aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/App.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/App.vue')
-rw-r--r--src/App.vue65
1 files changed, 36 insertions, 29 deletions
diff --git a/src/App.vue b/src/App.vue
index cd1d9ba..aff340c 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -13,7 +13,9 @@
13 <section v-if="config.header" class="first-line"> 13 <section v-if="config.header" class="first-line">
14 <div v-cloak class="container"> 14 <div v-cloak class="container">
15 <div class="logo"> 15 <div class="logo">
16 <a href="#"><img v-if="config.logo" :src="config.logo" alt="dashboard logo" /></a> 16 <a href="#">
17 <img v-if="config.logo" :src="config.logo" alt="dashboard logo" />
18 </a>
17 <i v-if="config.icon" :class="config.icon"></i> 19 <i v-if="config.icon" :class="config.icon"></i>
18 </div> 20 </div>
19 <div class="dashboard-title"> 21 <div class="dashboard-title">
@@ -149,36 +151,41 @@ export default {
149 }; 151 };
150 }, 152 },
151 created: async function () { 153 created: async function () {
152 const defaults = jsyaml.load(defaultConfig); 154 this.buildDashboard();
153 let config; 155 window.onhashchange = this.buildDashboard;
154 window.onhashchange = function() { location.reload(); };
155 try {
156 config = await this.getConfig();
157 const path = (window.location.hash.substring(1) != '') ? window.location.hash.substring(1) : null;
158 if (path) {
159 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
160 for (const prop in pathConfig) config[prop] = pathConfig[prop];
161 }
162 // config = await this.getConfig(path ? `assets/${path}.yml` : null);
163 //config = await (path ? this.getConfig(`assets/${path}.yml`) : this.getConfig())
164 } catch (error) {
165 console.log(error);
166 config = this.handleErrors("⚠️ Error loading configuration", error);
167 }
168 this.config = merge(defaults, config);
169 this.services = this.config.services;
170 document.title =
171 this.config.documentTitle ||
172 `${this.config.title} | ${this.config.subtitle}`;
173 if (this.config.stylesheet) {
174 let stylesheet = "";
175 for (const file of this.config.stylesheet) {
176 stylesheet += `@import "${file}";`;
177 }
178 this.createStylesheet(stylesheet);
179 }
180 }, 156 },
181 methods: { 157 methods: {
158 buildDashboard: async function () {
159 const defaults = jsyaml.load(defaultConfig);
160 let config;
161 try {
162 config = await this.getConfig();
163 const path =
164 window.location.hash.substring(1) != ""
165 ? window.location.hash.substring(1)
166 : null;
167
168 if (path) {
169 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
170 config = Object.assign(config, pathConfig);
171 }
172 } catch (error) {
173 console.log(error);
174 config = this.handleErrors("⚠️ Error loading configuration", error);
175 }
176 this.config = merge(defaults, config);
177 this.services = this.config.services;
178 document.title =
179 this.config.documentTitle ||
180 `${this.config.title} | ${this.config.subtitle}`;
181 if (this.config.stylesheet) {
182 let stylesheet = "";
183 for (const file of this.config.stylesheet) {
184 stylesheet += `@import "${file}";`;
185 }
186 this.createStylesheet(stylesheet);
187 }
188 },
182 getConfig: function (path = "assets/config.yml") { 189 getConfig: function (path = "assets/config.yml") {
183 return fetch(path).then((response) => { 190 return fetch(path).then((response) => {
184 if (response.redirected) { 191 if (response.redirected) {