2018-12-09 13:21:20 +00:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2019-05-14 12:04:36 +00:00
|
|
|
<div v-if="runs.length > 0">
|
|
|
|
|
<div class="item-list">
|
|
|
|
|
<div v-for="run in runs" v-bind:key="run.id" :class="runResultClass(run)">
|
2019-04-29 14:34:04 +00:00
|
|
|
<div class="item-content">
|
|
|
|
|
<router-link
|
2019-05-17 15:28:11 +00:00
|
|
|
v-if="projectref"
|
2019-04-29 14:34:04 +00:00
|
|
|
tag="div"
|
|
|
|
|
class="name"
|
2019-05-17 15:28:11 +00:00
|
|
|
:to="projectRunLink(ownertype, ownername, projectref, run.id)"
|
2018-12-09 13:21:20 +00:00
|
|
|
>
|
2019-04-29 14:34:04 +00:00
|
|
|
<span>{{run.name}}</span>
|
|
|
|
|
</router-link>
|
2019-05-17 15:28:11 +00:00
|
|
|
<router-link v-else tag="div" class="name" :to="userLocalRunLink(ownername, run.id)">
|
2019-04-29 14:34:04 +00:00
|
|
|
<span>{{run.name}}</span>
|
|
|
|
|
</router-link>
|
|
|
|
|
<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"></span>
|
|
|
|
|
<div class="source-info">
|
|
|
|
|
<a :href="run.annotations.commit_link" class="commit" target="_blank">
|
|
|
|
|
<i class="mdi mdi-source-commit mdi-rotate-90"></i>
|
|
|
|
|
<span>{{run.annotations.commit_sha.substring(0,8)}}</span>
|
|
|
|
|
</a>
|
|
|
|
|
<a
|
|
|
|
|
v-if="run.annotations.event_type == 'push'"
|
|
|
|
|
:href="run.annotations.branch_link"
|
|
|
|
|
class="commit"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<i class="mdi mdi-source-branch"></i>
|
|
|
|
|
<span>{{run.annotations.branch}}</span>
|
|
|
|
|
</a>
|
|
|
|
|
<a
|
|
|
|
|
v-else-if="run.annotations.event_type == 'tag'"
|
|
|
|
|
:href="run.annotations.tag_link"
|
|
|
|
|
class="commit"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<i class="mdi mdi-tag"></i>
|
|
|
|
|
<span>{{run.annotations.tag}}</span>
|
|
|
|
|
</a>
|
|
|
|
|
<a
|
|
|
|
|
v-else-if="run.annotations.event_type == 'pull_request'"
|
|
|
|
|
:href="run.annotations.pull_request_link"
|
|
|
|
|
class="commit"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<i class="mdi mdi-source-pull"></i>
|
|
|
|
|
<span>PR #{{run.annotations.pull_request_id}}</span>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
2018-12-09 13:21:20 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-05-14 12:04:36 +00:00
|
|
|
<div class="has-text-centered">
|
|
|
|
|
<button
|
|
|
|
|
v-if="hasMoreRuns"
|
|
|
|
|
class="button is-primary is-outlined is-fullwidth load-more-button"
|
|
|
|
|
@click="loadMoreRuns()"
|
|
|
|
|
>Load more...</button>
|
|
|
|
|
</div>
|
2018-12-09 13:21:20 +00:00
|
|
|
</div>
|
2019-05-14 12:04:36 +00:00
|
|
|
<div v-else class="item-list">No runs</div>
|
2018-12-09 13:21:20 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-05-13 14:29:47 +00:00
|
|
|
import { fetchUser, fetchProject, fetchRuns } from "@/util/data.js";
|
2018-12-09 13:21:20 +00:00
|
|
|
import { userLocalRunLink, projectRunLink } from "@/util/link.js";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {},
|
|
|
|
|
name: "runs",
|
|
|
|
|
props: {
|
|
|
|
|
ownertype: String,
|
|
|
|
|
ownername: String,
|
2019-04-02 16:08:03 +00:00
|
|
|
projectref: Array,
|
2019-03-27 14:41:29 +00:00
|
|
|
query: String
|
2018-12-09 13:21:20 +00:00
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
runs: [],
|
2019-05-14 12:04:36 +00:00
|
|
|
wantedRunsNumber: 25,
|
|
|
|
|
hasMoreRuns: false,
|
2018-12-09 13:21:20 +00:00
|
|
|
polling: null,
|
|
|
|
|
project: null,
|
|
|
|
|
user: null
|
|
|
|
|
};
|
|
|
|
|
},
|
2019-03-27 14:41:29 +00:00
|
|
|
watch: {
|
2019-04-02 16:08:03 +00:00
|
|
|
$route: function() {
|
2019-03-27 14:41:29 +00:00
|
|
|
this.update();
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-12-09 13:21:20 +00:00
|
|
|
methods: {
|
|
|
|
|
projectRunLink: projectRunLink,
|
|
|
|
|
userLocalRunLink: userLocalRunLink,
|
|
|
|
|
stillRunning(run) {
|
|
|
|
|
return run.result != "unknown" && run.phase == "running";
|
|
|
|
|
},
|
2019-04-08 15:43:34 +00:00
|
|
|
waitingApproval(run) {
|
|
|
|
|
return run.tasks_waiting_approval.length > 0;
|
|
|
|
|
},
|
2018-12-09 13:21:20 +00:00
|
|
|
runResultClass(run) {
|
|
|
|
|
if (run.result == "unknown") {
|
2019-04-10 09:21:18 +00:00
|
|
|
if (run.phase == "setuperror") return "setuperror";
|
2018-12-09 13:21:20 +00:00
|
|
|
if (run.phase == "queued") return "unknown";
|
|
|
|
|
if (run.phase == "cancelled") return "failed";
|
|
|
|
|
if (run.phase == "running") return "running";
|
|
|
|
|
}
|
|
|
|
|
if (run.result == "success") return "success";
|
|
|
|
|
if (run.result == "failed") return "failed";
|
|
|
|
|
if (run.result == "stopped") return "failed";
|
|
|
|
|
return "unknown";
|
|
|
|
|
},
|
2019-03-27 14:41:29 +00:00
|
|
|
update() {
|
|
|
|
|
clearInterval(this.polling);
|
2019-04-02 16:08:03 +00:00
|
|
|
if (this.projectref !== undefined) {
|
2019-03-27 14:41:29 +00:00
|
|
|
this.fetchProject();
|
|
|
|
|
} else {
|
2019-05-17 15:28:11 +00:00
|
|
|
this.fetchUser();
|
2019-03-27 14:41:29 +00:00
|
|
|
}
|
|
|
|
|
this.pollData();
|
|
|
|
|
},
|
2019-03-29 17:19:07 +00:00
|
|
|
async fetchProject() {
|
2019-05-13 14:29:47 +00:00
|
|
|
let projectref = [
|
|
|
|
|
this.ownertype,
|
|
|
|
|
this.ownername,
|
|
|
|
|
...this.projectref
|
|
|
|
|
].join("/");
|
|
|
|
|
|
|
|
|
|
let { data, error } = await fetchProject(projectref);
|
|
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.project = data;
|
2018-12-09 13:21:20 +00:00
|
|
|
|
2019-03-29 17:19:07 +00:00
|
|
|
this.fetchRuns();
|
2018-12-09 13:21:20 +00:00
|
|
|
},
|
2019-03-29 17:19:07 +00:00
|
|
|
async fetchUser() {
|
2019-05-17 15:28:11 +00:00
|
|
|
let { data, error } = await fetchUser(this.ownername);
|
2019-05-13 14:29:47 +00:00
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.user = data;
|
2018-12-09 13:21:20 +00:00
|
|
|
|
2019-03-29 17:19:07 +00:00
|
|
|
this.fetchRuns();
|
2018-12-09 13:21:20 +00:00
|
|
|
},
|
2019-05-14 12:04:36 +00:00
|
|
|
loadMoreRuns() {
|
|
|
|
|
this.wantedRunsNumber += 25;
|
|
|
|
|
this.fetchRuns();
|
|
|
|
|
},
|
|
|
|
|
// TODO(sgotti) use run events instead of refetching all runs everytime
|
2019-03-27 14:41:29 +00:00
|
|
|
async fetchRuns() {
|
|
|
|
|
let group;
|
|
|
|
|
let lastrun = false;
|
2018-12-09 13:21:20 +00:00
|
|
|
if (this.project !== null) {
|
2019-03-27 14:41:29 +00:00
|
|
|
if (this.query == "branches") {
|
2019-03-29 08:28:31 +00:00
|
|
|
group = "/project/" + this.project.id + "/branch";
|
2019-03-27 14:41:29 +00:00
|
|
|
lastrun = true;
|
|
|
|
|
} else if (this.query == "tags") {
|
2019-03-29 08:28:31 +00:00
|
|
|
group = "/project/" + this.project.id + "/tag";
|
2019-03-27 14:41:29 +00:00
|
|
|
lastrun = true;
|
|
|
|
|
} else if (this.query == "pullrequests") {
|
2019-03-29 08:28:31 +00:00
|
|
|
group = "/project/" + this.project.id + "/pr";
|
2019-03-27 14:41:29 +00:00
|
|
|
lastrun = true;
|
|
|
|
|
} else {
|
2019-03-29 08:28:31 +00:00
|
|
|
group = "/project/" + this.project.id;
|
2019-03-27 14:41:29 +00:00
|
|
|
}
|
2018-12-09 13:21:20 +00:00
|
|
|
} else if (this.user !== null) {
|
2019-03-29 08:28:31 +00:00
|
|
|
group = "/user/" + this.user.id;
|
2018-12-09 13:21:20 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-14 12:04:36 +00:00
|
|
|
let newRuns = [];
|
|
|
|
|
let hasMoreRuns = false;
|
|
|
|
|
let stopFetch = false;
|
|
|
|
|
let runCount = 0;
|
|
|
|
|
let startRunID = null;
|
|
|
|
|
while (!stopFetch) {
|
|
|
|
|
let { data, error } = await fetchRuns(group, startRunID, lastrun);
|
|
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
runCount += data.length;
|
|
|
|
|
if (runCount >= this.wantedRunsNumber || data.length == 0) {
|
|
|
|
|
hasMoreRuns = data.length != 0;
|
|
|
|
|
stopFetch = true;
|
|
|
|
|
}
|
|
|
|
|
newRuns = newRuns.concat(data);
|
|
|
|
|
if (newRuns.length) {
|
|
|
|
|
startRunID = newRuns[newRuns.length - 1].id;
|
|
|
|
|
}
|
2019-05-13 14:29:47 +00:00
|
|
|
}
|
2019-05-14 12:04:36 +00:00
|
|
|
this.runs = newRuns;
|
|
|
|
|
this.hasMoreRuns = hasMoreRuns;
|
2018-12-09 13:21:20 +00:00
|
|
|
},
|
|
|
|
|
pollData() {
|
2019-03-27 14:41:29 +00:00
|
|
|
clearInterval(this.polling);
|
2018-12-09 13:21:20 +00:00
|
|
|
this.polling = setInterval(() => {
|
|
|
|
|
this.fetchRuns();
|
|
|
|
|
}, 2000);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created: function() {
|
2019-03-27 14:41:29 +00:00
|
|
|
this.update();
|
2018-12-09 13:21:20 +00:00
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
clearInterval(this.polling);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
@import "@/css/_variables.scss";
|
|
|
|
|
|
|
|
|
|
.project-title {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding-left: 5px;
|
|
|
|
|
margin-bottom: 25px;
|
|
|
|
|
.project-name {
|
|
|
|
|
padding-left: 5px;
|
|
|
|
|
font-size: 1.5rem;
|
|
|
|
|
padding-right: 1rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-list {
|
|
|
|
|
.item-content {
|
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
border: 1px solid $grey-lighter;
|
|
|
|
|
border-left: 0 solid;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.success {
|
|
|
|
|
border-left: 5px solid $green;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.failed {
|
|
|
|
|
border-left: 5px solid $red;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.running {
|
|
|
|
|
border-left: 5px solid $blue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.unknown {
|
|
|
|
|
border-left: 5px solid $grey-lighter;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 09:21:18 +00:00
|
|
|
.setuperror {
|
|
|
|
|
border-left: 5px solid $yellow;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-09 13:21:20 +00:00
|
|
|
.name {
|
|
|
|
|
flex: 0 0 30%;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.commitmessage {
|
|
|
|
|
flex: 0 0 40%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stillrunning {
|
|
|
|
|
flex: 0 0 10%;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-08 15:43:34 +00:00
|
|
|
.waitingapproval {
|
|
|
|
|
flex: 0 0 10%;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-09 13:21:20 +00:00
|
|
|
.source-info {
|
|
|
|
|
flex: 0 0 10%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.commit {
|
|
|
|
|
display: block;
|
|
|
|
|
font-size: 0.8rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-14 12:04:36 +00:00
|
|
|
|
|
|
|
|
.load-more-button {
|
|
|
|
|
margin-top: 1rem;
|
|
|
|
|
margin-bottom: 2rem;
|
|
|
|
|
}
|
2018-12-09 13:21:20 +00:00
|
|
|
</style>
|