debian-mirror-gitlab/app/assets/javascripts/pipelines/components/time_ago.vue

97 lines
1.8 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2018-11-08 19:23:39 +05:30
import iconTimerSvg from 'icons/_icon_timer.svg';
import '../../lib/utils/datetime_utility';
import tooltip from '../../vue_shared/directives/tooltip';
import timeagoMixin from '../../vue_shared/mixins/timeago';
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
export default {
directives: {
tooltip,
},
mixins: [timeagoMixin],
props: {
finishedTime: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
duration: {
type: Number,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
},
data() {
return {
iconTimerSvg,
};
},
computed: {
hasDuration() {
return this.duration > 0;
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
hasFinishedTime() {
return this.finishedTime !== '';
},
durationFormated() {
const date = new Date(this.duration * 1000);
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
let hh = date.getUTCHours();
let mm = date.getUTCMinutes();
let ss = date.getSeconds();
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
// left pad
if (hh < 10) {
hh = `0${hh}`;
}
if (mm < 10) {
mm = `0${mm}`;
}
if (ss < 10) {
ss = `0${ss}`;
}
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
return `${hh}:${mm}:${ss}`;
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
<div class="table-section section-15 pipelines-time-ago">
<div
class="table-mobile-header"
2018-03-17 18:26:18 +05:30
role="rowheader"
>
2017-09-10 17:25:29 +05:30
Duration
</div>
<div class="table-mobile-content">
<p
2018-03-17 18:26:18 +05:30
v-if="hasDuration"
2018-11-08 19:23:39 +05:30
class="duration"
2018-03-17 18:26:18 +05:30
>
<span v-html="iconTimerSvg">
2017-09-10 17:25:29 +05:30
</span>
2018-03-17 18:26:18 +05:30
{{ durationFormated }}
2017-09-10 17:25:29 +05:30
</p>
<p
2018-03-17 18:26:18 +05:30
v-if="hasFinishedTime"
2018-11-08 19:23:39 +05:30
class="finished-at d-none d-sm-none d-md-block"
2018-03-17 18:26:18 +05:30
>
2017-09-10 17:25:29 +05:30
<i
class="fa fa-calendar"
2018-03-17 18:26:18 +05:30
aria-hidden="true"
>
2017-09-10 17:25:29 +05:30
</i>
<time
v-tooltip
2018-11-08 19:23:39 +05:30
:title="tooltipTitle(finishedTime)"
2017-09-10 17:25:29 +05:30
data-placement="top"
2018-11-08 19:23:39 +05:30
data-container="body">
2018-03-17 18:26:18 +05:30
{{ timeFormated(finishedTime) }}
2017-09-10 17:25:29 +05:30
</time>
</p>
</div>
</div>
2018-03-17 18:26:18 +05:30
</template>