X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FApp.vue;h=1f1791ca616c0786236dc9901b7a131575e8f861;hb=5db2414d052af629e2848f53ce9c2e0e686eefaf;hp=03760fdd3190119397bec6d48532373f06466afd;hpb=fbe9338fd3a78141110530055c9b90a5958f845f;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/App.vue b/src/App.vue index 03760fd..1f1791c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,9 @@
@@ -26,23 +28,27 @@ - +
@@ -51,7 +57,7 @@
@@ -62,12 +68,18 @@ @@ -85,12 +97,18 @@ >

+ {{ group.name }}

@@ -149,26 +167,41 @@ export default { }; }, created: async function () { - const defaults = jsyaml.load(defaultConfig); - let config; - try { - config = await this.getConfig(); - } catch (error) { - console.log(error); - config = this.handleErrors("⚠️ Error loading configuration", error); - } - this.config = merge(defaults, config); - this.services = this.config.services; - document.title = `${this.config.title} | ${this.config.subtitle}`; - if (this.config.stylesheet) { - let stylesheet = ''; - for (const file of this.config.stylesheet) { - stylesheet += `@import "${file}";`; - } - this.createStylesheet(stylesheet); - } + this.buildDashboard(); + window.onhashchange = this.buildDashboard; }, methods: { + buildDashboard: async function () { + const defaults = jsyaml.load(defaultConfig); + let config; + try { + config = await this.getConfig(); + const path = + window.location.hash.substring(1) != "" + ? window.location.hash.substring(1) + : null; + + if (path) { + let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname + config = Object.assign(config, pathConfig); + } + } catch (error) { + console.log(error); + config = this.handleErrors("⚠️ Error loading configuration", error); + } + this.config = merge(defaults, config); + this.services = this.config.services; + document.title = + this.config.documentTitle || + `${this.config.title} | ${this.config.subtitle}`; + if (this.config.stylesheet) { + let stylesheet = ""; + for (const file of this.config.stylesheet) { + stylesheet += `@import "${file}";`; + } + this.createStylesheet(stylesheet); + } + }, getConfig: function (path = "assets/config.yml") { return fetch(path).then((response) => { if (response.redirected) { @@ -197,6 +230,7 @@ export default { matchesFilter: function (item) { return ( item.name.toLowerCase().includes(this.filter) || + (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) || (item.tag && item.tag.toLowerCase().includes(this.filter)) ); }, @@ -242,8 +276,8 @@ export default { }, }; }, - createStylesheet: function(css) { - let style = document.createElement('style'); + createStylesheet: function (css) { + let style = document.createElement("style"); style.appendChild(document.createTextNode(css)); document.head.appendChild(style); },