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">
17 <img v-if="config.logo" :src="config.logo" alt="dashboard logo" />
19 <i v-if="config.icon" :class="config.icon"></i>
21 <div class="dashboard-title">
22 <span class="headline">{{ config.subtitle }}</span>
23 <h1>{{ config.title }}</h1>
31 @navbar-toggle="showMenu = !showMenu"
33 <DarkMode @updated="isDark = $event" />
36 @updated="vlayout = $event"
43 class="navbar-item is-inline-block-mobile"
44 :hotkey="config.hotkey"
45 @input="filterServices"
46 @search-focus="showMenu = true"
47 @search-open="navigateToFirstService"
48 @search-cancel="filterServices"
53 <section id="main-section" class="section">
54 <div v-cloak class="container">
56 v-if="config.connectivityCheck"
57 @network-status-update="offline = $event"
60 <!-- Optional messages -->
61 <Message :item="config.message" />
63 <!-- Horizontal layout -->
64 <div v-if="!vlayout || filter" class="columns is-multiline">
65 <template v-for="group in services">
66 <h2 v-if="group.name" class="column is-full group-title">
67 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
68 <div v-else-if="group.logo" class="group-logo media-left">
69 <figure class="image is-48x48">
70 <img :src="group.logo" :alt="`${group.name} logo`" />
76 v-for="(item, index) in group.items"
79 :class="['column', `is-${12 / config.columns}`]"
84 <!-- Vertical layout -->
86 v-if="!filter && vlayout"
87 class="columns is-multiline layout-vertical"
90 :class="['column', `is-${12 / config.columns}`]"
91 v-for="group in services"
94 <h2 v-if="group.name" class="group-title">
95 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
96 <div v-else-if="group.logo" class="group-logo media-left">
97 <figure class="image is-48x48">
98 <img :src="group.logo" :alt="`${group.name} logo`" />
104 v-for="(item, index) in group.items"
114 <footer class="footer">
115 <div class="container">
117 class="content has-text-centered"
119 v-html="config.footer"
127 const jsyaml = require("js-yaml");
128 const merge = require("lodash.merge");
130 import Navbar from "./components/Navbar.vue";
131 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
132 import Service from "./components/Service.vue";
133 import Message from "./components/Message.vue";
134 import SearchInput from "./components/SearchInput.vue";
135 import SettingToggle from "./components/SettingToggle.vue";
136 import DarkMode from "./components/DarkMode.vue";
137 import DynamicTheme from "./components/DynamicTheme.vue";
139 import defaultConfig from "./assets/defaults.yml";
164 created: async function () {
165 this.buildDashboard();
166 window.onhashchange = this.buildDashboard;
169 buildDashboard: async function () {
170 const defaults = jsyaml.load(defaultConfig);
173 config = await this.getConfig();
175 window.location.hash.substring(1) != ""
176 ? window.location.hash.substring(1)
180 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
181 config = Object.assign(config, pathConfig);
185 config = this.handleErrors("⚠️ Error loading configuration", error);
187 this.config = merge(defaults, config);
188 this.services = this.config.services;
190 this.config.documentTitle ||
191 `${this.config.title} | ${this.config.subtitle}`;
192 if (this.config.stylesheet) {
194 for (const file of this.config.stylesheet) {
195 stylesheet += `@import "${file}";`;
197 this.createStylesheet(stylesheet);
200 getConfig: function (path = "assets/config.yml") {
201 return fetch(path).then((response) => {
202 if (response.redirected) {
203 // This allows to work with authentication proxies.
204 window.location.href = response.url;
208 throw Error(`${response.statusText}: ${response.body}`);
215 return jsyaml.load(body);
217 .then(function (config) {
218 if (config.externalConfig) {
219 return that.getConfig(config.externalConfig);
225 matchesFilter: function (item) {
227 item.name.toLowerCase().includes(this.filter) ||
228 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
229 (item.tag && item.tag.toLowerCase().includes(this.filter))
232 navigateToFirstService: function (target) {
234 const service = this.services[0].items[0];
235 window.open(service.url, target || service.target || "_self");
237 console.warning("fail to open service");
240 filterServices: function (filter) {
241 this.filter = filter;
244 this.services = this.config.services;
248 const searchResultItems = [];
249 for (const group of this.config.services) {
250 for (const item of group.items) {
251 if (this.matchesFilter(item)) {
252 searchResultItems.push(item);
260 icon: "fas fa-search",
261 items: searchResultItems,
265 handleErrors: function (title, content) {
274 createStylesheet: function (css) {
275 let style = document.createElement("style");
276 style.appendChild(document.createTextNode(css));
277 document.head.appendChild(style);