Commit 4df7c9ed authored by Filipa Lacerda's avatar Filipa Lacerda

Starts Vue view for environmnets List

parent b33791d8
//= require vue
//= require vue-resource
//= require_tree ./stores
//= require_tree ./services
$(() => {
const $environmentsListApp = document.getElementById('environments-list-view');
const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {};
if (gl.EnvironmentsListApp) {
gl.EnvironmentsListApp.$destroy(true);
}
gl.EnvironmentsListApp = new Vue({
el: $environmentsListApp,
components: {
'tree-view': gl.environmentsList.TreeView
},
data: {
endpoint: $environmentsListApp.dataset.endpoint,
loading: true
},
init: Store.create.bind(Store),
created() {
gl.environmentsService = new EnvironmentsService(this.endpoint);
},
/**
* Fetches all the environmnets and stores them.
* Toggles loading property.
*/
ready() {
gl.environmentsService.all().then((resp) => {
Store.addEnvironments(resp.json());
this.loading = false;
});
}
});
});
\ No newline at end of file
class EnvironmentsService {
constructor (root) {
Vue.http.options.root = root;
debugger;
this.environments = Vue.resource(root);
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
next();
});
}
all () {
return this.environments.get();
}
};
\ No newline at end of file
(() => {
window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {};
gl.environmentsList.EnvironmentsStore = {
create () {
},
/**
* Stores the received environmnets.
*
* @param {Array} environments List of environments
* @return {type}
*/
addEnvironments(environments) {
console.log(environments);
}
}
})();
\ No newline at end of file
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