2018-12-09 13:21:20 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="item-list">
|
|
|
|
<div class="item" v-for="run in runs" v-bind:key="run.id" :class="runResultClass(run)">
|
|
|
|
<div class="item-content">
|
|
|
|
<router-link
|
|
|
|
v-if="username"
|
|
|
|
tag="div"
|
|
|
|
class="name"
|
|
|
|
:to="userLocalRunLink(username, run.id)"
|
|
|
|
>
|
|
|
|
<span>{{run.name}}</span>
|
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
v-else
|
|
|
|
tag="div"
|
|
|
|
class="name"
|
|
|
|
:to="projectRunLink(ownertype, ownername, projectname, run.id)"
|
|
|
|
>
|
|
|
|
<span>{{run.name}}</span>
|
|
|
|
</router-link>
|
|
|
|
<div class="commitmessage">{{run.annotations.message}}</div>
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { apiurl, fetch } from "@/util/auth";
|
2019-03-27 14:41:29 +00:00
|
|
|
import { 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,
|
|
|
|
username: String,
|
2019-03-27 14:41:29 +00:00
|
|
|
projectname: String,
|
|
|
|
query: String
|
2018-12-09 13:21:20 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
runs: [],
|
|
|
|
polling: null,
|
|
|
|
project: null,
|
|
|
|
user: null
|
|
|
|
};
|
|
|
|
},
|
2019-03-27 14:41:29 +00:00
|
|
|
watch: {
|
|
|
|
$route: function(route) {
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
},
|
2018-12-09 13:21:20 +00:00
|
|
|
methods: {
|
|
|
|
projectRunLink: projectRunLink,
|
|
|
|
userLocalRunLink: userLocalRunLink,
|
|
|
|
stillRunning(run) {
|
|
|
|
return run.result != "unknown" && run.phase == "running";
|
|
|
|
},
|
|
|
|
runResultClass(run) {
|
|
|
|
if (run.result == "unknown") {
|
|
|
|
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);
|
|
|
|
console.log("username", this.username);
|
|
|
|
console.log("projectname", this.projectname);
|
|
|
|
if (this.projectname !== undefined) {
|
|
|
|
this.fetchProject();
|
|
|
|
} else if (this.username !== undefined) {
|
|
|
|
this.fetchUser();
|
|
|
|
} else {
|
|
|
|
this.fetchRuns();
|
|
|
|
}
|
|
|
|
this.pollData();
|
|
|
|
},
|
|
|
|
fetchProject() {
|
2019-03-20 12:51:00 +00:00
|
|
|
let path =
|
|
|
|
"/projects/" +
|
|
|
|
encodeURIComponent(
|
|
|
|
this.ownertype + "/" + this.ownername + "/" + this.projectname
|
|
|
|
);
|
|
|
|
fetch(apiurl(path))
|
2018-12-09 13:21:20 +00:00
|
|
|
.then(res => res.json())
|
|
|
|
.then(res => {
|
|
|
|
console.log(res);
|
|
|
|
this.project = res;
|
|
|
|
console.log("project", this.project);
|
|
|
|
|
|
|
|
this.fetchRuns();
|
|
|
|
});
|
|
|
|
},
|
2019-03-27 14:41:29 +00:00
|
|
|
fetchUser() {
|
2018-12-09 13:21:20 +00:00
|
|
|
fetch(apiurl("/users/" + this.username))
|
|
|
|
.then(res => res.json())
|
|
|
|
.then(res => {
|
|
|
|
console.log(res);
|
|
|
|
this.user = res;
|
|
|
|
console.log("user", this.user);
|
|
|
|
|
|
|
|
this.fetchRuns();
|
|
|
|
});
|
|
|
|
},
|
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-03-27 14:41:29 +00:00
|
|
|
this.runs = await fetchRuns(group, lastrun);
|
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 {
|
|
|
|
}
|
|
|
|
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
|
|
|
flex: 0 0 30%;
|
|
|
|
font-weight: bold;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.commitmessage {
|
|
|
|
flex: 0 0 40%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.stillrunning {
|
|
|
|
flex: 0 0 10%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.source-info {
|
|
|
|
flex: 0 0 10%;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
a {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.commit {
|
|
|
|
display: block;
|
|
|
|
font-size: 0.8rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|