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

75 lines
2.1 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');
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: { 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'],
created() {
const pagenum = gl.utils.getParameterByName('p');
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);
},
methods: {
change(pagenum, apiScope) {
if (!apiScope) apiScope = 'all';
2017-01-13 16:54:16 -05:00
gl.utils.visitUrl(`?scope=${apiScope}&p=${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'>
<pipelines-table-component
:pipelines='pipelines'
:svgs='svgs'>
</pipelines-table-component>
</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 = {}));