diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-06-06 16:57:36 -0700 |
---|---|---|
committer | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-06-06 17:01:11 -0700 |
commit | bd9109425a40f5b6c43147a7c9852014a5797dca (patch) | |
tree | ac0ae4228024680968028c8825f73eb085d8c013 /src/App.vue | |
parent | 10ea23a01d822714eb5c55ac46b808064fd1f600 (diff) | |
download | homer-bd9109425a40f5b6c43147a7c9852014a5797dca.tar.gz homer-bd9109425a40f5b6c43147a7c9852014a5797dca.tar.zst homer-bd9109425a40f5b6c43147a7c9852014a5797dca.zip |
Display parsing error
Diffstat (limited to 'src/App.vue')
-rw-r--r-- | src/App.vue | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/App.vue b/src/App.vue index 8185da2..fddc585 100644 --- a/src/App.vue +++ b/src/App.vue | |||
@@ -146,27 +146,26 @@ export default { | |||
146 | }; | 146 | }; |
147 | }, | 147 | }, |
148 | created: async function () { | 148 | created: async function () { |
149 | try { | 149 | const defaults = jsyaml.load(defaultConfig); |
150 | const defaults = jsyaml.load(defaultConfig); | 150 | let config = await this.getConfig(); |
151 | let config = await this.getConfig(); | 151 | this.config = merge(defaults, config); |
152 | 152 | this.services = this.config.services; | |
153 | this.config = merge(defaults, config); | 153 | document.title = `${this.config.title} | ${this.config.subtitle}`; |
154 | this.services = this.config.services; | ||
155 | document.title = `${this.config.title} | ${this.config.subtitle}`; | ||
156 | } catch (error) { | ||
157 | this.offline = true; | ||
158 | } | ||
159 | }, | 154 | }, |
160 | methods: { | 155 | methods: { |
161 | getConfig: function () { | 156 | getConfig: function () { |
162 | return fetch("config.yml").then(function (response) { | 157 | return fetch("config.yml") |
163 | if (response.status != 200) { | 158 | .then((response) => { |
164 | return; | 159 | if (!response.ok) { |
165 | } | 160 | throw Error(response.statusText); |
166 | return response.text().then(function (body) { | 161 | } |
167 | return jsyaml.load(body); | 162 | return response.text().then((body) => { |
163 | return jsyaml.load(body); | ||
164 | }); | ||
165 | }) | ||
166 | .catch((error) => { | ||
167 | return this.handleErrors("⚠️ Error loading configuration", error); | ||
168 | }); | 168 | }); |
169 | }); | ||
170 | }, | 169 | }, |
171 | matchesFilter: function (item) { | 170 | matchesFilter: function (item) { |
172 | return ( | 171 | return ( |
@@ -207,6 +206,15 @@ export default { | |||
207 | }, | 206 | }, |
208 | ]; | 207 | ]; |
209 | }, | 208 | }, |
209 | handleErrors: function (title, content) { | ||
210 | return { | ||
211 | message: { | ||
212 | title: title, | ||
213 | style: "is-danger", | ||
214 | content: content, | ||
215 | }, | ||
216 | }; | ||
217 | }, | ||
210 | }, | 218 | }, |
211 | }; | 219 | }; |
212 | </script> | 220 | </script> |