2017-01-09 12:20:20 -05:00
|
|
|
/* global Vue, Turbolinks, gl */
|
2017-01-06 18:06:12 -05:00
|
|
|
/* eslint-disable no-param-reassign */
|
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
|
|
|
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-12-05 15:17:23 -05:00
|
|
|
apiScope: 'all',
|
2016-12-07 15:35:26 -05:00
|
|
|
pageInfo: {},
|
2016-12-07 17:20:30 -05:00
|
|
|
pagenum: 1,
|
2016-12-08 13:05:20 -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-12-12 14:11:28 -05:00
|
|
|
props: ['scope', 'store', 'svgs'],
|
2016-10-30 03:28:57 -04:00
|
|
|
created() {
|
2017-01-09 11:19:55 -05:00
|
|
|
const pagenum = gl.utils.getParameterByName('p');
|
|
|
|
const scope = gl.utils.getParameterByName('scope');
|
2016-12-05 15:17:23 -05:00
|
|
|
if (pagenum) this.pagenum = pagenum;
|
|
|
|
if (scope) this.apiScope = scope;
|
2016-12-08 13:05:20 -05:00
|
|
|
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
|
2016-10-30 03:28:57 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2016-12-08 19:37:00 -05:00
|
|
|
change(pagenum, apiScope) {
|
2017-01-09 12:20:20 -05:00
|
|
|
Turbolinks.visit(`?scope=${apiScope}&p=${pagenum}`);
|
2016-10-31 15:02:34 -04:00
|
|
|
},
|
2016-11-22 14:36:45 -05:00
|
|
|
author(pipeline) {
|
2017-01-09 11:19:55 -05:00
|
|
|
if (!pipeline.commit) return { avatar_url: '', web_url: '', username: '' };
|
2016-12-08 13:05:20 -05:00
|
|
|
if (pipeline.commit.author) return pipeline.commit.author;
|
2017-01-06 17:38:35 -05:00
|
|
|
return {
|
2016-12-08 13:05:20 -05:00
|
|
|
avatar_url: pipeline.commit.author_gravatar_url,
|
|
|
|
web_url: `mailto:${pipeline.commit.author_email}`,
|
|
|
|
username: pipeline.commit.author_name,
|
2017-01-06 17:38:35 -05:00
|
|
|
};
|
2016-11-22 14:36:45 -05:00
|
|
|
},
|
2016-12-01 20:08:34 -05:00
|
|
|
ref(pipeline) {
|
|
|
|
const { ref } = pipeline;
|
2017-01-06 17:38:35 -05:00
|
|
|
return { name: ref.name, tag: ref.tag, ref_url: ref.path };
|
2016-11-30 03:23:51 -05:00
|
|
|
},
|
2016-12-08 12:03:53 -05:00
|
|
|
commitTitle(pipeline) {
|
2016-12-16 18:03:01 -05:00
|
|
|
return pipeline.commit ? pipeline.commit.title : '';
|
2016-12-08 12:03:53 -05:00
|
|
|
},
|
|
|
|
commitSha(pipeline) {
|
2016-12-16 18:03:01 -05:00
|
|
|
return pipeline.commit ? pipeline.commit.short_id : '';
|
2016-12-08 12:03:53 -05:00
|
|
|
},
|
|
|
|
commitUrl(pipeline) {
|
2016-12-21 20:06:23 -05:00
|
|
|
return pipeline.commit ? pipeline.commit.commit_path : '';
|
2016-12-08 12:03:53 -05:00
|
|
|
},
|
2016-12-13 11:54:18 -05:00
|
|
|
match(string) {
|
|
|
|
return string.replace(/_([a-z])/g, (m, w) => w.toUpperCase());
|
|
|
|
},
|
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>
|
2017-01-06 17:37:02 -05:00
|
|
|
<div class="table-holder" v-if='pipelines.length'>
|
2016-11-02 20:54:04 -04:00
|
|
|
<table class="table ci-table">
|
2017-01-06 16:14:53 -05:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2017-01-12 16:03:02 -05:00
|
|
|
<th class="pipeline-status">Status</th>
|
|
|
|
<th class="pipeline-info">Pipeline</th>
|
|
|
|
<th class="pipeline-commit">Commit</th>
|
|
|
|
<th class="pipeline-stages">Stages</th>
|
|
|
|
<th class="pipeline-date"></th>
|
|
|
|
<th class="pipeline-actions hidden-xs"></th>
|
2017-01-06 16:14:53 -05:00
|
|
|
</tr>
|
|
|
|
</thead>
|
2016-11-02 20:54:04 -04:00
|
|
|
<tbody>
|
|
|
|
<tr class="commit" v-for='pipeline in pipelines'>
|
2016-12-13 11:54:18 -05:00
|
|
|
<status-scope
|
|
|
|
:pipeline='pipeline'
|
|
|
|
:match='match'
|
|
|
|
:svgs='svgs'
|
|
|
|
>
|
|
|
|
</status-scope>
|
2016-11-10 22:08:55 -05:00
|
|
|
<pipeline-url :pipeline='pipeline'></pipeline-url>
|
2016-11-29 10:43:08 -05:00
|
|
|
<td>
|
|
|
|
<commit
|
2016-12-12 14:11:28 -05:00
|
|
|
:commit-icon-svg='svgs.commitIconSvg'
|
2016-12-01 18:07:30 -05:00
|
|
|
:author='author(pipeline)'
|
2017-01-02 18:20:10 -05:00
|
|
|
:tag="pipeline.ref.tag"
|
2016-12-08 12:03:53 -05:00
|
|
|
:title='commitTitle(pipeline)'
|
2016-12-12 14:11:28 -05:00
|
|
|
:commit-ref='ref(pipeline)'
|
|
|
|
:short-sha='commitSha(pipeline)'
|
|
|
|
:commit-url='commitUrl(pipeline)'
|
2016-11-29 10:43:08 -05:00
|
|
|
>
|
|
|
|
</commit>
|
|
|
|
</td>
|
2016-12-13 11:54:18 -05:00
|
|
|
<stages
|
|
|
|
:pipeline='pipeline'
|
|
|
|
:svgs='svgs'
|
|
|
|
:match='match'
|
|
|
|
>
|
|
|
|
</stages>
|
2016-12-16 18:12:52 -05:00
|
|
|
<time-ago :pipeline='pipeline' :svgs='svgs'></time-ago>
|
|
|
|
<pipeline-actions :pipeline='pipeline' :svgs='svgs'></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-08 12:03:53 -05:00
|
|
|
v-if='pageInfo.total > pageInfo.perPage'
|
2016-11-03 13:20:15 -04:00
|
|
|
:pagenum='pagenum'
|
2016-12-08 19:37:00 -05:00
|
|
|
:change='change'
|
2016-11-10 14:46:29 -05:00
|
|
|
:count='count.all'
|
2016-12-07 15:35:26 -05:00
|
|
|
:pageInfo='pageInfo'
|
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 = {}));
|