blob: 26979755f3acb2bb43eac226bf92207f271c9181 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
var app = new Vue({
el: '#app',
data: {
config: null,
filter: ''
},
beforeCreate () {
var that = this;
return getConfig().then(function (config) {
// Splice services list into groups of 3 for flex column display
var size = 3;
config.services.forEach(function(service) {
service.rows = [];
items = service.items;
while (items.length) {
service.rows.push(items.splice(0, size));
}
if (service.rows.length) {
var last = service.rows.length-1;
service.rows[last] = service.rows[last].concat(Array(size - service.rows[last].length));
}
});
that.config = config;
});
}
});
function getConfig() {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'config.yml');
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
try {
var data = jsyaml.load(xhr.response);
resolve(data);
} catch (e) {
console.error('fail to parse config file');
reject();
}
} else {
reject({
status: this.status,
statusText: xhr.statusText
});
}
};
xhr.onerror = function () {
reject({
status: this.status,
statusText: xhr.statusText
});
};
xhr.send();
});
}
|