implement task approval notifications and action
This commit is contained in:
parent
a0097ea16e
commit
53e814f00e
|
@ -17,6 +17,9 @@
|
||||||
<router-link class="column is-10" tag="a" :to="runTaskLink(task)">
|
<router-link class="column is-10" tag="a" :to="runTaskLink(task)">
|
||||||
<span class="name">{{task.name}}</span>
|
<span class="name">{{task.name}}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<div class="column">
|
||||||
|
<span class="tag" v-if="run.tasks_waiting_approval.includes(task.id)">Waiting approval</span>
|
||||||
|
</div>
|
||||||
<div class="parents column">
|
<div class="parents column">
|
||||||
<span v-if="parents(task).length > 0">depends on: </span>
|
<span v-if="parents(task).length > 0">depends on: </span>
|
||||||
<span class="parent" v-for="dep in parents(task)" v-bind:key="dep">{{dep}}</span>
|
<span class="parent" v-for="dep in parents(task)" v-bind:key="dep">{{dep}}</span>
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
<span>{{run.name}}</span>
|
<span>{{run.name}}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
<div class="commitmessage">{{run.annotations.message}}</div>
|
<div class="commitmessage">{{run.annotations.message}}</div>
|
||||||
|
<span v-if="waitingApproval(run)" class="waitingapproval tag">Waiting Approval</span>
|
||||||
|
<span v-if="!waitingApproval(run)" class="waitingapproval"></span>
|
||||||
<span v-if="stillRunning(run)" class="stillrunning tag">Still running</span>
|
<span v-if="stillRunning(run)" class="stillrunning tag">Still running</span>
|
||||||
<span v-if="!stillRunning(run)" class="stillrunning"></span>
|
<span v-if="!stillRunning(run)" class="stillrunning"></span>
|
||||||
<div class="source-info">
|
<div class="source-info">
|
||||||
|
@ -95,6 +97,9 @@ export default {
|
||||||
stillRunning(run) {
|
stillRunning(run) {
|
||||||
return run.result != "unknown" && run.phase == "running";
|
return run.result != "unknown" && run.phase == "running";
|
||||||
},
|
},
|
||||||
|
waitingApproval(run) {
|
||||||
|
return run.tasks_waiting_approval.length > 0;
|
||||||
|
},
|
||||||
runResultClass(run) {
|
runResultClass(run) {
|
||||||
if (run.result == "unknown") {
|
if (run.result == "unknown") {
|
||||||
if (run.phase == "queued") return "unknown";
|
if (run.phase == "queued") return "unknown";
|
||||||
|
@ -227,6 +232,10 @@ export default {
|
||||||
flex: 0 0 10%;
|
flex: 0 0 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.waitingapproval {
|
||||||
|
flex: 0 0 10%;
|
||||||
|
}
|
||||||
|
|
||||||
.source-info {
|
.source-info {
|
||||||
flex: 0 0 10%;
|
flex: 0 0 10%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
@ -2,9 +2,18 @@
|
||||||
<div>
|
<div>
|
||||||
<RunDetail :run="run"/>
|
<RunDetail :run="run"/>
|
||||||
<div v-if="task != null">
|
<div v-if="task != null">
|
||||||
<div class="task-title">
|
<div class="columns">
|
||||||
<span class="task-name" v-html="task.name"/>
|
<div class="task-title column is-10">
|
||||||
<span class="tag" :class="taskClass(task)">{{ task.status | capitalize }}</span>
|
<span class="task-name" v-html="task.name"/>
|
||||||
|
<span class="tag" :class="taskClass(task)">{{ task.status | capitalize }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="task-actions column is-2 is-pulled-right">
|
||||||
|
<button
|
||||||
|
class="button is-primary"
|
||||||
|
v-if="task.waiting_approval"
|
||||||
|
@click="approveTask(run.id, task.id)"
|
||||||
|
>Approve</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Collapse
|
<Collapse
|
||||||
v-bind:runid="runid"
|
v-bind:runid="runid"
|
||||||
|
@ -25,7 +34,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fetchRun, fetchTask } from "@/util/data.js";
|
import { fetchRun, fetchTask, approveTask } from "@/util/data.js";
|
||||||
|
|
||||||
import Collapse from "@/components/collapse.vue";
|
import Collapse from "@/components/collapse.vue";
|
||||||
import RunDetail from "@/components/rundetail.vue";
|
import RunDetail from "@/components/rundetail.vue";
|
||||||
|
@ -64,7 +73,8 @@ export default {
|
||||||
this.fetchTask();
|
this.fetchTask();
|
||||||
this.fetchRun();
|
this.fetchRun();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
},
|
||||||
|
approveTask: approveTask
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
this.fetchRun();
|
this.fetchRun();
|
||||||
|
@ -90,4 +100,8 @@ export default {
|
||||||
padding-right: 1rem;
|
padding-right: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task-actions {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
|
@ -70,4 +70,16 @@ export async function deleteUserToken(username, tokenname) {
|
||||||
}
|
}
|
||||||
let res = await fetch(apiurl(path), init)
|
let res = await fetch(apiurl(path), init)
|
||||||
return res.text();
|
return res.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function approveTask(runid, taskid) {
|
||||||
|
let path = "/runs/" + runid + "/tasks/" + taskid + "/actions"
|
||||||
|
let init = {
|
||||||
|
method: "PUT",
|
||||||
|
body: JSON.stringify({
|
||||||
|
action_type: "approve"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let res = await fetch(apiurl(path), init)
|
||||||
|
return res.json();
|
||||||
}
|
}
|
Loading…
Reference in New Issue