2016-11-09 17:45:44 -05:00
|
|
|
/* global Vue, gl */
|
|
|
|
/* eslint-disable no-param-reassign */
|
2017-01-06 15:56:53 -05:00
|
|
|
|
2017-02-05 13:17:38 -05:00
|
|
|
window.Vue = require('vue');
|
|
|
|
require('../lib/utils/datetime_utility');
|
2017-01-29 10:30:04 -05:00
|
|
|
|
2017-02-24 14:02:57 -05:00
|
|
|
const iconTimerSvg = require('../../../views/shared/icons/_icon_timer.svg');
|
|
|
|
|
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(),
|
2017-02-24 14:02:57 -05:00
|
|
|
iconTimerSvg,
|
2016-11-30 03:23:51 -05:00
|
|
|
};
|
|
|
|
},
|
2017-02-24 14:02:57 -05:00
|
|
|
props: ['pipeline'],
|
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;
|
2017-01-09 13:25:30 -05:00
|
|
|
const date = new Date(duration * 1000);
|
|
|
|
|
|
|
|
let hh = date.getUTCHours();
|
|
|
|
let mm = date.getUTCMinutes();
|
|
|
|
let ss = date.getSeconds();
|
|
|
|
|
|
|
|
if (hh < 10) hh = `0${hh}`;
|
|
|
|
if (mm < 10) mm = `0${mm}`;
|
|
|
|
if (ss < 10) ss = `0${ss}`;
|
|
|
|
|
|
|
|
if (duration !== null) return `${hh}:${mm}:${ss}`;
|
2016-11-23 11:52:21 -05:00
|
|
|
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'>
|
2017-02-24 14:02:57 -05:00
|
|
|
<span v-html="iconTimerSvg"></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 = {}));
|