@adminforth/background-jobs 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.log CHANGED
@@ -11,5 +11,5 @@ custom/StateToIcon.vue
11
11
  custom/tsconfig.json
12
12
  custom/utils.ts
13
13
 
14
- sent 11,390 bytes received 134 bytes 23,048.00 bytes/sec
15
- total size is 10,912 speedup is 0.95
14
+ sent 11,734 bytes received 134 bytes 23,736.00 bytes/sec
15
+ total size is 11,249 speedup is 0.95
@@ -2,9 +2,14 @@
2
2
  <div class="flex flex-col w-full min-w-96">
3
3
  <div class="flex items-center mb-1">
4
4
  <h2 class="text-lg font-semibold dark:text-white">{{ job.name }}</h2>
5
- <p class="ml-2 text-xs text-gray-600 dark:text-gray-200 h-full"> {{ getTimeAgoString(new Date(job.createdAt)) }}</p>
6
- <p class="ml-auto text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
7
- <StateToIcon :job="job" />
5
+ <p class="ml-2 text-xs text-gray-600 dark:text-gray-200 h-full">{{ t('Created:') }} {{ getTimeAgoString(new Date(job.createdAt)) }}</p>
6
+ <div class="ml-auto flex flex-col items-start">
7
+ <div class="flex items-center">
8
+ <p class=" text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
9
+ <StateToIcon :job="job" />
10
+ </div>
11
+ <p class="text-xs text-gray-600 dark:text-gray-200 h-full" v-if="job.finishedAt"> {{ t('Finished:') }} {{ getTimeAgoString(new Date(job.finishedAt)) }}</p>
12
+ </div>
8
13
  </div>
9
14
  <div class="flex items-center gap-4 w-full">
10
15
  <ProgressBar
package/custom/utils.ts CHANGED
@@ -5,5 +5,6 @@ export interface IJob {
5
5
  status: 'IN_PROGRESS' | 'DONE' | 'DONE_WITH_ERRORS' | 'CANCELLED';
6
6
  progress: number; // 0 to 100
7
7
  createdAt: Date;
8
+ finishedAt?: Date;
8
9
  customComponent?: AdminForthComponentDeclarationFull;
9
10
  }
@@ -2,9 +2,14 @@
2
2
  <div class="flex flex-col w-full min-w-96">
3
3
  <div class="flex items-center mb-1">
4
4
  <h2 class="text-lg font-semibold dark:text-white">{{ job.name }}</h2>
5
- <p class="ml-2 text-xs text-gray-600 dark:text-gray-200 h-full"> {{ getTimeAgoString(new Date(job.createdAt)) }}</p>
6
- <p class="ml-auto text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
7
- <StateToIcon :job="job" />
5
+ <p class="ml-2 text-xs text-gray-600 dark:text-gray-200 h-full">{{ t('Created:') }} {{ getTimeAgoString(new Date(job.createdAt)) }}</p>
6
+ <div class="ml-auto flex flex-col items-start">
7
+ <div class="flex items-center">
8
+ <p class=" text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
9
+ <StateToIcon :job="job" />
10
+ </div>
11
+ <p class="text-xs text-gray-600 dark:text-gray-200 h-full" v-if="job.finishedAt"> {{ t('Finished:') }} {{ getTimeAgoString(new Date(job.finishedAt)) }}</p>
12
+ </div>
8
13
  </div>
9
14
  <div class="flex items-center gap-4 w-full">
10
15
  <ProgressBar
@@ -5,5 +5,6 @@ export interface IJob {
5
5
  status: 'IN_PROGRESS' | 'DONE' | 'DONE_WITH_ERRORS' | 'CANCELLED';
6
6
  progress: number; // 0 to 100
7
7
  createdAt: Date;
8
+ finishedAt?: Date;
8
9
  customComponent?: AdminForthComponentDeclarationFull;
9
10
  }
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { afLogger } from "adminforth";
12
12
  import pLimit from 'p-limit';
13
13
  import { Level } from 'level';
14
14
  import fs from 'fs/promises';
15
- export default class extends AdminForthPlugin {
15
+ export default class BackgroundJobsPlugin extends AdminForthPlugin {
16
16
  constructor(options) {
17
17
  super(options, import.meta.url);
18
18
  this.taskHandlers = {};
@@ -37,6 +37,7 @@ export default class extends AdminForthPlugin {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
38
  var _a, _b;
39
39
  _super.modifyResourceConfig.call(this, adminforth, resourceConfig);
40
+ console.log('Modifying resource config for Background Jobs Plugin');
40
41
  if (!((_b = (_a = adminforth.config.customization) === null || _a === void 0 ? void 0 : _a.globalInjections) === null || _b === void 0 ? void 0 : _b.header)) {
41
42
  adminforth.config.customization.globalInjections.header = [];
42
43
  }
@@ -382,6 +383,7 @@ export default class extends AdminForthPlugin {
382
383
  id: job[resourcePk],
383
384
  name: job[this.options.nameField],
384
385
  createdAt: job[this.options.createdAtField],
386
+ finishedAt: job[this.options.finishedAtField] || null,
385
387
  status: job[this.options.statusField],
386
388
  progress: job[this.options.progressField],
387
389
  customComponent: this.jobCustomComponents[job[this.options.jobHandlerField]],
package/index.ts CHANGED
@@ -15,7 +15,7 @@ type taskType = {
15
15
  state: Record<string, any>;
16
16
  }
17
17
 
18
- export default class extends AdminForthPlugin {
18
+ export default class BackgroundJobsPlugin extends AdminForthPlugin {
19
19
  options: PluginOptions;
20
20
  private taskHandlers: Record<string, taskHandlerType> = {};
21
21
  private jobCustomComponents: Record<string, AdminForthComponentDeclarationFull> = {};
@@ -39,7 +39,7 @@ export default class extends AdminForthPlugin {
39
39
 
40
40
  async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
41
41
  super.modifyResourceConfig(adminforth, resourceConfig);
42
-
42
+ console.log('Modifying resource config for Background Jobs Plugin');
43
43
  if (!adminforth.config.customization?.globalInjections?.header) {
44
44
  adminforth.config.customization.globalInjections.header = [];
45
45
  }
@@ -413,6 +413,7 @@ export default class extends AdminForthPlugin {
413
413
  id: job[resourcePk],
414
414
  name: job[this.options.nameField],
415
415
  createdAt: job[this.options.createdAtField],
416
+ finishedAt: job[this.options.finishedAtField] || null,
416
417
  status: job[this.options.statusField],
417
418
  progress: job[this.options.progressField],
418
419
  customComponent: this.jobCustomComponents[job[this.options.jobHandlerField]],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/background-jobs",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",