gitlab-org--gitlab-foss/app/assets/javascripts/pipelines/components/time_ago.vue

80 lines
1.7 KiB
Vue
Raw Normal View History

<script>
2018-06-27 10:28:05 -04:00
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';
2018-06-27 10:28:05 -04:00
export default {
directives: {
tooltip,
},
mixins: [timeagoMixin],
props: {
finishedTime: {
type: String,
required: true,
2018-01-04 19:18:35 -05:00
},
2018-06-27 10:28:05 -04:00
duration: {
type: Number,
required: true,
},
2018-06-27 10:28:05 -04:00
},
data() {
return {
iconTimerSvg,
};
},
computed: {
hasDuration() {
return this.duration > 0;
},
2018-06-27 10:28:05 -04:00
hasFinishedTime() {
return this.finishedTime !== '';
},
durationFormated() {
const date = new Date(this.duration * 1000);
2018-06-27 10:28:05 -04:00
let hh = date.getUTCHours();
let mm = date.getUTCMinutes();
let ss = date.getSeconds();
2018-06-27 10:28:05 -04:00
// left pad
if (hh < 10) {
hh = `0${hh}`;
}
if (mm < 10) {
mm = `0${mm}`;
}
if (ss < 10) {
ss = `0${ss}`;
}
2018-06-27 10:28:05 -04:00
return `${hh}:${mm}:${ss}`;
},
2018-06-27 10:28:05 -04:00
},
};
</script>
<template>
<div class="table-section section-15 pipelines-time-ago">
2018-11-16 15:07:38 -05:00
<div class="table-mobile-header" role="rowheader">{{ s__('Pipeline|Duration') }}</div>
<div class="table-mobile-content">
2018-11-16 15:07:38 -05:00
<p v-if="hasDuration" class="duration">
<span v-html="iconTimerSvg"> </span> {{ durationFormated }}
</p>
2018-11-16 15:07:38 -05:00
<p v-if="hasFinishedTime" class="finished-at d-none d-sm-none d-md-block">
<i class="fa fa-calendar" aria-hidden="true"> </i>
<time
v-tooltip
2018-06-11 05:49:47 -04:00
:title="tooltipTitle(finishedTime)"
data-placement="top"
2018-10-30 08:59:33 -04:00
data-container="body"
>
2018-01-04 19:18:35 -05:00
{{ timeFormated(finishedTime) }}
</time>
</p>
</div>
</div>
2018-01-04 19:18:35 -05:00
</template>