@adminforth/background-jobs 1.2.3 → 1.3.0

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,397 bytes received 134 bytes 23,062.00 bytes/sec
15
- total size is 10,912 speedup is 0.95
14
+ sent 12,276 bytes received 134 bytes 24,820.00 bytes/sec
15
+ total size is 11,791 speedup is 0.95
@@ -1,10 +1,27 @@
1
1
  <template>
2
2
  <div class="flex flex-col w-full min-w-96">
3
3
  <div class="flex items-center mb-1">
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" />
4
+ <div class="flex flex-col items-start">
5
+ <h2 class="text-lg font-semibold dark:text-white">{{ job.name }}</h2>
6
+ <Tooltip>
7
+ <p class="text-xs text-gray-600 dark:text-gray-200 h-full">{{ t('Created:') }} {{ getTimeAgoString(new Date(job.createdAt)) }}</p>
8
+ <template #tooltip>
9
+ {{ t('Created at:') }} {{ new Date(job.createdAt).toLocaleString() }}
10
+ </template>
11
+ </Tooltip>
12
+ </div>
13
+ <div class="ml-auto flex flex-col items-start">
14
+ <div class="flex items-center">
15
+ <p class=" text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
16
+ <StateToIcon :job="job" />
17
+ </div>
18
+ <Tooltip v-if="job.finishedAt">
19
+ <p class="text-xs text-gray-600 dark:text-gray-200 h-full"> {{ t('Finished:') }} {{ getTimeAgoString(new Date(job.finishedAt)) }}</p>
20
+ <template #tooltip>
21
+ {{ t('Finished at:') }} {{ new Date(job.finishedAt).toLocaleString() }}
22
+ </template>
23
+ </Tooltip>
24
+ </div>
8
25
  </div>
9
26
  <div class="flex items-center gap-4 w-full">
10
27
  <ProgressBar
@@ -35,7 +52,7 @@
35
52
 
36
53
  <script setup lang="ts">
37
54
  import type { IJob } from './utils';
38
- import { ProgressBar, Button } from '@/afcl';
55
+ import { ProgressBar, Button, Tooltip } from '@/afcl';
39
56
  import { getTimeAgoString, callAdminForthApi, getCustomComponent} from '@/utils';
40
57
  import { useI18n } from 'vue-i18n';
41
58
  import StateToIcon from './StateToIcon.vue';
@@ -94,6 +94,9 @@
94
94
  if (data.progress !== undefined) {
95
95
  jobs.value[jobIndex].progress = data.progress;
96
96
  }
97
+ if (data.finishedAt) {
98
+ jobs.value[jobIndex].finishedAt = data.finishedAt;
99
+ }
97
100
  } else {
98
101
  jobs.value.unshift({
99
102
  id: data.jobId,
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
  }
@@ -1,10 +1,27 @@
1
1
  <template>
2
2
  <div class="flex flex-col w-full min-w-96">
3
3
  <div class="flex items-center mb-1">
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" />
4
+ <div class="flex flex-col items-start">
5
+ <h2 class="text-lg font-semibold dark:text-white">{{ job.name }}</h2>
6
+ <Tooltip>
7
+ <p class="text-xs text-gray-600 dark:text-gray-200 h-full">{{ t('Created:') }} {{ getTimeAgoString(new Date(job.createdAt)) }}</p>
8
+ <template #tooltip>
9
+ {{ t('Created at:') }} {{ new Date(job.createdAt).toLocaleString() }}
10
+ </template>
11
+ </Tooltip>
12
+ </div>
13
+ <div class="ml-auto flex flex-col items-start">
14
+ <div class="flex items-center">
15
+ <p class=" text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
16
+ <StateToIcon :job="job" />
17
+ </div>
18
+ <Tooltip v-if="job.finishedAt">
19
+ <p class="text-xs text-gray-600 dark:text-gray-200 h-full"> {{ t('Finished:') }} {{ getTimeAgoString(new Date(job.finishedAt)) }}</p>
20
+ <template #tooltip>
21
+ {{ t('Finished at:') }} {{ new Date(job.finishedAt).toLocaleString() }}
22
+ </template>
23
+ </Tooltip>
24
+ </div>
8
25
  </div>
9
26
  <div class="flex items-center gap-4 w-full">
10
27
  <ProgressBar
@@ -35,7 +52,7 @@
35
52
 
36
53
  <script setup lang="ts">
37
54
  import type { IJob } from './utils';
38
- import { ProgressBar, Button } from '@/afcl';
55
+ import { ProgressBar, Button, Tooltip } from '@/afcl';
39
56
  import { getTimeAgoString, callAdminForthApi, getCustomComponent} from '@/utils';
40
57
  import { useI18n } from 'vue-i18n';
41
58
  import StateToIcon from './StateToIcon.vue';
@@ -94,6 +94,9 @@
94
94
  if (data.progress !== undefined) {
95
95
  jobs.value[jobIndex].progress = data.progress;
96
96
  }
97
+ if (data.finishedAt) {
98
+ jobs.value[jobIndex].finishedAt = data.finishedAt;
99
+ }
97
100
  } else {
98
101
  jobs.value.unshift({
99
102
  id: data.jobId,
@@ -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
@@ -242,7 +242,7 @@ export default class BackgroundJobsPlugin extends AdminForthPlugin {
242
242
  [this.options.statusField]: 'DONE',
243
243
  [this.options.finishedAtField]: (new Date()).toISOString(),
244
244
  });
245
- this.adminforth.websocket.publish('/background-jobs', { jobId, status: 'DONE' });
245
+ this.adminforth.websocket.publish('/background-jobs', { jobId, status: 'DONE', finishedAt: (new Date()).toISOString() });
246
246
  }
247
247
  else if (failedTasks > 0) {
248
248
  yield this.adminforth.resource(this.getResourceId()).update(jobId, {
@@ -383,6 +383,7 @@ export default class BackgroundJobsPlugin extends AdminForthPlugin {
383
383
  id: job[resourcePk],
384
384
  name: job[this.options.nameField],
385
385
  createdAt: job[this.options.createdAtField],
386
+ finishedAt: job[this.options.finishedAtField] || null,
386
387
  status: job[this.options.statusField],
387
388
  progress: job[this.options.progressField],
388
389
  customComponent: this.jobCustomComponents[job[this.options.jobHandlerField]],
package/index.ts CHANGED
@@ -273,7 +273,7 @@ export default class BackgroundJobsPlugin extends AdminForthPlugin {
273
273
  [this.options.statusField]: 'DONE',
274
274
  [this.options.finishedAtField]: (new Date()).toISOString(),
275
275
  })
276
- this.adminforth.websocket.publish('/background-jobs', { jobId, status: 'DONE' });
276
+ this.adminforth.websocket.publish('/background-jobs', { jobId, status: 'DONE', finishedAt: (new Date()).toISOString() });
277
277
  } else if (failedTasks > 0) {
278
278
  await this.adminforth.resource(this.getResourceId()).update(jobId, {
279
279
  [this.options.statusField]: 'DONE_WITH_ERRORS',
@@ -413,6 +413,7 @@ export default class BackgroundJobsPlugin 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.3",
3
+ "version": "1.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",