From 655f8e99c37b7f2616db9546634a21f9ebe65ee5 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 16 Jun 2020 18:10:21 +0000 Subject: [PATCH] --- ayanova/src/api/gzutil.js | 1 - ayanova/src/views/ay-evaluate.vue | 34 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ayanova/src/api/gzutil.js b/ayanova/src/api/gzutil.js index 0dc0557b..9cc0c7b1 100644 --- a/ayanova/src/api/gzutil.js +++ b/ayanova/src/api/gzutil.js @@ -370,7 +370,6 @@ export default { // Sleep async // sleepAsync: function(milliseconds) { - console.log("sleep async"); // eslint-disable-next-line return new Promise((resolve) => setTimeout(resolve, milliseconds)); } diff --git a/ayanova/src/views/ay-evaluate.vue b/ayanova/src/views/ay-evaluate.vue index 4ab781cc..c00f4c92 100644 --- a/ayanova/src/views/ay-evaluate.vue +++ b/ayanova/src/views/ay-evaluate.vue @@ -174,20 +174,17 @@ export default { ); } - //notice about what's going to happen - //maybe some kind of ui to determine if a job is running or not? - //a job monitoring ui dialog or something would be ideal - //call seed route let jobId = await window.$gz.api.upsertEx( `trial/seed/${vm.obj.seedLevel}/${vm.obj.timeZoneOffset}` ); - + if (jobId.error) { + throw jobId.error; + } + jobId = jobId.jobId; //it's in a sub key //indicate loading by setting on button - vm.seedingJobActive = true; - console.log("Jobid is", jobId); /* /// /// Job status for opsjobs /// @@ -202,19 +199,16 @@ export default { let jobStatus = 1; //get status - while (vm.seedingJobActive) { - console.log( - "top of while loop about to sleep 5 seconds seeding job active=", - vm.seedingJobActive - ); - + while (vm.seedingJobActive == true) { await window.$gz.util.sleepAsync(5000); - console.log("back from sleep checking job"); //check if done jobStatus = await window.$gz.api.get( `job-operations/status/${jobId}` ); - console.log(`Job status is ${jobStatus}`); + if (jobStatus.error) { + throw jobStatus.error; + } + jobStatus = jobStatus.data; if (jobStatus == 4 || jobStatus == 0) { throw "Seeding job failed"; } @@ -222,9 +216,15 @@ export default { vm.seedingJobActive = false; } } + + //Here if it's completed successfully + window.$gz.eventBus.$emit("notify-success", vm.$ay.t("JobCompleted")); + + vm.$router.push("/login"); } catch (error) { vm.seedingJobActive = false; window.$gz.errorHandler.handleFormError(error, vm); + window.$gz.eventBus.$emit("notify-error", vm.$ay.t("JobFailed")); } } } @@ -299,7 +299,9 @@ function fetchTranslatedText(vm) { "StartSeeding", "AdminEraseDatabaseWarning", "AdminEraseDatabaseLastWarning", - "UserTimeZoneOffset" + "UserTimeZoneOffset", + "JobCompleted", + "JobFailed" ]); }