From 41eff92e7d2a5b59209c7b6abcdb2c907259b8ec Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 9 Sep 2020 13:21:40 +0100 Subject: [PATCH] Updated Action status strings --- .../genericComponents/taskSubmitter.vue | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue b/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue index 0d521b1b..88c1fb29 100644 --- a/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue +++ b/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue @@ -16,7 +16,7 @@ class="uk-button uk-button-danger uk-margin-remove uk-float-right uk-width-1-1" @click="terminateTask()" > - Terminate + Cancel @@ -193,32 +193,29 @@ export default { var checkCondition = (resolve, reject) => { // If the condition is met, we're done! - axios - .get(this.taskUrl) - .then(response => { - console.log(response.data.status); - var result = response.data.status; - // If the task ends with success - if (result == "completed") { - resolve(response.data); - } - // If task ends with an error - else if (result == "error") { - // Pass the error string back with reject - reject(new Error(response.data.return)); - } - // If task ends with termination - else if (result == "cancelled") { - // Pass a generic termination error back with reject - reject(new Error("Task cancelled")); - } - else { - // Since the task is still running, we can update the progress bar - this.progress = response.data.progress; - // Check again after timeout - setTimeout(checkCondition, interval, resolve, reject); - } - }); + axios.get(this.taskUrl).then(response => { + console.log(response.data.status); + var result = response.data.status; + // If the task ends with success + if (result == "completed") { + resolve(response.data); + } + // If task ends with an error + else if (result == "error") { + // Pass the error string back with reject + reject(new Error(response.data.return)); + } + // If task ends with termination + else if (result == "cancelled") { + // Pass a generic termination error back with reject + reject(new Error("Task cancelled")); + } else { + // Since the task is still running, we can update the progress bar + this.progress = response.data.progress; + // Check again after timeout + setTimeout(checkCondition, interval, resolve, reject); + } + }); }; return new Promise(checkCondition); @@ -227,20 +224,16 @@ export default { pollProgress: function() { console.log("Starting progress polling"); - axios - .get(this.taskUrl) - .then(response => { - console.log("PROGRESS RESPONSE: ", response.data.progress); - this.progress = response.data.progress; - }); + axios.get(this.taskUrl).then(response => { + console.log("PROGRESS RESPONSE: ", response.data.progress); + this.progress = response.data.progress; + }); }, terminateTask: function() { - axios - .delete(this.taskUrl) - .then(response => { - console.log("TERMINATION RESPONSE: ", response.data); - }); + axios.delete(this.taskUrl).then(response => { + console.log("TERMINATION RESPONSE: ", response.data); + }); } } };