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

98 lines
1.9 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">
2019-01-03 12:48:30 +05:30
<div
class="table-mobile-header"
role="rowheader"
>
{{ s__('Pipeline|Duration') }}
</div>
2017-09-10 17:25:29 +05:30
<div class="table-mobile-content">
2019-01-03 12:48:30 +05:30
<p
v-if="hasDuration"
class="duration"
>
<span v-html="iconTimerSvg">
</span>
{{ durationFormated }}
2017-09-10 17:25:29 +05:30
</p>
2019-01-03 12:48:30 +05:30
<p
v-if="hasFinishedTime"
class="finished-at d-none d-sm-none d-md-block"
>
<i
class="fa fa-calendar"
aria-hidden="true"
>
</i>
2017-09-10 17:25:29 +05:30
<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-12-13 13:39:08 +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>