rundetail: handle api errors

This commit is contained in:
Simone Gotti 2019-05-15 14:59:52 +02:00
parent 336869fe73
commit f85243acfe
1 changed files with 30 additions and 4 deletions

View File

@ -95,6 +95,12 @@
</div> </div>
</div> </div>
</div> </div>
<div v-if="stopRunError" class="message is-danger">
<div class="message-body">{{ stopRunError }}</div>
</div>
<div v-if="cancelRunError" class="message is-danger">
<div class="message-body">{{ cancelRunError }}</div>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -109,10 +115,16 @@ export default {
}, },
data() { data() {
return { return {
stopRunError: null,
cancelRunError: null,
dropdownActive: false dropdownActive: false
}; };
}, },
methods: { methods: {
resetErrors() {
this.stopRunError = null;
this.cancelRunError = null;
},
toggleDropdown() { toggleDropdown() {
this.dropdownActive = !this.dropdownActive; this.dropdownActive = !this.dropdownActive;
}, },
@ -146,13 +158,27 @@ export default {
if (task.status == "running") return "running"; if (task.status == "running") return "running";
return "unknown"; return "unknown";
}, },
stopRun(runid) { async stopRun(runid) {
this.resetErrors();
let { error } = await stopRun(runid);
if (error) {
this.cancelRunError = error;
return;
}
this.run.stopping = true; this.run.stopping = true;
stopRun(runid);
}, },
cancelRun(runid) { async cancelRun(runid) {
this.resetErrors();
let { error } = await cancelRun(runid);
if (error) {
this.cancelRunError = error;
return;
}
this.run.phase = "cancelled"; this.run.phase = "cancelled";
cancelRun(runid);
}, },
restartRun(runid, fromStart) { restartRun(runid, fromStart) {
this.dropdownActive = false; this.dropdownActive = false;