@adminforth/background-jobs 1.11.6 → 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 CHANGED
@@ -13,5 +13,5 @@ custom/tsconfig.json
13
13
  custom/useBackgroundJobApi.ts
14
14
  custom/utils.ts
15
15
 
16
- sent 18,507 bytes received 172 bytes 37,358.00 bytes/sec
17
- total size is 17,874 speedup is 0.96
16
+ sent 18,730 bytes received 172 bytes 37,804.00 bytes/sec
17
+ total size is 18,097 speedup is 0.96
@@ -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>
@@ -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/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
- afLogger.error(`Error in handling task ${taskIndex} of job ${jobId}: ${error}`);
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
- afLogger.error(`Error in handling task ${taskIndex} of job ${jobId}: ${error}`, );
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++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/background-jobs",
3
- "version": "1.11.6",
3
+ "version": "1.11.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",