2016-11-09 17:45:44 -05:00
|
|
|
/* global Vue, gl */
|
|
|
|
/* eslint-disable no-param-reassign */
|
2017-01-06 15:56:53 -05:00
|
|
|
|
2016-11-09 17:45:44 -05:00
|
|
|
((gl) => {
|
|
|
|
gl.VueTimeAgo = Vue.extend({
|
2016-11-30 03:23:51 -05:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
currentTime: new Date(),
|
|
|
|
};
|
|
|
|
},
|
2016-12-16 18:12:52 -05:00
|
|
|
props: ['pipeline', 'svgs'],
|
2016-11-23 11:52:21 -05:00
|
|
|
computed: {
|
2016-12-15 11:40:40 -05:00
|
|
|
timeAgo() {
|
|
|
|
return gl.utils.getTimeago();
|
|
|
|
},
|
2016-11-23 11:52:21 -05:00
|
|
|
localTimeFinished() {
|
|
|
|
return gl.utils.formatDate(this.pipeline.details.finished_at);
|
|
|
|
},
|
2016-11-09 17:45:44 -05:00
|
|
|
timeStopped() {
|
2016-11-30 03:23:51 -05:00
|
|
|
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';
|
2016-11-10 14:22:16 -05:00
|
|
|
const finished = this.pipeline.details.finished_at;
|
2016-11-30 03:23:51 -05:00
|
|
|
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() {
|
2016-11-23 11:52:21 -05:00
|
|
|
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
|
|
|
},
|
2017-01-07 20:13:00 -05:00
|
|
|
},
|
|
|
|
methods: {
|
2016-12-02 17:05:01 -05:00
|
|
|
changeTime() {
|
|
|
|
this.currentTime = new Date();
|
2016-11-30 03:23:51 -05:00
|
|
|
},
|
2016-11-09 17:45:44 -05:00
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<td>
|
2017-01-07 20:13:00 -05:00
|
|
|
<p class="duration" v-if='duration'>
|
2016-12-16 18:12:52 -05:00
|
|
|
<span v-html='svgs.iconTimer'></span>
|
2017-01-07 20:13:00 -05:00
|
|
|
{{duration}}
|
2016-11-09 17:45:44 -05:00
|
|
|
</p>
|
2016-11-30 03:23:51 -05:00
|
|
|
<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"
|
2016-11-23 11:52:21 -05:00
|
|
|
:data-original-title='localTimeFinished'
|
2016-11-09 17:45:44 -05:00
|
|
|
>
|
2016-11-30 03:23:51 -05:00
|
|
|
{{timeStopped.words}}
|
2016-11-09 17:45:44 -05:00
|
|
|
</time>
|
|
|
|
</p>
|
|
|
|
</td>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
})(window.gl || (window.gl = {}));
|