Updated Action status strings

This commit is contained in:
Joel Collins 2020-09-09 13:21:40 +01:00
parent a34f98275b
commit 41eff92e7d

View file

@ -16,7 +16,7 @@
class="uk-button uk-button-danger uk-margin-remove uk-float-right uk-width-1-1" class="uk-button uk-button-danger uk-margin-remove uk-float-right uk-width-1-1"
@click="terminateTask()" @click="terminateTask()"
> >
Terminate Cancel
</button> </button>
</div> </div>
@ -193,32 +193,29 @@ export default {
var checkCondition = (resolve, reject) => { var checkCondition = (resolve, reject) => {
// If the condition is met, we're done! // If the condition is met, we're done!
axios axios.get(this.taskUrl).then(response => {
.get(this.taskUrl) console.log(response.data.status);
.then(response => { var result = response.data.status;
console.log(response.data.status); // If the task ends with success
var result = response.data.status; if (result == "completed") {
// If the task ends with success resolve(response.data);
if (result == "completed") { }
resolve(response.data); // If task ends with an error
} else if (result == "error") {
// If task ends with an error // Pass the error string back with reject
else if (result == "error") { reject(new Error(response.data.return));
// Pass the error string back with reject }
reject(new Error(response.data.return)); // If task ends with termination
} else if (result == "cancelled") {
// If task ends with termination // Pass a generic termination error back with reject
else if (result == "cancelled") { reject(new Error("Task cancelled"));
// Pass a generic termination error back with reject } else {
reject(new Error("Task cancelled")); // Since the task is still running, we can update the progress bar
} this.progress = response.data.progress;
else { // Check again after timeout
// Since the task is still running, we can update the progress bar setTimeout(checkCondition, interval, resolve, reject);
this.progress = response.data.progress; }
// Check again after timeout });
setTimeout(checkCondition, interval, resolve, reject);
}
});
}; };
return new Promise(checkCondition); return new Promise(checkCondition);
@ -227,20 +224,16 @@ export default {
pollProgress: function() { pollProgress: function() {
console.log("Starting progress polling"); console.log("Starting progress polling");
axios axios.get(this.taskUrl).then(response => {
.get(this.taskUrl) console.log("PROGRESS RESPONSE: ", response.data.progress);
.then(response => { this.progress = response.data.progress;
console.log("PROGRESS RESPONSE: ", response.data.progress); });
this.progress = response.data.progress;
});
}, },
terminateTask: function() { terminateTask: function() {
axios axios.delete(this.taskUrl).then(response => {
.delete(this.taskUrl) console.log("TERMINATION RESPONSE: ", response.data);
.then(response => { });
console.log("TERMINATION RESPONSE: ", response.data);
});
} }
} }
}; };