gitlab-org--gitlab-foss/app/assets/javascripts/vue_pipelines_index/time_ago.js.es6

65 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-11-09 17:45:44 -05:00
/* global Vue, gl */
/* eslint-disable no-param-reassign */
2016-11-09 17:45:44 -05:00
((gl) => {
gl.VueTimeAgo = Vue.extend({
data() {
return {
currentTime: new Date(),
};
},
2016-12-16 18:12:52 -05:00
props: ['pipeline', 'svgs'],
computed: {
2016-12-15 11:40:40 -05:00
timeAgo() {
return gl.utils.getTimeago();
},
localTimeFinished() {
return gl.utils.formatDate(this.pipeline.details.finished_at);
},
2016-11-09 17:45:44 -05:00
timeStopped() {
const changeTime = this.currentTime;
2016-11-09 17:45:44 -05:00
const options = {
weekday: 'long',
year: 'numeric',
month: 'short',
day: 'numeric',
};
options.timeZoneName = 'short';
const finished = this.pipeline.details.finished_at;
if (!finished && changeTime) return false;
2016-12-15 11:40:40 -05:00
return ({ words: this.timeAgo.format(finished) });
2016-11-09 17:45:44 -05:00
},
duration() {
const { duration } = this.pipeline.details;
if (duration === 0) return '00:00:00';
if (duration !== null) return duration;
return false;
2016-11-09 17:45:44 -05:00
},
},
methods: {
changeTime() {
this.currentTime = new Date();
},
2016-11-09 17:45:44 -05:00
},
template: `
<td>
<p class="duration" v-if='duration'>
2016-12-16 18:12:52 -05:00
<span v-html='svgs.iconTimer'></span>
{{duration}}
2016-11-09 17:45:44 -05:00
</p>
<p class="finished-at" v-if='timeStopped'>
2016-11-09 17:45:44 -05:00
<i class="fa fa-calendar"></i>
<time
data-toggle="tooltip"
data-placement="top"
data-container="body"
:data-original-title='localTimeFinished'
2016-11-09 17:45:44 -05:00
>
{{timeStopped.words}}
2016-11-09 17:45:44 -05:00
</time>
</p>
</td>
`,
});
})(window.gl || (window.gl = {}));