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 @@
...
@@ -24,6 +24,7 @@
data() {
data() {
return {
return {
pipelines: [],
pipelines: [],
allTimeIntervals: [],
intervalId: '',
intervalId: '',
updatedAt: '',
updatedAt: '',
pagenum: 1,
pagenum: 1,
...
@@ -65,6 +66,9 @@
...
@@ -65,6 +66,9 @@
if (author) return author;
if (author) return author;
return ({});
return ({});
},
},
addTimeInterval(id, that) {
this.allTimeIntervals.push({ id: id, component: that });
},
},
},
template: `
template: `
<div>
<div>
...
@@ -90,7 +94,11 @@
...
@@ -90,7 +94,11 @@
</commit>
</commit>
</td>
</td>
<stages :pipeline='pipeline'></stages>
<stages :pipeline='pipeline'></stages>
<time-ago :pipeline='pipeline'></time-ago>
<time-ago
:pipeline='pipeline'
:addTimeInterval='addTimeInterval'
>
</time-ago>
<pipeline-actions :pipeline='pipeline'></pipeline-actions>
<pipeline-actions :pipeline='pipeline'></pipeline-actions>
</tr>
</tr>
</tbody>
</tbody>
...
...
app/assets/javascripts/vue_pipelines_index/store.js.es6
View file @
d11a298c
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign */
((gl) => {
((gl) => {
const REALTIME =
fals
e;
const REALTIME =
tru
e;
const PAGINATION_LIMIT = 31;
const PAGINATION_LIMIT = 31;
const SLICE_LIMIT = 29;
const SLICE_LIMIT = 29;
...
@@ -33,11 +33,10 @@
...
@@ -33,11 +33,10 @@
const addToVueResources = () => { Vue.activeResources += 1; };
const addToVueResources = () => { Vue.activeResources += 1; };
const subtractFromVueResources = () => { Vue.activeResources -= 1; };
const subtractFromVueResources = () => { Vue.activeResources -= 1; };
resetVueResources();
// set Vue.resources to 0
resetVueResources();
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;
...
@@ -82,7 +81,7 @@
...
@@ -82,7 +81,7 @@
resourceChecker();
resourceChecker();
goFetch();
goFetch();
if (REALTIME)
{
const poller = () =>
{
this.intervalId = setInterval(() => {
this.intervalId = setInterval(() => {
if (this.updatedAt) {
if (this.updatedAt) {
resourceChecker();
resourceChecker();
...
@@ -90,11 +89,31 @@
...
@@ -90,11 +89,31 @@
goUpdate();
goUpdate();
}
}
}, 3000);
}, 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() {
window.onbeforeunload = function onClose() {
clearInterval(this.intervalId);
removePipelineInterval();
};
};
}
window.onblur = function remove() {
removePipelineInterval();
};
window.onfocus = function start() {
startIntervalLoops();
};
}
}
};
};
})(window.gl || (window.gl = {}));
})(window.gl || (window.gl = {}));
app/assets/javascripts/vue_pipelines_index/time_ago.js.es6
View file @
d11a298c
/* global Vue, gl */
/* global Vue, gl */
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign */
((gl) => {
((gl) => {
const REALTIME = false;
gl.VueTimeAgo = Vue.extend({
gl.VueTimeAgo = Vue.extend({
data() {
return {
timeInterval: '',
currentTime: new Date(),
};
},
props: [
props: [
'pipeline',
'pipeline',
'addTimeInterval',
],
],
created() {
if (!REALTIME) {
this.timeInterval = setInterval(() => {
this.currentTime = new Date();
}, 1000);
this.addTimeInterval(this.timeInterval, this);
}
},
computed: {
computed: {
localTimeFinished() {
localTimeFinished() {
return gl.utils.formatDate(this.pipeline.details.finished_at);
return gl.utils.formatDate(this.pipeline.details.finished_at);
},
},
},
methods: {
timeStopped() {
timeStopped() {
const changeTime = this.currentTime;
const options = {
const options = {
weekday: 'long',
weekday: 'long',
year: 'numeric',
year: 'numeric',
...
@@ -23,18 +41,22 @@
...
@@ -23,18 +41,22 @@
const finished = this.pipeline.details.finished_at;
const finished = this.pipeline.details.finished_at;
if (!finished) return false;
if (!finished && changeTime) return false;
return ({ words: gl.utils.getTimeago().format(finished) });
return {
words: gl.utils.getTimeago().format(finished),
};
},
},
},
methods: {
duration() {
duration() {
const { duration } = this.pipeline.details;
const { duration } = this.pipeline.details;
if (duration === 0) return '00:00:00';
if (duration === 0) return '00:00:00';
if (duration !== null) return duration;
if (duration !== null) return duration;
return false;
return false;
},
},
startInterval() {
this.timeInterval = setInterval(() => {
this.currentTime = new Date();
}, 1000);
},
},
},
template: `
template: `
<td>
<td>
...
@@ -51,7 +73,7 @@
...
@@ -51,7 +73,7 @@
</svg>
</svg>
{{duration()}}
{{duration()}}
</p>
</p>
<p class="finished-at" v-if='timeStopped
()
'>
<p class="finished-at" v-if='timeStopped'>
<i class="fa fa-calendar"></i>
<i class="fa fa-calendar"></i>
<time
<time
data-toggle="tooltip"
data-toggle="tooltip"
...
@@ -59,7 +81,7 @@
...
@@ -59,7 +81,7 @@
data-container="body"
data-container="body"
:data-original-title='localTimeFinished'
:data-original-title='localTimeFinished'
>
>
{{timeStopped
()
.words}}
{{timeStopped.words}}
</time>
</time>
</p>
</p>
</td>
</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