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