6 `theme-${config.theme}`,
7 isDark ? 'is-dark' : 'is-light',
8 !config.footer ? 'no-footer' : '',
11 <DynamicTheme :themes="config.colors" />
13 <section v-if="config.header" class="first-line">
14 <div v-cloak class="container">
16 <a href="#"><img v-if="config.logo" :src="config.logo" alt="dashboard logo" /></a>
17 <i v-if="config.icon" :class="config.icon"></i>
19 <div class="dashboard-title">
20 <span class="headline">{{ config.subtitle }}</span>
21 <h1>{{ config.title }}</h1>
29 @navbar-toggle="showMenu = !showMenu"
31 <DarkMode @updated="isDark = $event" />
34 @updated="vlayout = $event"
41 class="navbar-item is-inline-block-mobile"
42 @input="filterServices"
43 @search-focus="showMenu = true"
44 @search-open="navigateToFirstService"
45 @search-cancel="filterServices"
50 <section id="main-section" class="section">
51 <div v-cloak class="container">
53 v-if="config.connectivityCheck"
54 @network-status-update="offline = $event"
57 <!-- Optional messages -->
58 <Message :item="config.message" />
60 <!-- Horizontal layout -->
61 <div v-if="!vlayout || filter" class="columns is-multiline">
62 <template v-for="group in services">
63 <h2 v-if="group.name" class="column is-full group-title">
64 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
68 v-for="(item, index) in group.items"
71 :class="['column', `is-${12 / config.columns}`]"
76 <!-- Vertical layout -->
78 v-if="!filter && vlayout"
79 class="columns is-multiline layout-vertical"
82 :class="['column', `is-${12 / config.columns}`]"
83 v-for="group in services"
86 <h2 v-if="group.name" class="group-title">
87 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
91 v-for="(item, index) in group.items"
101 <footer class="footer">
102 <div class="container">
104 class="content has-text-centered"
106 v-html="config.footer"
114 const jsyaml = require("js-yaml");
115 const merge = require("lodash.merge");
117 import Navbar from "./components/Navbar.vue";
118 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
119 import Service from "./components/Service.vue";
120 import Message from "./components/Message.vue";
121 import SearchInput from "./components/SearchInput.vue";
122 import SettingToggle from "./components/SettingToggle.vue";
123 import DarkMode from "./components/DarkMode.vue";
124 import DynamicTheme from "./components/DynamicTheme.vue";
126 import defaultConfig from "./assets/defaults.yml";
151 created: async function () {
152 const defaults = jsyaml.load(defaultConfig);
154 window.onhashchange = function() { location.reload(); };
156 config = await this.getConfig();
157 const path = (window.location.hash.substring(1) != '') ? window.location.hash.substring(1) : null;
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];
162 // config = await this.getConfig(path ? `assets/${path}.yml` : null);
163 //config = await (path ? this.getConfig(`assets/${path}.yml`) : this.getConfig())
166 config = this.handleErrors("⚠️ Error loading configuration", error);
168 this.config = merge(defaults, config);
169 this.services = this.config.services;
171 this.config.documentTitle ||
172 `${this.config.title} | ${this.config.subtitle}`;
173 if (this.config.stylesheet) {
175 for (const file of this.config.stylesheet) {
176 stylesheet += `@import "${file}";`;
178 this.createStylesheet(stylesheet);
182 getConfig: function (path = "assets/config.yml") {
183 return fetch(path).then((response) => {
184 if (response.redirected) {
185 // This allows to work with authentication proxies.
186 window.location.href = response.url;
190 throw Error(`${response.statusText}: ${response.body}`);
197 return jsyaml.load(body);
199 .then(function (config) {
200 if (config.externalConfig) {
201 return that.getConfig(config.externalConfig);
207 matchesFilter: function (item) {
209 item.name.toLowerCase().includes(this.filter) ||
210 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
211 (item.tag && item.tag.toLowerCase().includes(this.filter))
214 navigateToFirstService: function (target) {
216 const service = this.services[0].items[0];
217 window.open(service.url, target || service.target || "_self");
219 console.warning("fail to open service");
222 filterServices: function (filter) {
223 this.filter = filter;
226 this.services = this.config.services;
230 const searchResultItems = [];
231 for (const group of this.config.services) {
232 for (const item of group.items) {
233 if (this.matchesFilter(item)) {
234 searchResultItems.push(item);
242 icon: "fas fa-search",
243 items: searchResultItems,
247 handleErrors: function (title, content) {
256 createStylesheet: function (css) {
257 let style = document.createElement("style");
258 style.appendChild(document.createTextNode(css));
259 document.head.appendChild(style);