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); } };