aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/App.vue
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2021-09-13 13:09:40 -0700
committerGitHub <noreply@github.com>2021-09-13 13:09:40 -0700
commit92d5b8d424cbd4c227c9c76931930787deec4a2f (patch)
treeaa52c1955c9cf210bd95ad32e20f1b4286f7c0a7 /src/App.vue
parent97f0c43ccc724ec4502e55f73874a89f822f0a81 (diff)
parent55c3ea4d92b0c5628ead4475ae7359bbf2cc59c4 (diff)
downloadhomer-92d5b8d424cbd4c227c9c76931930787deec4a2f.tar.gz
homer-92d5b8d424cbd4c227c9c76931930787deec4a2f.tar.zst
homer-92d5b8d424cbd4c227c9c76931930787deec4a2f.zip
Merge branch 'main' into main
Diffstat (limited to 'src/App.vue')
-rw-r--r--src/App.vue67
1 files changed, 46 insertions, 21 deletions
diff --git a/src/App.vue b/src/App.vue
index dc473ca..1f4f509 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 <img v-if="config.logo" :src="config.logo" alt="dashboard logo" /> 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">
@@ -62,6 +64,11 @@
62 <template v-for="group in services"> 64 <template v-for="group in services">
63 <h2 v-if="group.name" class="column is-full group-title"> 65 <h2 v-if="group.name" class="column is-full group-title">
64 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i> 66 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
67 <div v-else-if="group.logo" class="group-logo media-left">
68 <figure class="image is-48x48">
69 <img :src="group.logo" :alt="`${group.name} logo`" />
70 </figure>
71 </div>
65 {{ group.name }} 72 {{ group.name }}
66 </h2> 73 </h2>
67 <Service 74 <Service
@@ -85,6 +92,11 @@
85 > 92 >
86 <h2 v-if="group.name" class="group-title"> 93 <h2 v-if="group.name" class="group-title">
87 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i> 94 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
95 <div v-else-if="group.logo" class="group-logo media-left">
96 <figure class="image is-48x48">
97 <img :src="group.logo" :alt="`${group.name} logo`" />
98 </figure>
99 </div>
88 {{ group.name }} 100 {{ group.name }}
89 </h2> 101 </h2>
90 <Service 102 <Service
@@ -149,28 +161,41 @@ export default {
149 }; 161 };
150 }, 162 },
151 created: async function () { 163 created: async function () {
152 const defaults = jsyaml.load(defaultConfig); 164 this.buildDashboard();
153 let config; 165 window.onhashchange = this.buildDashboard;
154 try {
155 config = await this.getConfig();
156 } catch (error) {
157 console.log(error);
158 config = this.handleErrors("⚠️ Error loading configuration", error);
159 }
160 this.config = merge(defaults, config);
161 this.services = this.config.services;
162 document.title =
163 this.config.documentTitle ||
164 `${this.config.title} | ${this.config.subtitle}`;
165 if (this.config.stylesheet) {
166 let stylesheet = "";
167 for (const file of this.config.stylesheet) {
168 stylesheet += `@import "${file}";`;
169 }
170 this.createStylesheet(stylesheet);
171 }
172 }, 166 },
173 methods: { 167 methods: {
168 buildDashboard: async function () {
169 const defaults = jsyaml.load(defaultConfig);
170 let config;
171 try {
172 config = await this.getConfig();
173 const path =
174 window.location.hash.substring(1) != ""
175 ? window.location.hash.substring(1)
176 : null;
177
178 if (path) {
179 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
180 config = Object.assign(config, pathConfig);
181 }
182 } catch (error) {
183 console.log(error);
184 config = this.handleErrors("⚠️ Error loading configuration", error);
185 }
186 this.config = merge(defaults, config);
187 this.services = this.config.services;
188 document.title =
189 this.config.documentTitle ||
190 `${this.config.title} | ${this.config.subtitle}`;
191 if (this.config.stylesheet) {
192 let stylesheet = "";
193 for (const file of this.config.stylesheet) {
194 stylesheet += `@import "${file}";`;
195 }
196 this.createStylesheet(stylesheet);
197 }
198 },
174 getConfig: function (path = "assets/config.yml") { 199 getConfig: function (path = "assets/config.yml") {
175 return fetch(path).then((response) => { 200 return fetch(path).then((response) => {
176 if (response.redirected) { 201 if (response.redirected) {