Commit 520e27d1 authored by Regis's avatar Regis

add vue_realtime_listener function

parent 7be5c231
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
}, },
detailsPath() { detailsPath() {
const { status } = this.pipeline.details; const { status } = this.pipeline.details;
return status.path ? status.path : '#'; return status.details_path ? status.details_path : '#';
}, },
}, },
template: ` template: `
......
/* global gl, Flash */ /* global gl, Flash */
/* eslint-disable no-param-reassign, no-underscore-dangle */ /* eslint-disable no-param-reassign, no-underscore-dangle */
/*= require vue_realtime_listener/index.js */
((gl) => { ((gl) => {
const pageValues = headers => ({ const pageValues = headers => ({
perPage: +headers['X-Per-Page'], perPage: +headers['X-Per-Page'],
...@@ -49,21 +51,10 @@ ...@@ -49,21 +51,10 @@
startTimeLoops(); startTimeLoops();
const removeTimeIntervals = () => clearInterval(this.timeLoopInterval); const removeIntervals = () => clearInterval(this.timeLoopInterval);
const startIntervalLoops = () => startTimeLoops(); const startIntervals = () => startTimeLoops();
const removeAll = () => {
removeTimeIntervals();
window.removeEventListener('beforeunload', removeTimeIntervals);
window.removeEventListener('focus', startIntervalLoops);
window.removeEventListener('blur', removeTimeIntervals);
document.removeEventListener('page:fetch', removeAll);
};
window.addEventListener('beforeunload', removeTimeIntervals); gl.VueRealtimeListener(removeIntervals, startIntervals);
window.addEventListener('focus', startIntervalLoops);
window.addEventListener('blur', removeTimeIntervals);
document.addEventListener('page:fetch', removeAll);
} }
}; };
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));
(() => {
gl.VueRealtimeListener = (removeIntervals, startIntervals) => {
const removeAll = () => {
removeIntervals();
window.removeEventListener('beforeunload', removeIntervals);
window.removeEventListener('focus', startIntervals);
window.removeEventListener('blur', removeIntervals);
document.removeEventListener('page:fetch', removeAll);
};
window.addEventListener('beforeunload', removeIntervals);
window.addEventListener('focus', startIntervals);
window.addEventListener('blur', removeIntervals);
document.addEventListener('page:fetch', removeAll);
};
})(window.gl || (window.gl = {}));
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