diff --git a/src/components/genericComponents/taskProgress.vue b/src/components/genericComponents/taskProgress.vue new file mode 100644 index 00000000..3586d3c8 --- /dev/null +++ b/src/components/genericComponents/taskProgress.vue @@ -0,0 +1,181 @@ + + + + + \ No newline at end of file diff --git a/src/components/pluginComponents/JsonForm.vue b/src/components/pluginComponents/JsonForm.vue index 1364419c..be99e39e 100644 --- a/src/components/pluginComponents/JsonForm.vue +++ b/src/components/pluginComponents/JsonForm.vue @@ -27,10 +27,10 @@
- +
- + @@ -51,6 +51,7 @@ import tagList from "../fieldComponents/tagList" import keyvalList from "../fieldComponents/keyvalList" import progressBar from "../genericComponents/progressBar" +import taskProgress from "../genericComponents/taskProgress" export default { name: 'JsonForm', @@ -64,7 +65,8 @@ export default { checkList, tagList, keyvalList, - progressBar + progressBar, + taskProgress }, props: { @@ -101,7 +103,8 @@ export default { data: function () { return { formData: {}, - taskRunning: false + taskRunning: false, + taskId: null } }, @@ -182,23 +185,30 @@ export default { }, newLongRequest: function(params) { - this.taskRunning = true axios.post(this.submitApiUri, params) .then(response => { + // Fetch the task ID console.log("Task ID: " + response.data.id) + this.taskId = response.data.id // Start the store polling TaskId for success - return this.$store.dispatch('pollTask', [response.data.id, null, null]) + this.taskRunning = true + return this.$store.dispatch('pollTask', [this.taskId, null, null]) }) .then(response => { // Do something with the response console.log(response) }) .catch(error => { - this.modalError(error) // Let mixin handle error + console.log("Task eneded with error: ", error) + if (error) { + this.modalError(error) // Display the error, if one exists + } }) .finally(() => { console.log("Cleaning up after task.") + // Reset taskRunning and taskId this.taskRunning = false + this.taskId = null // Update the form data if we're self-updating if (this.selfUpdate) { this.getFormData() diff --git a/src/store.js b/src/store.js index 0c4cb7ff..157e89a1 100644 --- a/src/store.js +++ b/src/store.js @@ -162,8 +162,19 @@ export default new Vuex.Store({ } // 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 == 'terminated') { + // Pass a generic termination error back with reject + reject(new Error("Task terminated")) + } + // If task ends in any other way + else if (result != 'running') { + // Pass status string as error + reject(new Error(result)) + } // If the condition isn't met but the timeout hasn't elapsed, go again else if (Number(new Date()) < endTime) { setTimeout(checkCondition, interval, resolve, reject)