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

99 lines
1.9 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
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';
export default {
2018-03-17 18:26:18 +05:30
directives: {
tooltip,
},
mixins: [
timeagoMixin,
],
2017-09-10 17:25:29 +05:30
props: {
finishedTime: {
type: String,
required: true,
},
duration: {
type: Number,
required: true,
},
},
data() {
return {
iconTimerSvg,
};
},
computed: {
hasDuration() {
return this.duration > 0;
},
hasFinishedTime() {
return this.finishedTime !== '';
},
durationFormated() {
const date = new Date(this.duration * 1000);
let hh = date.getUTCHours();
let mm = date.getUTCMinutes();
let ss = date.getSeconds();
// left pad
if (hh < 10) {
hh = `0${hh}`;
}
if (mm < 10) {
mm = `0${mm}`;
}
if (ss < 10) {
ss = `0${ss}`;
}
return `${hh}:${mm}:${ss}`;
},
},
};
</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
class="duration"
2018-03-17 18:26:18 +05:30
v-if="hasDuration"
>
<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
class="finished-at hidden-xs hidden-sm"
2018-03-17 18:26:18 +05:30
v-if="hasFinishedTime"
>
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
data-placement="top"
data-container="body"
:title="tooltipTitle(finishedTime)">
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>