This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-btn
|
<v-btn
|
||||||
|
:disabled="!canDoAction()"
|
||||||
color="blue darken-1"
|
color="blue darken-1"
|
||||||
text
|
text
|
||||||
@click="doAction()"
|
@click="doAction()"
|
||||||
@@ -50,8 +51,74 @@ export default {
|
|||||||
available() {
|
available() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
doAction() {
|
canDoAction() {
|
||||||
|
let vm = this;
|
||||||
|
if (vm.action == "Replace" && !vm.replace) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//other actions
|
||||||
|
if (vm.tag) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
async doAction() {
|
||||||
//do the bulk action
|
//do the bulk action
|
||||||
|
|
||||||
|
let vm = this;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//call api route
|
||||||
|
let jobId = await window.$gz.api.upsert(
|
||||||
|
`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;
|
||||||
|
|
||||||
|
/* /// <summary>
|
||||||
|
/// Job status for opsjobs
|
||||||
|
/// </summary>
|
||||||
|
public enum JobStatus : int
|
||||||
|
{
|
||||||
|
Absent=0,
|
||||||
|
Sleeping = 1,
|
||||||
|
Running = 2,
|
||||||
|
Completed = 3,
|
||||||
|
Failed = 4
|
||||||
|
} */
|
||||||
|
let jobStatus = 1;
|
||||||
|
//get status
|
||||||
|
|
||||||
|
while (vm.seedingJobActive == true) {
|
||||||
|
await window.$gz.util.sleepAsync(1000);
|
||||||
|
//check if done
|
||||||
|
jobStatus = await window.$gz.api.get(
|
||||||
|
`job-operations/status/${jobId}`
|
||||||
|
);
|
||||||
|
if (jobStatus.error) {
|
||||||
|
throw jobStatus.error;
|
||||||
|
}
|
||||||
|
jobStatus = jobStatus.data;
|
||||||
|
if (jobStatus == 4 || jobStatus == 0) {
|
||||||
|
throw "Seeding job failed";
|
||||||
|
}
|
||||||
|
if (jobStatus == 3) {
|
||||||
|
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"));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
normalize(value) {
|
normalize(value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user