BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d11a298c
Commit
d11a298c
authored
Nov 30, 2016
by
Regis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
on focus - blur - and page closed -- intervals are taken care of for time ago and realtime
parent
649d1eb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
18 deletions
+67
-18
pipelines.js.es6
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
+9
-1
store.js.es6
app/assets/javascripts/vue_pipelines_index/store.js.es6
+27
-8
time_ago.js.es6
app/assets/javascripts/vue_pipelines_index/time_ago.js.es6
+31
-9
No files found.
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
View file @
d11a298c
...
...
@@ -24,6 +24,7 @@
data() {
return {
pipelines: [],
allTimeIntervals: [],
intervalId: '',
updatedAt: '',
pagenum: 1,
...
...
@@ -65,6 +66,9 @@
if (author) return author;
return ({});
},
addTimeInterval(id, that) {
this.allTimeIntervals.push({ id: id, component: that });
},
},
template: `
<div>
...
...
@@ -90,7 +94,11 @@
</commit>
</td>
<stages :pipeline='pipeline'></stages>
<time-ago :pipeline='pipeline'></time-ago>
<time-ago
:pipeline='pipeline'
:addTimeInterval='addTimeInterval'
>
</time-ago>
<pipeline-actions :pipeline='pipeline'></pipeline-actions>
</tr>
</tbody>
...
...
app/assets/javascripts/vue_pipelines_index/store.js.es6
View file @
d11a298c
...
...
@@ -2,7 +2,7 @@
/* eslint-disable no-param-reassign */
((gl) => {
const REALTIME =
fals
e;
const REALTIME =
tru
e;
const PAGINATION_LIMIT = 31;
const SLICE_LIMIT = 29;
...
...
@@ -33,11 +33,10 @@
const addToVueResources = () => { Vue.activeResources += 1; };
const subtractFromVueResources = () => { Vue.activeResources -= 1; };
resetVueResources();
// set Vue.resources to 0
resetVueResources();
const updatePipelineNums = (count) => {
const { all } = count;
// cannot define non camel case, so not using destructuring for running
const running = count.running_or_pending;
document.querySelector('.js-totalbuilds-count').innerHTML = all;
document.querySelector('.js-running-count').innerHTML = running;
...
...
@@ -82,7 +81,7 @@
resourceChecker();
goFetch();
if (REALTIME)
{
const poller = () =>
{
this.intervalId = setInterval(() => {
if (this.updatedAt) {
resourceChecker();
...
...
@@ -90,11 +89,31 @@
goUpdate();
}
}, 3000);
};
if (REALTIME) poller();
const removePipelineInterval = () => {
this.allTimeIntervals.forEach(e => clearInterval(e.id));
if (REALTIME) clearInterval(this.intervalId);
};
const startIntervalLoops = () => {
this.allTimeIntervals.forEach(e => e.component.startInterval());
if (REALTIME) poller();
};
window.onbeforeunload = function removePipelineInterval() {
clearInterval(this.intervalId);
};
}
window.onbeforeunload = function onClose() {
removePipelineInterval();
};
window.onblur = function remove() {
removePipelineInterval();
};
window.onfocus = function start() {
startIntervalLoops();
};
}
};
})(window.gl || (window.gl = {}));
app/assets/javascripts/vue_pipelines_index/time_ago.js.es6
View file @
d11a298c
/* global Vue, gl */
/* eslint-disable no-param-reassign */
((gl) => {
const REALTIME = false;
gl.VueTimeAgo = Vue.extend({
data() {
return {
timeInterval: '',
currentTime: new Date(),
};
},
props: [
'pipeline',
'addTimeInterval',
],
created() {
if (!REALTIME) {
this.timeInterval = setInterval(() => {
this.currentTime = new Date();
}, 1000);
this.addTimeInterval(this.timeInterval, this);
}
},
computed: {
localTimeFinished() {
return gl.utils.formatDate(this.pipeline.details.finished_at);
},
},
methods: {
timeStopped() {
const changeTime = this.currentTime;
const options = {
weekday: 'long',
year: 'numeric',
...
...
@@ -23,18 +41,22 @@
const finished = this.pipeline.details.finished_at;
if (!finished) return false;
return {
words: gl.utils.getTimeago().format(finished),
};
if (!finished && changeTime) return false;
return ({ words: gl.utils.getTimeago().format(finished) });
},
},
methods: {
duration() {
const { duration } = this.pipeline.details;
if (duration === 0) return '00:00:00';
if (duration !== null) return duration;
return false;
},
startInterval() {
this.timeInterval = setInterval(() => {
this.currentTime = new Date();
}, 1000);
},
},
template: `
<td>
...
...
@@ -51,7 +73,7 @@
</svg>
{{duration()}}
</p>
<p class="finished-at" v-if='timeStopped
()
'>
<p class="finished-at" v-if='timeStopped'>
<i class="fa fa-calendar"></i>
<time
data-toggle="tooltip"
...
...
@@ -59,7 +81,7 @@
data-container="body"
:data-original-title='localTimeFinished'
>
{{timeStopped
()
.words}}
{{timeStopped.words}}
</time>
</p>
</td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment