2017-01-13 16:54:16 -05:00
|
|
|
/* global Vue, gl */
|
2017-01-06 18:06:12 -05:00
|
|
|
/* eslint-disable no-param-reassign */
|
2016-10-25 18:00:38 -04:00
|
|
|
|
2017-02-05 13:17:38 -05:00
|
|
|
window.Vue = require('vue');
|
|
|
|
require('../vue_shared/components/table_pagination');
|
|
|
|
require('./store');
|
|
|
|
require('../vue_shared/components/pipelines_table');
|
2017-02-15 11:00:58 -05:00
|
|
|
const CommitPipelinesStoreWithTimeAgo = require('../commit/pipelines/pipelines_store');
|
2017-01-28 16:26:04 -05:00
|
|
|
|
2016-10-26 14:43:58 -04:00
|
|
|
((gl) => {
|
2016-11-18 17:26:49 -05:00
|
|
|
gl.VuePipelines = Vue.extend({
|
2017-01-28 16:26:04 -05:00
|
|
|
|
2016-10-30 16:46:31 -04:00
|
|
|
components: {
|
2017-01-29 10:30:04 -05:00
|
|
|
'gl-pagination': gl.VueGlPagination,
|
2017-01-28 16:26:04 -05:00
|
|
|
'pipelines-table-component': gl.pipelines.PipelinesTableComponent,
|
2016-10-30 16:46:31 -04:00
|
|
|
},
|
2017-01-28 16:26:04 -05: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,
|
2017-02-15 09:06:00 -05:00
|
|
|
count: {},
|
2016-11-11 00:21:09 -05:00
|
|
|
pageRequest: false,
|
2016-10-29 15:50:08 -04:00
|
|
|
};
|
|
|
|
},
|
2017-02-24 14:02:57 -05:00
|
|
|
props: ['scope', 'store'],
|
2016-10-30 03:28:57 -04:00
|
|
|
created() {
|
2017-02-15 11:36:13 -05:00
|
|
|
const pagenum = gl.utils.getParameterByName('page');
|
2017-01-09 11:19:55 -05:00
|
|
|
const scope = gl.utils.getParameterByName('scope');
|
2016-12-05 15:17:23 -05:00
|
|
|
if (pagenum) this.pagenum = pagenum;
|
|
|
|
if (scope) this.apiScope = scope;
|
2017-02-15 11:00:58 -05:00
|
|
|
|
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
|
|
|
},
|
2017-02-15 11:00:58 -05:00
|
|
|
|
|
|
|
beforeUpdate() {
|
|
|
|
if (this.pipelines.length && this.$children) {
|
|
|
|
CommitPipelinesStoreWithTimeAgo.startTimeAgoLoops.call(this, Vue);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-10-30 03:28:57 -04:00
|
|
|
methods: {
|
2017-02-16 06:22:58 -05:00
|
|
|
/**
|
|
|
|
* Changes the URL according to the pagination component.
|
|
|
|
*
|
|
|
|
* If no scope is provided, 'all' is assumed.
|
|
|
|
*
|
2017-02-16 13:10:23 -05:00
|
|
|
* Pagination component sends "null" when no scope is provided.
|
|
|
|
*
|
2017-02-16 06:22:58 -05:00
|
|
|
* @param {Number} pagenum
|
|
|
|
* @param {String} apiScope = 'all'
|
|
|
|
*/
|
2017-02-16 13:10:23 -05:00
|
|
|
change(pagenum, apiScope) {
|
|
|
|
if (!apiScope) apiScope = 'all';
|
2017-02-16 15:17:12 -05:00
|
|
|
gl.utils.visitUrl(`?scope=${apiScope}&page=${pagenum}`);
|
2016-10-31 15:02:34 -04: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>
|
2017-02-03 10:14:20 -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>
|
2017-02-03 10:14:20 -05:00
|
|
|
|
|
|
|
<div class="blank-state blank-state-no-icon"
|
|
|
|
v-if="!pageRequest && pipelines.length === 0">
|
|
|
|
<h2 class="blank-state-title js-blank-state-title">
|
|
|
|
No pipelines to show
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="table-holder" v-if='!pageRequest && pipelines.length'>
|
2017-02-24 14:02:57 -05:00
|
|
|
<pipelines-table-component :pipelines='pipelines'/>
|
2016-11-02 20:54:04 -04:00
|
|
|
</div>
|
2017-02-03 10:14:20 -05:00
|
|
|
|
2016-11-10 22:08:55 -05:00
|
|
|
<gl-pagination
|
2017-02-03 10:14:20 -05:00
|
|
|
v-if='!pageRequest && pipelines.length && 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 = {}));
|