BigW Consortium Gitlab

Commit a42140d0 by Regis

page specific js - remove inline js - refactor

parent c32c77a0
/* global Vue, VueResource, gl */
//= require vue //= require vue
//= require vue-resource //= require vue-resource
...@@ -5,3 +7,24 @@ ...@@ -5,3 +7,24 @@
//= require ./running_icon.vue.js.es6 //= require ./running_icon.vue.js.es6
//= require ./running.vue.js.es6 //= require ./running.vue.js.es6
//= require ./pipelines.vue.js.es6 //= require ./pipelines.vue.js.es6
(() => {
const project = document.querySelector('.table-holder');
Vue.use(VueResource);
new Vue({
el: '.vue-pipelines-index',
data: {
scope: project.dataset.projectId,
store: new gl.PipelineStore(),
},
components: {
'vue-pipelines': gl.VuePipeLines,
},
template: ''
+ '<div>'
+ "<vue-pipelines :scope='scope' :store='store'></vue-pipelines>"
+ '</div>',
});
})();
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
return { return {
pipelines: [], pipelines: [],
commits: [], commits: [],
currentPage: '',
intervalId: '',
}; };
}, },
props: [ props: [
...@@ -24,6 +26,11 @@ ...@@ -24,6 +26,11 @@
shortSha(pipeline) { shortSha(pipeline) {
return pipeline.sha.slice(0, 8); return pipeline.sha.slice(0, 8);
}, },
changePage() {
// clearInterval(this.intervalId);
// this.store.fetchCommits.call(this, Vue);
// this.store.fetchDataLoop.call(this, Vue);
},
}, },
template: ` template: `
<thead> <thead>
...@@ -52,6 +59,7 @@ ...@@ -52,6 +59,7 @@
<div class="icon-container"> <div class="icon-container">
<i class="fa fa-code-fork"></i> <i class="fa fa-code-fork"></i>
</div> </div>
<!-- I need to know which branch things are comming from -->
<a class="monospace branch-name" href="/gitlab-org/gitlab-ce/commits/master">master</a> <a class="monospace branch-name" href="/gitlab-org/gitlab-ce/commits/master">master</a>
<div class="icon-container commit-icon"> <div class="icon-container commit-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"> <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
......
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
((gl) => { ((gl) => {
const api = '/api/v3/projects';
const goFetch = (that, vue) => const goFetch = (that, vue) =>
that.$http.get(`/api/v3/projects/${that.scope}/pipelines?per_page=5&page=1`) that.$http.get(
`${api}/${that.scope}/pipelines?per_page=5&page=1`
)
.then((response) => { .then((response) => {
vue.set(that, 'pipelines', JSON.parse(response.body)); vue.set(that, 'pipelines', JSON.parse(response.body));
}, () => { }, () => {
...@@ -12,14 +16,17 @@ ...@@ -12,14 +16,17 @@
gl.PipelineStore = class { gl.PipelineStore = class {
fetchDataLoop(Vue) { fetchDataLoop(Vue) {
setInterval(() => { // eventually clearInterval(this.intervalId)
this.intervalId = setInterval(() => {
console.log('DID IT'); console.log('DID IT');
goFetch(this, Vue); goFetch(this, Vue);
}, 30000); }, 30000);
} }
fetchCommits(vue) { fetchCommits(vue) {
this.$http.get(`/api/v3/projects/${this.scope}/repository/commits?per_page=5&page=1`) this.$http.get(
`${api}/${this.scope}/repository/commits?per_page=5&page=1`
)
.then((response) => { .then((response) => {
vue.set(this, 'commits', JSON.parse(response.body)); vue.set(this, 'commits', JSON.parse(response.body));
}, () => { }, () => {
......
...@@ -42,24 +42,8 @@ ...@@ -42,24 +42,8 @@
%div %div
.nothing-here-block No pipelines to show .nothing-here-block No pipelines to show
- else - else
.table-holder .table-holder{"data-project-id": "#{@project.id}"}
%table.table.ci-table %table.table.ci-table
%tbody.app %tbody.vue-pipelines-index
:javascript = page_specific_javascript_tag('vue_pipelines_index/index.js')
Vue.use(VueResource); \ No newline at end of file
var vm = new Vue({
el: ".app",
data:{
scope: "#{@project.id}",
store: new gl.PipelineStore(),
},
components: {
'vue-pipelines': gl.VuePipeLines,
},
template: ""
+ "<div>"
+ "<vue-pipelines :scope='scope' :store='store'></vue-pipelines>"
+ "</div>",
})
...@@ -99,6 +99,7 @@ module Gitlab ...@@ -99,6 +99,7 @@ module Gitlab
config.assets.precompile << "lib/utils/*.js" config.assets.precompile << "lib/utils/*.js"
config.assets.precompile << "lib/*.js" config.assets.precompile << "lib/*.js"
config.assets.precompile << "u2f.js" config.assets.precompile << "u2f.js"
config.assets.precompile << "vue_pipelines_index/index.js"
# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment