From 42f7ce7eaa3c8d22cf2f3e5343929464f79b9a24 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 9 Jul 2019 11:22:45 +0200 Subject: [PATCH] rundetail: rework item presentation * Add duration and finish time * Move type (branch/tag/PR) to the left --- src/components/rundetail.vue | 133 ++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 41 deletions(-) diff --git a/src/components/rundetail.vue b/src/components/rundetail.vue index 4f45c42..f45e3e1 100644 --- a/src/components/rundetail.vue +++ b/src/components/rundetail.vue @@ -24,10 +24,10 @@
-
-
-
- {{run.name}} + @@ -134,6 +144,11 @@ import { cancelRun, stopRun, restartRun } from "@/util/data.js"; import { userDirectRunLink, projectRunLink } from "@/util/link.js"; import { runStatus, runResultClass } from "@/util/run.js"; +import * as moment from "moment"; +import momentDurationFormatSetup from "moment-duration-format"; + +momentDurationFormatSetup(moment); + export default { name: "rundetail", directives: { @@ -147,6 +162,7 @@ export default { }, data() { return { + now: moment(), stopRunError: null, cancelRunError: null, restartRunError: null, @@ -213,7 +229,42 @@ export default { runLink = userDirectRunLink(this.ownername, data.id); } this.$router.push(runLink); + }, + duration(run) { + let formatString = "h:mm:ss[s]"; + let start = moment(run.start_time); + let end = moment(run.end_time); + + if (run.start_time === null) { + return moment.duration(0).format(formatString); + } + if (run.end_time === null) { + return moment.duration(this.now.diff(start)).format(formatString); + } + return moment.duration(end.diff(start)).format(formatString); + }, + endTime(run) { + let formatString = "lll"; + let end = moment(run.end_time); + + if (run.end_time === null) { + return ""; + } + return "Finished " + end.format(formatString); + }, + endTimeHuman(run) { + let end = moment(run.end_time); + + if (run.end_time === null) { + return ""; + } + return end.fromNow(); } + }, + created: function() { + window.setInterval(() => { + this.now = moment(); + }, 500); } };