@adminforth/background-jobs 1.11.5 → 1.11.7
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 +2 -2
- package/custom/JobInfoPopup.vue +15 -1
- package/custom/JobsList.vue +1 -1
- package/custom/utils.ts +1 -1
- package/dist/custom/JobInfoPopup.vue +15 -1
- package/dist/custom/JobsList.vue +1 -1
- package/dist/custom/utils.ts +1 -1
- package/dist/index.js +3 -1
- package/index.ts +3 -1
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -13,5 +13,5 @@ custom/tsconfig.json
|
|
|
13
13
|
custom/useBackgroundJobApi.ts
|
|
14
14
|
custom/utils.ts
|
|
15
15
|
|
|
16
|
-
sent 18,
|
|
17
|
-
total size is
|
|
16
|
+
sent 18,730 bytes received 172 bytes 37,804.00 bytes/sec
|
|
17
|
+
total size is 18,097 speedup is 0.96
|
package/custom/JobInfoPopup.vue
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
</div>
|
|
36
36
|
<div class="flex items-center gap-4 w-full mt-4">
|
|
37
37
|
<ProgressBar
|
|
38
|
-
:current-value="job.progress"
|
|
38
|
+
:current-value="parseInt(job.progress, 10)"
|
|
39
39
|
:max-value="100"
|
|
40
40
|
:min-value="0"
|
|
41
41
|
:showAnimation="job.status === 'IN_PROGRESS'"
|
|
@@ -67,6 +67,7 @@ import { getTimeAgoString, callAdminForthApi, getCustomComponent} from '@/utils'
|
|
|
67
67
|
import { useI18n } from 'vue-i18n';
|
|
68
68
|
import StateToIcon from './StateToIcon.vue';
|
|
69
69
|
import { useAdminforth } from '@/adminforth';
|
|
70
|
+
import { watch } from 'vue';
|
|
70
71
|
|
|
71
72
|
|
|
72
73
|
const { t } = useI18n();
|
|
@@ -133,6 +134,19 @@ async function getJobTasks(limit: number = 10, offset: number = 0): Promise<{sta
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
watch(
|
|
138
|
+
() => props.job.state?.error,
|
|
139
|
+
(error) => {
|
|
140
|
+
if (error) {
|
|
141
|
+
adminforth.alert({
|
|
142
|
+
message: error,
|
|
143
|
+
variant: 'danger',
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{ immediate: true }
|
|
148
|
+
);
|
|
149
|
+
|
|
136
150
|
|
|
137
151
|
|
|
138
152
|
</script>
|
package/custom/JobsList.vue
CHANGED
package/custom/utils.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface IJob {
|
|
|
4
4
|
name: string;
|
|
5
5
|
status: 'IN_PROGRESS' | 'DONE' | 'DONE_WITH_ERRORS' | 'CANCELLED';
|
|
6
6
|
state: Record<string, any>;
|
|
7
|
-
progress:
|
|
7
|
+
progress: string; // 0 to 100
|
|
8
8
|
createdAt: Date;
|
|
9
9
|
finishedAt?: Date;
|
|
10
10
|
customComponent?: AdminForthComponentDeclarationFull;
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
</div>
|
|
36
36
|
<div class="flex items-center gap-4 w-full mt-4">
|
|
37
37
|
<ProgressBar
|
|
38
|
-
:current-value="job.progress"
|
|
38
|
+
:current-value="parseInt(job.progress, 10)"
|
|
39
39
|
:max-value="100"
|
|
40
40
|
:min-value="0"
|
|
41
41
|
:showAnimation="job.status === 'IN_PROGRESS'"
|
|
@@ -67,6 +67,7 @@ import { getTimeAgoString, callAdminForthApi, getCustomComponent} from '@/utils'
|
|
|
67
67
|
import { useI18n } from 'vue-i18n';
|
|
68
68
|
import StateToIcon from './StateToIcon.vue';
|
|
69
69
|
import { useAdminforth } from '@/adminforth';
|
|
70
|
+
import { watch } from 'vue';
|
|
70
71
|
|
|
71
72
|
|
|
72
73
|
const { t } = useI18n();
|
|
@@ -133,6 +134,19 @@ async function getJobTasks(limit: number = 10, offset: number = 0): Promise<{sta
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
watch(
|
|
138
|
+
() => props.job.state?.error,
|
|
139
|
+
(error) => {
|
|
140
|
+
if (error) {
|
|
141
|
+
adminforth.alert({
|
|
142
|
+
message: error,
|
|
143
|
+
variant: 'danger',
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{ immediate: true }
|
|
148
|
+
);
|
|
149
|
+
|
|
136
150
|
|
|
137
151
|
|
|
138
152
|
</script>
|
package/dist/custom/JobsList.vue
CHANGED
package/dist/custom/utils.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface IJob {
|
|
|
4
4
|
name: string;
|
|
5
5
|
status: 'IN_PROGRESS' | 'DONE' | 'DONE_WITH_ERRORS' | 'CANCELLED';
|
|
6
6
|
state: Record<string, any>;
|
|
7
|
-
progress:
|
|
7
|
+
progress: string; // 0 to 100
|
|
8
8
|
createdAt: Date;
|
|
9
9
|
finishedAt?: Date;
|
|
10
10
|
customComponent?: AdminForthComponentDeclarationFull;
|
package/dist/index.js
CHANGED
|
@@ -246,7 +246,9 @@ export default class BackgroundJobsPlugin extends AdminForthPlugin {
|
|
|
246
246
|
this.adminforth.websocket.publish(`/background-jobs-task-update/${jobId}`, { taskIndex, status: "DONE" });
|
|
247
247
|
}
|
|
248
248
|
catch (error) {
|
|
249
|
-
|
|
249
|
+
const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || 'Unknown error';
|
|
250
|
+
afLogger.error(`Error in handling task ${taskIndex} of job ${jobId}: ${errorMessage}`);
|
|
251
|
+
yield this.setJobField(jobId, 'error', errorMessage);
|
|
250
252
|
yield this.setLevelDbTaskStatusField(jobLevelDb, taskIndex.toString(), 'FAILED');
|
|
251
253
|
this.adminforth.websocket.publish(`/background-jobs-task-update/${jobId}`, { taskIndex, status: "FAILED" });
|
|
252
254
|
failedTasks++;
|
package/index.ts
CHANGED
|
@@ -279,7 +279,9 @@ export default class BackgroundJobsPlugin extends AdminForthPlugin {
|
|
|
279
279
|
await this.setLevelDbTaskStatusField(jobLevelDb, taskIndex.toString(), 'DONE');
|
|
280
280
|
this.adminforth.websocket.publish(`/background-jobs-task-update/${jobId}`, { taskIndex, status: "DONE" });
|
|
281
281
|
} catch (error) {
|
|
282
|
-
|
|
282
|
+
const errorMessage = error?.message || 'Unknown error';
|
|
283
|
+
afLogger.error(`Error in handling task ${taskIndex} of job ${jobId}: ${errorMessage}`, );
|
|
284
|
+
await this.setJobField(jobId, 'error', errorMessage);
|
|
283
285
|
await this.setLevelDbTaskStatusField(jobLevelDb, taskIndex.toString(), 'FAILED');
|
|
284
286
|
this.adminforth.websocket.publish(`/background-jobs-task-update/${jobId}`, { taskIndex, status: "FAILED" });
|
|
285
287
|
failedTasks++;
|