diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-06-09 19:11:42 -0700 |
---|---|---|
committer | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-06-09 21:55:29 -0700 |
commit | 1a42e30a1752be5ab0fba5b224fad5686f12499e (patch) | |
tree | d5fb02a4fda8eb0ffe30e32fa53b0212ff1d6d7c | |
parent | 52ed5af6074bb6850925cbb658a60a4493079338 (diff) | |
download | homer-1a42e30a1752be5ab0fba5b224fad5686f12499e.tar.gz homer-1a42e30a1752be5ab0fba5b224fad5686f12499e.tar.zst homer-1a42e30a1752be5ab0fba5b224fad5686f12499e.zip |
Adding external config support
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | src/App.vue | 33 |
2 files changed, 25 insertions, 12 deletions
@@ -85,6 +85,10 @@ Title, icons, links, colors, and services can be configured in the `config.yml` | |||
85 | # Homepage configuration | 85 | # Homepage configuration |
86 | # See https://fontawesome.com/icons for icons options | 86 | # See https://fontawesome.com/icons for icons options |
87 | 87 | ||
88 | # Optional: Use external configuration file. | ||
89 | # Using this will ignore remaining config in this file | ||
90 | # externalConfig: https://example.com/server-luci/config.yaml | ||
91 | |||
88 | title: "App dashboard" | 92 | title: "App dashboard" |
89 | subtitle: "Homer" | 93 | subtitle: "Homer" |
90 | logo: "assets/homer.png" | 94 | logo: "assets/homer.png" |
diff --git a/src/App.vue b/src/App.vue index fddc585..440ffa0 100644 --- a/src/App.vue +++ b/src/App.vue | |||
@@ -63,7 +63,7 @@ | |||
63 | </h2> | 63 | </h2> |
64 | <Service | 64 | <Service |
65 | v-for="item in group.items" | 65 | v-for="item in group.items" |
66 | :key="item.url" | 66 | :key="item.name" |
67 | v-bind:item="item" | 67 | v-bind:item="item" |
68 | class="column is-one-third-widescreen" | 68 | class="column is-one-third-widescreen" |
69 | /> | 69 | /> |
@@ -153,19 +153,28 @@ export default { | |||
153 | document.title = `${this.config.title} | ${this.config.subtitle}`; | 153 | document.title = `${this.config.title} | ${this.config.subtitle}`; |
154 | }, | 154 | }, |
155 | methods: { | 155 | methods: { |
156 | getConfig: function () { | 156 | getConfig: function (path = "config.yml") { |
157 | return fetch("config.yml") | 157 | return fetch(path).then((response) => { |
158 | .then((response) => { | 158 | if (!response.ok) { |
159 | if (!response.ok) { | 159 | throw Error(response.statusText); |
160 | throw Error(response.statusText); | 160 | } |
161 | } | 161 | |
162 | return response.text().then((body) => { | 162 | const that = this; |
163 | return response | ||
164 | .text() | ||
165 | .then((body) => { | ||
163 | return jsyaml.load(body); | 166 | return jsyaml.load(body); |
167 | }) | ||
168 | .then(function (config) { | ||
169 | if (config.externalConfig) { | ||
170 | return that.getConfig(config.externalConfig); | ||
171 | } | ||
172 | return config; | ||
173 | }) | ||
174 | .catch((error) => { | ||
175 | return this.handleErrors("⚠️ Error loading configuration", error); | ||
164 | }); | 176 | }); |
165 | }) | 177 | }); |
166 | .catch((error) => { | ||
167 | return this.handleErrors("⚠️ Error loading configuration", error); | ||
168 | }); | ||
169 | }, | 178 | }, |
170 | matchesFilter: function (item) { | 179 | matchesFilter: function (item) { |
171 | return ( | 180 | return ( |