aboutsummaryrefslogtreecommitdiffhomepage
path: root/app.js
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2018-06-13 22:14:05 -0700
committerBastien Wirtz <bastien.wirtz@gmail.com>2018-06-13 22:21:09 -0700
commit09763dbf6a6f24263cdff535a3aca64da35a0abb (patch)
tree13967839553c98e12ea5219a5d88e6eb8da08043 /app.js
parentb21bf8b1af775e17833da4432d48ffc18a294ebc (diff)
downloadhomer-09763dbf6a6f24263cdff535a3aca64da35a0abb.tar.gz
homer-09763dbf6a6f24263cdff535a3aca64da35a0abb.tar.zst
homer-09763dbf6a6f24263cdff535a3aca64da35a0abb.zip
Initial commit
Diffstat (limited to 'app.js')
-rw-r--r--app.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/app.js b/app.js
new file mode 100644
index 0000000..2697975
--- /dev/null
+++ b/app.js
@@ -0,0 +1,58 @@
1var app = new Vue({
2 el: '#app',
3 data: {
4 config: null,
5 filter: ''
6 },
7 beforeCreate () {
8 var that = this;
9 return getConfig().then(function (config) {
10 // Splice services list into groups of 3 for flex column display
11 var 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 var 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 });
26 }
27});
28
29
30function getConfig() {
31 return new Promise(function (resolve, reject) {
32 var xhr = new XMLHttpRequest();
33 xhr.open('GET', 'config.yml');
34 xhr.onload = function () {
35 if (this.status >= 200 && this.status < 300) {
36 try {
37 var data = jsyaml.load(xhr.response);
38 resolve(data);
39 } catch (e) {
40 console.error('fail to parse config file');
41 reject();
42 }
43 } else {
44 reject({
45 status: this.status,
46 statusText: xhr.statusText
47 });
48 }
49 };
50 xhr.onerror = function () {
51 reject({
52 status: this.status,
53 statusText: xhr.statusText
54 });
55 };
56 xhr.send();
57 });
58} \ No newline at end of file