From 040ff001d8b22b37b5d0b23ab026f76722b78b5b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 28 Sep 2022 00:07:03 +0000 Subject: [PATCH] --- .../src/components/extension-tags-control.vue | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/ayanova/src/components/extension-tags-control.vue b/ayanova/src/components/extension-tags-control.vue index 0ab3baeb..8e1e4e06 100644 --- a/ayanova/src/components/extension-tags-control.vue +++ b/ayanova/src/components/extension-tags-control.vue @@ -37,6 +37,15 @@ @click="doAction()" >{{ $ay.t("StartJob") }} + + + {{ $ay.t("Cancel") }}{{ progress }} @@ -50,6 +59,8 @@ export default { tag: null, replace: null, jobActive: false, + currentJobId: null, + progress: "", rights: window.$gz.role.defaultRightsObject(), available: false }), @@ -78,6 +89,12 @@ export default { } return false; }, + async requestCancel() { + await window.$gz.api.upsert( + "job-operations/request-cancel", + this.currentJobId + ); + }, async doAction() { let url = "tag-list/"; switch (this.action) { @@ -93,29 +110,34 @@ export default { } try { + this.progress = ""; let jobId = await window.$gz.api.upsert(url, this.dataListSelection); if (jobId.error) { throw new Error(window.$gz.errorHandler.errorToString(jobId, this)); } - jobId = jobId.jobId; + + this.currentJobId = jobId.jobId; this.jobActive = true; - let jobStatus = 1; + let jobProgress = {}; while (this.jobActive == true) { - await window.$gz.util.sleepAsync(1000); - jobStatus = await window.$gz.api.get( - `job-operations/status/${jobId}` + await window.$gz.util.sleepAsync(2000); + jobProgress = await window.$gz.api.get( + `job-operations/progress/${this.currentJobId}` ); - if (jobStatus.error) { + + if (jobProgress.error) { throw new Error( - window.$gz.errorHandler.errorToString(jobStatus, this) + window.$gz.errorHandler.errorToString(jobProgress, this) ); } - jobStatus = jobStatus.data; - if (jobStatus == 4 || jobStatus == 0) { + jobProgress = jobProgress.data; + this.progress = jobProgress.progress; + + if (jobProgress.jobStatus == 4 || jobProgress.jobStatus == 0) { throw new Error("Job failed"); } - if (jobStatus == 3) { + if (jobProgress.jobStatus == 3) { this.jobActive = false; } }