2016-10-26 14:43:58 -04:00
|
|
|
/* global Vue, gl */
|
2016-11-02 18:45:22 -04:00
|
|
|
/* eslint-disable no-param-reassign, no-bitwise*/
|
2016-10-25 18:00:38 -04:00
|
|
|
|
2016-10-26 14:43:58 -04:00
|
|
|
((gl) => {
|
2016-11-18 17:26:49 -05:00
|
|
|
const SPREAD = '...';
|
|
|
|
const PREV = 'Prev';
|
|
|
|
const NEXT = 'Next';
|
|
|
|
const FIRST = '<< First';
|
|
|
|
const LAST = 'Last >>';
|
|
|
|
|
|
|
|
gl.VuePipelines = Vue.extend({
|
2016-10-30 16:46:31 -04:00
|
|
|
components: {
|
2016-11-11 00:21:09 -05:00
|
|
|
runningPipeline: gl.VueRunningPipeline,
|
|
|
|
pipelineActions: gl.VuePipelineActions,
|
|
|
|
stages: gl.VueStages,
|
2016-11-22 14:36:45 -05:00
|
|
|
commit: gl.CommitComponent,
|
2016-11-11 00:21:09 -05:00
|
|
|
pipelineUrl: gl.VuePipelineUrl,
|
|
|
|
pipelineHead: gl.VuePipelineHead,
|
|
|
|
glPagination: gl.VueGlPagination,
|
|
|
|
statusScope: gl.VueStatusScope,
|
|
|
|
timeAgo: gl.VueTimeAgo,
|
2016-10-30 16:46:31 -04:00
|
|
|
},
|
2016-10-29 15:50:08 -04:00
|
|
|
data() {
|
|
|
|
return {
|
2016-10-30 03:28:57 -04:00
|
|
|
pipelines: [],
|
2016-12-02 17:05:01 -05:00
|
|
|
timeLoopInterval: '',
|
2016-10-31 15:02:34 -04:00
|
|
|
intervalId: '',
|
2016-11-10 15:17:33 -05:00
|
|
|
updatedAt: '',
|
2016-11-03 13:20:15 -04:00
|
|
|
pagenum: 1,
|
2016-11-10 14:46:29 -05:00
|
|
|
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
|
|
|
};
|
|
|
|
},
|
2016-10-30 16:46:31 -04:00
|
|
|
props: [
|
|
|
|
'scope',
|
|
|
|
'store',
|
|
|
|
],
|
2016-10-30 03:28:57 -04:00
|
|
|
created() {
|
2016-11-02 18:45:22 -04:00
|
|
|
const url = window.location.toString();
|
2016-11-15 15:45:05 -05:00
|
|
|
if (~url.indexOf('?') && !~url.indexOf('scope=pipelines')) {
|
|
|
|
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);
|
2016-10-30 03:28:57 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2016-11-12 03:57:23 -05:00
|
|
|
changepage(e, last) {
|
|
|
|
const text = e.target.innerText;
|
2016-11-18 17:26:49 -05:00
|
|
|
if (text === SPREAD) return;
|
2016-11-08 15:04:30 -05:00
|
|
|
if (/^-?[\d.]+(?:e-?\d+)?$/.test(text)) this.pagenum = +text;
|
2016-11-18 17:26:49 -05:00
|
|
|
if (text === LAST) this.pagenum = last;
|
|
|
|
if (text === NEXT) this.pagenum = +this.pagenum + 1;
|
|
|
|
if (text === PREV) this.pagenum = +this.pagenum - 1;
|
|
|
|
if (text === FIRST) this.pagenum = 1;
|
2016-11-06 13:17:18 -05:00
|
|
|
|
2016-11-03 13:20:15 -04:00
|
|
|
window.history.pushState({}, null, `?p=${this.pagenum}`);
|
2016-12-02 17:05:01 -05:00
|
|
|
clearInterval(this.timeLoopInterval);
|
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);
|
2016-10-31 15:02:34 -04:00
|
|
|
},
|
2016-11-22 14:36:45 -05:00
|
|
|
author(pipeline) {
|
2016-12-01 18:07:30 -05:00
|
|
|
const { commit } = pipeline;
|
|
|
|
const author = commit.author;
|
2016-11-22 14:36:45 -05:00
|
|
|
if (author) return author;
|
2016-12-01 18:07:30 -05:00
|
|
|
|
|
|
|
const nonUser = {
|
|
|
|
avatar_url: commit.author_gravatar_url,
|
|
|
|
web_url: `mailto:${commit.author_email}`,
|
|
|
|
username: commit.author_name,
|
|
|
|
};
|
|
|
|
|
|
|
|
return nonUser;
|
2016-11-22 14:36:45 -05:00
|
|
|
},
|
2016-12-01 20:08:34 -05:00
|
|
|
ref(pipeline) {
|
|
|
|
const { ref } = pipeline;
|
|
|
|
const commitRef = {
|
|
|
|
name: ref.name,
|
|
|
|
tag: ref['tag?'],
|
|
|
|
ref_url: ref.url,
|
|
|
|
};
|
|
|
|
return commitRef;
|
|
|
|
},
|
2016-12-02 12:18:23 -05:00
|
|
|
addTimeInterval(id, start) {
|
|
|
|
this.allTimeIntervals.push({ id, start });
|
2016-11-30 03:23:51 -05:00
|
|
|
},
|
2016-10-30 03:28:57 -04:00
|
|
|
},
|
2016-10-25 18:00:38 -04:00
|
|
|
template: `
|
2016-11-02 20:54:04 -04:00
|
|
|
<div>
|
2016-12-01 17:02:26 -05:00
|
|
|
<div class="pipelines realtime-loading" v-if='pipelines.length < 1'>
|
2016-11-11 00:21:09 -05:00
|
|
|
<i class="fa fa-spinner fa-spin"></i>
|
|
|
|
</div>
|
|
|
|
<div class="table-holder" v-if='pipelines.length > 0'>
|
2016-11-02 20:54:04 -04:00
|
|
|
<table class="table ci-table">
|
2016-11-10 22:08:55 -05:00
|
|
|
<pipeline-head></pipeline-head>
|
2016-11-02 20:54:04 -04:00
|
|
|
<tbody>
|
|
|
|
<tr class="commit" v-for='pipeline in pipelines'>
|
2016-11-10 22:08:55 -05:00
|
|
|
<status-scope :pipeline='pipeline'></status-scope>
|
|
|
|
<pipeline-url :pipeline='pipeline'></pipeline-url>
|
2016-11-29 10:43:08 -05:00
|
|
|
<td>
|
|
|
|
<commit
|
2016-12-01 18:07:30 -05:00
|
|
|
:author='author(pipeline)'
|
2016-12-01 20:08:34 -05:00
|
|
|
:tag="pipeline.ref['tag?']"
|
2016-11-29 10:43:08 -05:00
|
|
|
:title='pipeline.commit.title'
|
2016-12-02 13:52:20 -05:00
|
|
|
:commit_ref='ref(pipeline)'
|
2016-11-29 10:43:08 -05:00
|
|
|
:short_sha='pipeline.commit.short_id'
|
|
|
|
:commit_url='pipeline.commit.commit_url'
|
|
|
|
>
|
|
|
|
</commit>
|
|
|
|
</td>
|
2016-11-10 22:08:55 -05:00
|
|
|
<stages :pipeline='pipeline'></stages>
|
2016-11-30 03:23:51 -05:00
|
|
|
<time-ago
|
|
|
|
:pipeline='pipeline'
|
|
|
|
>
|
|
|
|
</time-ago>
|
2016-11-10 22:08:55 -05:00
|
|
|
<pipeline-actions :pipeline='pipeline'></pipeline-actions>
|
2016-11-02 20:54:04 -04:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2016-12-01 17:02:26 -05:00
|
|
|
<div class="pipelines realtime-loading" v-if='pageRequest'>
|
2016-11-11 00:21:09 -05:00
|
|
|
<i class="fa fa-spinner fa-spin"></i>
|
|
|
|
</div>
|
2016-11-10 22:08:55 -05:00
|
|
|
<gl-pagination
|
2016-12-01 18:07:30 -05:00
|
|
|
v-if='count.all > 30'
|
2016-11-03 13:20:15 -04:00
|
|
|
:pagenum='pagenum'
|
2016-11-02 20:54:04 -04:00
|
|
|
:changepage='changepage'
|
2016-11-10 14:46:29 -05:00
|
|
|
:count='count.all'
|
2016-11-02 20:54:04 -04:00
|
|
|
>
|
2016-11-10 22:08:55 -05:00
|
|
|
</gl-pagination>
|
2016-11-01 20:16:51 -04:00
|
|
|
</div>
|
2016-10-25 18:00:38 -04:00
|
|
|
`,
|
2016-10-26 14:43:58 -04:00
|
|
|
});
|
|
|
|
})(window.gl || (window.gl = {}));
|