rundetails: add run cancel button

This commit is contained in:
Simone Gotti 2019-05-15 14:44:35 +02:00
parent 74cd268431
commit b10a7f18e1
2 changed files with 18 additions and 1 deletions

View File

@ -43,6 +43,11 @@
</div>
</div>
</div>
<button
class="button is-danger"
v-if="run.phase == 'queued'"
@click="cancelRun(run.id)"
>Cancel</button>
<button
class="button is-danger"
v-if="run.phase == 'running'"
@ -94,7 +99,7 @@
</template>
<script>
import { stopRun, restartRun } from "@/util/data.js";
import { cancelRun, stopRun, restartRun } from "@/util/data.js";
export default {
name: "RunDetail",
@ -141,6 +146,7 @@ export default {
return "unknown";
},
stopRun: stopRun,
cancelRun: cancelRun,
restartRun(runid, fromStart) {
this.dropdownActive = false;
restartRun(runid, fromStart);

View File

@ -170,6 +170,17 @@ export async function restartRun(runid, fromStart) {
return await fetch(apiurl(path), init)
}
export async function cancelRun(runid) {
let path = "/runs/" + runid + "/actions"
let init = {
method: "PUT",
body: JSON.stringify({
action_type: "cancel"
})
}
return await fetch(apiurl(path), init)
}
export async function stopRun(runid) {
let path = "/runs/" + runid + "/actions"
let init = {