gitlab-org--gitlab-foss/app/assets/javascripts/vue_pipelines_index/pipelines.js.es6

89 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-10-26 14:43:58 -04:00
/* global Vue, gl */
/* eslint-disable no-param-reassign, no-bitwise*/
2016-10-26 14:43:58 -04:00
((gl) => {
gl.VuePipeLines = Vue.extend({
components: {
2016-11-11 00:21:09 -05:00
runningPipeline: gl.VueRunningPipeline,
pipelineActions: gl.VuePipelineActions,
stages: gl.VueStages,
branchCommit: gl.VueBranchCommit,
pipelineUrl: gl.VuePipelineUrl,
pipelineHead: gl.VuePipelineHead,
glPagination: gl.VueGlPagination,
statusScope: gl.VueStatusScope,
timeAgo: gl.VueTimeAgo,
},
2016-10-29 15:50:08 -04:00
data() {
return {
pipelines: [],
intervalId: '',
2016-11-10 15:17:33 -05:00
updatedAt: '',
pagenum: 1,
count: {
all: 0,
running_or_pending: 0,
},
2016-11-11 00:21:09 -05:00
pageRequest: false,
2016-10-29 15:50:08 -04:00
};
},
props: [
'scope',
'store',
],
created() {
const url = window.location.toString();
if (~url.indexOf('?')) this.pagenum = url.split('?')[1].split('=')[1];
2016-11-10 12:16:27 -05:00
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope);
},
methods: {
2016-11-08 14:23:29 -05:00
changepage(event, last) {
const text = event.target.innerText;
2016-11-08 16:57:16 -05:00
if (text === '...') return;
2016-11-08 15:04:30 -05:00
if (/^-?[\d.]+(?:e-?\d+)?$/.test(text)) this.pagenum = +text;
2016-11-08 16:57:16 -05:00
if (text === 'Last >>') this.pagenum = last;
2016-11-08 14:31:41 -05:00
if (text === 'Next') this.pagenum = +this.pagenum + 1;
2016-11-08 14:23:29 -05:00
if (text === 'Prev') this.pagenum = +this.pagenum - 1;
2016-11-08 16:57:16 -05:00
if (text === '<< First') this.pagenum = 1;
window.history.pushState({}, null, `?p=${this.pagenum}`);
clearInterval(this.intervalId);
2016-11-11 00:21:09 -05:00
this.pageRequest = true;
2016-11-10 12:16:27 -05:00
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope);
},
},
template: `
<div>
2016-11-11 00:21:09 -05:00
<div class="pipeline-loading-status" v-if='pipelines.length < 1'>
<i class="fa fa-spinner fa-spin"></i>
</div>
<div class="table-holder" v-if='pipelines.length > 0'>
<table class="table ci-table">
<pipeline-head></pipeline-head>
<tbody>
<tr class="commit" v-for='pipeline in pipelines'>
<status-scope :pipeline='pipeline'></status-scope>
<pipeline-url :pipeline='pipeline'></pipeline-url>
<branch-commit :pipeline='pipeline'></branch-commit>
<stages :pipeline='pipeline'></stages>
<time-ago :pipeline='pipeline'></time-ago>
<pipeline-actions :pipeline='pipeline'></pipeline-actions>
</tr>
</tbody>
</table>
</div>
2016-11-11 00:21:09 -05:00
<div class="pipeline-loading-status" v-if='pageRequest'>
<i class="fa fa-spinner fa-spin"></i>
</div>
<gl-pagination
v-if='count.all > 0'
:pagenum='pagenum'
:changepage='changepage'
:count='count.all'
>
</gl-pagination>
2016-11-01 20:16:51 -04:00
</div>
`,
2016-10-26 14:43:58 -04:00
});
})(window.gl || (window.gl = {}));