mirror of
https://github.com/bastienwirtz/homer.git
synced 2025-01-14 18:08:13 +01:00
Adding external config support
This commit is contained in:
parent
52ed5af607
commit
1a42e30a17
@ -85,6 +85,10 @@ Title, icons, links, colors, and services can be configured in the `config.yml`
|
|||||||
# Homepage configuration
|
# Homepage configuration
|
||||||
# See https://fontawesome.com/icons for icons options
|
# See https://fontawesome.com/icons for icons options
|
||||||
|
|
||||||
|
# Optional: Use external configuration file.
|
||||||
|
# Using this will ignore remaining config in this file
|
||||||
|
# externalConfig: https://example.com/server-luci/config.yaml
|
||||||
|
|
||||||
title: "App dashboard"
|
title: "App dashboard"
|
||||||
subtitle: "Homer"
|
subtitle: "Homer"
|
||||||
logo: "assets/homer.png"
|
logo: "assets/homer.png"
|
||||||
|
21
src/App.vue
21
src/App.vue
@ -63,7 +63,7 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<Service
|
<Service
|
||||||
v-for="item in group.items"
|
v-for="item in group.items"
|
||||||
:key="item.url"
|
:key="item.name"
|
||||||
v-bind:item="item"
|
v-bind:item="item"
|
||||||
class="column is-one-third-widescreen"
|
class="column is-one-third-widescreen"
|
||||||
/>
|
/>
|
||||||
@ -153,19 +153,28 @@ export default {
|
|||||||
document.title = `${this.config.title} | ${this.config.subtitle}`;
|
document.title = `${this.config.title} | ${this.config.subtitle}`;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getConfig: function () {
|
getConfig: function (path = "config.yml") {
|
||||||
return fetch("config.yml")
|
return fetch(path).then((response) => {
|
||||||
.then((response) => {
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw Error(response.statusText);
|
throw Error(response.statusText);
|
||||||
}
|
}
|
||||||
return response.text().then((body) => {
|
|
||||||
|
const that = this;
|
||||||
|
return response
|
||||||
|
.text()
|
||||||
|
.then((body) => {
|
||||||
return jsyaml.load(body);
|
return jsyaml.load(body);
|
||||||
});
|
})
|
||||||
|
.then(function (config) {
|
||||||
|
if (config.externalConfig) {
|
||||||
|
return that.getConfig(config.externalConfig);
|
||||||
|
}
|
||||||
|
return config;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
return this.handleErrors("⚠️ Error loading configuration", error);
|
return this.handleErrors("⚠️ Error loading configuration", error);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
matchesFilter: function (item) {
|
matchesFilter: function (item) {
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user