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

91 lines
2.5 KiB
JavaScript
Raw Normal View History

2017-01-13 16:54:16 -05:00
/* global Vue, gl */
/* eslint-disable no-param-reassign */
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');
const CommitPipelinesStoreWithTimeAgo = require('../commit/pipelines/pipelines_store');
2016-10-26 14:43:58 -04:00
((gl) => {
2016-11-18 17:26:49 -05:00
gl.VuePipelines = Vue.extend({
components: {
'gl-pagination': gl.VueGlPagination,
'pipelines-table-component': gl.pipelines.PipelinesTableComponent,
},
2016-10-29 15:50:08 -04:00
data() {
return {
pipelines: [],
timeLoopInterval: '',
intervalId: '',
apiScope: 'all',
2016-12-07 15:35:26 -05:00
pageInfo: {},
2016-12-07 17:20:30 -05:00
pagenum: 1,
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'],
created() {
const pagenum = gl.utils.getParameterByName('page');
const scope = gl.utils.getParameterByName('scope');
if (pagenum) this.pagenum = pagenum;
if (scope) this.apiScope = scope;
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
},
beforeUpdate() {
if (this.pipelines.length && this.$children) {
CommitPipelinesStoreWithTimeAgo.startTimeAgoLoops.call(this, Vue);
}
},
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.
*
* Pagination component sends "null" when no scope is provided.
*
2017-02-16 06:22:58 -05:00
* @param {Number} pagenum
* @param {String} apiScope = 'all'
*/
change(pagenum, apiScope) {
if (!apiScope) apiScope = 'all';
gl.utils.visitUrl(`?scope=${apiScope}&page=${pagenum}`);
},
},
template: `
<div>
<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>
<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'/>
</div>
<gl-pagination
v-if='!pageRequest && pipelines.length && pageInfo.total > pageInfo.perPage'
:pagenum='pagenum'
:change='change'
:count='count.all'
2016-12-07 15:35:26 -05:00
:pageInfo='pageInfo'
>
</gl-pagination>
2016-11-01 20:16:51 -04:00
</div>
`,
2016-10-26 14:43:58 -04:00
});
})(window.gl || (window.gl = {}));