]> git.immae.eu Git - github/bastienwirtz/homer.git/blob - app.js
Deps update & minor UI adjustments
[github/bastienwirtz/homer.git] / app.js
1 var app = new Vue({
2 el: '#app',
3 data: {
4 config: null,
5 filter: ''
6 },
7 beforeCreate() {
8 let that = this;
9
10 return getConfig().then(function (config) {
11 const size = 3;
12 config.services.forEach(function (service) {
13 service.rows = [];
14 items = service.items;
15 while (items.length) {
16 service.rows.push(items.splice(0, size));
17 }
18
19 if (service.rows.length) {
20 let last = service.rows.length - 1;
21 service.rows[last] = service.rows[last].concat(Array(size - service.rows[last].length));
22 }
23 });
24 that.config = config;
25 }).catch(function () {
26 console.error('Fail to get config');
27 });
28 }
29 });
30
31
32 function getConfig() {
33 return fetch('config.yml').then(function (response) {
34 if (response.status !== 200) {
35 return;
36 }
37
38 return response.text().then(function (body) {
39 return jsyaml.load(body);
40 });
41 });
42 }