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="searchHotkey()"
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 <GetStarted v-if="loaded && !services" />
63 <!-- Optional messages -->
64 <Message :item="config.message" />
66 <!-- Horizontal layout -->
67 <div v-if="!vlayout || filter" class="columns is-multiline">
68 <template v-for="group in services">
69 <h2 v-if="group.name" class="column is-full group-title">
70 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
71 <div v-else-if="group.logo" class="group-logo media-left">
72 <figure class="image is-48x48">
73 <img :src="group.logo" :alt="`${group.name} logo`" />
79 v-for="(item, index) in group.items"
83 :class="['column', `is-${12 / config.columns}`]"
88 <!-- Vertical layout -->
90 v-if="!filter && vlayout"
91 class="columns is-multiline layout-vertical"
94 :class="['column', `is-${12 / config.columns}`]"
95 v-for="group in services"
98 <h2 v-if="group.name" class="group-title">
99 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
100 <div v-else-if="group.logo" class="group-logo media-left">
101 <figure class="image is-48x48">
102 <img :src="group.logo" :alt="`${group.name} logo`" />
108 v-for="(item, index) in group.items"
111 :proxy="config.proxy"
119 <footer class="footer">
120 <div class="container">
122 class="content has-text-centered"
124 v-html="config.footer"
132 const jsyaml = require("js-yaml");
133 const merge = require("lodash.merge");
135 import Navbar from "./components/Navbar.vue";
136 import GetStarted from "./components/GetStarted.vue";
137 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
138 import Service from "./components/Service.vue";
139 import Message from "./components/Message.vue";
140 import SearchInput from "./components/SearchInput.vue";
141 import SettingToggle from "./components/SettingToggle.vue";
142 import DarkMode from "./components/DarkMode.vue";
143 import DynamicTheme from "./components/DynamicTheme.vue";
145 import defaultConfig from "./assets/defaults.yml";
172 created: async function () {
173 this.buildDashboard();
174 window.onhashchange = this.buildDashboard;
179 if (this.config.hotkey && this.config.hotkey.search) {
180 return this.config.hotkey.search;
183 buildDashboard: async function () {
184 const defaults = jsyaml.load(defaultConfig);
187 config = await this.getConfig();
189 window.location.hash.substring(1) != ""
190 ? window.location.hash.substring(1)
194 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
195 config = Object.assign(config, pathConfig);
199 config = this.handleErrors("⚠️ Error loading configuration", error);
201 this.config = merge(defaults, config);
202 this.services = this.config.services;
205 this.config.documentTitle ||
206 `${this.config.title} | ${this.config.subtitle}`;
207 if (this.config.stylesheet) {
209 for (const file of this.config.stylesheet) {
210 stylesheet += `@import "${file}";`;
212 this.createStylesheet(stylesheet);
215 getConfig: function (path = "assets/config.yml") {
216 return fetch(path).then((response) => {
217 if (response.redirected) {
218 // This allows to work with authentication proxies.
219 window.location.href = response.url;
224 throw Error(`${response.statusText}: ${response.body}`);
231 return jsyaml.load(body);
233 .then(function (config) {
234 if (config.externalConfig) {
235 return that.getConfig(config.externalConfig);
241 matchesFilter: function (item) {
243 item.name.toLowerCase().includes(this.filter) ||
244 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
245 (item.tag && item.tag.toLowerCase().includes(this.filter))
248 navigateToFirstService: function (target) {
250 const service = this.services[0].items[0];
251 window.open(service.url, target || service.target || "_self");
253 console.warning("fail to open service");
256 filterServices: function (filter) {
257 this.filter = filter;
260 this.services = this.config.services;
264 const searchResultItems = [];
265 for (const group of this.config.services) {
266 for (const item of group.items) {
267 if (this.matchesFilter(item)) {
268 searchResultItems.push(item);
276 icon: "fas fa-search",
277 items: searchResultItems,
281 handleErrors: function (title, content) {
290 createStylesheet: function (css) {
291 let style = document.createElement("style");
292 style.appendChild(document.createTextNode(css));
293 document.head.appendChild(style);