BigW Consortium Gitlab

Commit ce2750e0 by Regis

refactor - rename - simple behavior for time_ago

parent d15a0b68
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<status-scope :pipeline='pipeline'></status-scope> <status-scope :pipeline='pipeline'></status-scope>
<pipeline-url :pipeline='pipeline'></pipeline-url> <pipeline-url :pipeline='pipeline'></pipeline-url>
<commit <commit
:tag='pipeline.ref.tag' :tag="pipeline.ref['tag?']"
:author='pipeline.commit.author' :author='pipeline.commit.author'
:title='pipeline.commit.title' :title='pipeline.commit.title'
:ref='pipeline.ref' :ref='pipeline.ref'
......
...@@ -5,23 +5,23 @@ ...@@ -5,23 +5,23 @@
const PAGINATION_LIMIT = 31; const PAGINATION_LIMIT = 31;
const SLICE_LIMIT = 29; const SLICE_LIMIT = 29;
class PipelineUpdater { class RealtimePaginationUpdater {
constructor(pipelines) { constructor(pageData) {
this.pipelines = pipelines; this.pageData = pageData;
} }
updatePipelines(apiResponse) { updatePageDiff(apiResponse) {
const update = this.pipelines.slice(0); const diffData = this.pageData.slice(0);
apiResponse.pipelines.forEach((newPipe, i) => { apiResponse.pipelines.forEach((newPipe, i) => {
if (newPipe.commit) { if (newPipe.commit) {
update.unshift(newPipe); diffData.unshift(newPipe);
} else { } else {
const newMerge = Object.assign({}, update[i], newPipe); const newMerge = Object.assign({}, diffData[i], newPipe);
update[i] = newMerge; diffData[i] = newMerge;
} }
}); });
if (update.length < PAGINATION_LIMIT) return update; if (diffData.length < PAGINATION_LIMIT) return diffData;
return update.slice(0, SLICE_LIMIT); return diffData.slice(0, SLICE_LIMIT);
} }
} }
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
const updatePipelineNums = (count) => { const updatePipelineNums = (count) => {
const { all } = count; const { all } = count;
// cannot define non camel case, so not using destructuring for running
const running = count.running_or_pending; const running = count.running_or_pending;
document.querySelector('.js-totalbuilds-count').innerHTML = all; document.querySelector('.js-totalbuilds-count').innerHTML = all;
document.querySelector('.js-running-count').innerHTML = running; document.querySelector('.js-running-count').innerHTML = running;
...@@ -67,9 +68,9 @@ ...@@ -67,9 +68,9 @@
this.$http.get(`${url}?page=${pageNum}&updated_at=${this.updatedAt}`) this.$http.get(`${url}?page=${pageNum}&updated_at=${this.updatedAt}`)
.then((response) => { .then((response) => {
const res = JSON.parse(response.body); const res = JSON.parse(response.body);
const p = new PipelineUpdater(this.pipelines); const p = new RealtimePaginationUpdater(this.pipelines);
Vue.set(this, 'updatedAt', res.updated_at); Vue.set(this, 'updatedAt', res.updated_at);
Vue.set(this, 'pipelines', p.updatePipelines(res)); Vue.set(this, 'pipelines', p.updatePageDiff(res));
Vue.set(this, 'count', res.count); Vue.set(this, 'count', res.count);
updatePipelineNums(this.count); updatePipelineNums(this.count);
subtractFromVueResources(); subtractFromVueResources();
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
props: [ props: [
'pipeline', 'pipeline',
], ],
computed: {
localTimeFinished() {
return gl.utils.formatDate(this.pipeline.details.finished_at);
},
},
methods: { methods: {
formatSection(section) { formatSection(section) {
if (`${section}`.split('').length <= 1) return `0${section}`; if (`${section}`.split('').length <= 1) return `0${section}`;
...@@ -58,13 +63,17 @@ ...@@ -58,13 +63,17 @@
}; };
}, },
duration() { duration() {
if (this.timeStopped()) return this.finishdate(); // if (this.timeStopped()) return this.finishdate();
return this.runningdate(); // return this.runningdate();
const { duration } = this.pipeline.details;
if (duration === 0) return '00:00:00';
if (duration !== null) return duration;
return false;
}, },
}, },
template: ` template: `
<td> <td>
<p class="duration"> <p class="duration" v-if='duration()'>
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="40" width="40"
...@@ -83,7 +92,7 @@ ...@@ -83,7 +92,7 @@
data-toggle="tooltip" data-toggle="tooltip"
data-placement="top" data-placement="top"
data-container="body" data-container="body"
:data-original-title='9 + 9' :data-original-title='localTimeFinished'
> >
{{timeStopped().words}} {{timeStopped().words}}
</time> </time>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment