X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FApp.vue;h=fda13c31e07ef4cb7bcf5f1e50365d29f8fe4e65;hb=a7cbcc7700990dbdfbfe61374e14a700ff0d4714;hp=03970edce642874a28dd8c70d59f2ec6cccd8361;hpb=e3bd2ecc2ca874270282c3c42813b8053d67dcbd;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/App.vue b/src/App.vue index 03970ed..fda13c3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,9 @@
@@ -28,17 +30,22 @@ :links="config.links" @navbar-toggle="showMenu = !showMenu" > - + + + +
@@ -62,12 +72,18 @@ @@ -85,12 +101,18 @@ >

+ {{ group.name }}

@@ -115,6 +137,7 @@ const jsyaml = require("js-yaml"); const merge = require("lodash.merge"); import Navbar from "./components/Navbar.vue"; +import GetStarted from "./components/GetStarted.vue"; import ConnectivityChecker from "./components/ConnectivityChecker.vue"; import Service from "./components/Service.vue"; import Message from "./components/Message.vue"; @@ -129,6 +152,7 @@ export default { name: "App", components: { Navbar, + GetStarted, ConnectivityChecker, Service, Message, @@ -139,6 +163,7 @@ export default { }, data: function () { return { + loaded: false, config: null, services: null, offline: false, @@ -149,35 +174,48 @@ export default { }; }, created: async function () { - const defaults = jsyaml.load(defaultConfig); - let config; - try { - config = await this.getConfig(); - const path = (window.location.pathname != '/') ? window.location.pathname : null; - if (path) { - let pathConfig = await this.getConfig(`assets${path}.yml`); // the slash (/) is included in the pathname - for (const prop in pathConfig) config[prop] = pathConfig[prop]; - } - // config = await this.getConfig(path ? `assets/${path}.yml` : null); - //config = await (path ? this.getConfig(`assets/${path}.yml`) : 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.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); - } + this.buildDashboard(); + window.onhashchange = this.buildDashboard; + this.loaded = true; }, methods: { + searchHotkey() { + if (this.config.hotkey && this.config.hotkey.search) { + return this.config.hotkey.search; + } + }, + 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) { @@ -185,6 +223,7 @@ export default { window.location.href = response.url; return; } + if (!response.ok) { throw Error(`${response.statusText}: ${response.body}`); }