This commit is contained in:
2020-06-16 18:10:21 +00:00
parent 41c8058854
commit 655f8e99c3
2 changed files with 18 additions and 17 deletions

View File

@@ -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));
}

View File

@@ -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);
/* /// <summary>
/// Job status for opsjobs
/// </summary>
@@ -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"
]);
}