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"
34 @updated="isDark = $event"
35 :defaultValue="this.config.defaults.colorTheme"
39 @updated="vlayout = $event"
43 :defaultValue="this.config.defaults.layout == 'columns'"
47 class="navbar-item is-inline-block-mobile"
48 :hotkey="searchHotkey()"
49 @input="filterServices"
50 @search-focus="showMenu = true"
51 @search-open="navigateToFirstService"
52 @search-cancel="filterServices"
57 <section id="main-section" class="section">
58 <div v-cloak class="container">
60 v-if="config.connectivityCheck"
61 @network-status-update="offline = $event"
64 <GetStarted v-if="loaded && !services" />
67 <!-- Optional messages -->
68 <Message :item="config.message" />
70 <!-- Horizontal layout -->
71 <div v-if="!vlayout || filter" class="columns is-multiline">
72 <template v-for="group in services">
73 <h2 v-if="group.name" class="column is-full group-title">
74 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
75 <div v-else-if="group.logo" class="group-logo media-left">
76 <figure class="image is-48x48">
77 <img :src="group.logo" :alt="`${group.name} logo`" />
83 v-for="(item, index) in group.items"
87 :class="['column', `is-${12 / config.columns}`]"
92 <!-- Vertical layout -->
94 v-if="!filter && vlayout"
95 class="columns is-multiline layout-vertical"
98 :class="['column', `is-${12 / config.columns}`]"
99 v-for="group in services"
102 <h2 v-if="group.name" class="group-title">
103 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
104 <div v-else-if="group.logo" class="group-logo media-left">
105 <figure class="image is-48x48">
106 <img :src="group.logo" :alt="`${group.name} logo`" />
112 v-for="(item, index) in group.items"
115 :proxy="config.proxy"
123 <footer class="footer">
124 <div class="container">
126 class="content has-text-centered"
128 v-html="config.footer"
136 const jsyaml = require("js-yaml");
137 const merge = require("lodash.merge");
139 import Navbar from "./components/Navbar.vue";
140 import GetStarted from "./components/GetStarted.vue";
141 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
142 import Service from "./components/Service.vue";
143 import Message from "./components/Message.vue";
144 import SearchInput from "./components/SearchInput.vue";
145 import SettingToggle from "./components/SettingToggle.vue";
146 import DarkMode from "./components/DarkMode.vue";
147 import DynamicTheme from "./components/DynamicTheme.vue";
149 import defaultConfig from "./assets/defaults.yml";
176 created: async function () {
177 this.buildDashboard();
178 window.onhashchange = this.buildDashboard;
183 if (this.config.hotkey && this.config.hotkey.search) {
184 return this.config.hotkey.search;
187 buildDashboard: async function () {
188 const defaults = jsyaml.load(defaultConfig);
191 config = await this.getConfig();
193 window.location.hash.substring(1) != ""
194 ? window.location.hash.substring(1)
198 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
199 config = Object.assign(config, pathConfig);
203 config = this.handleErrors("⚠️ Error loading configuration", error);
205 this.config = merge(defaults, config);
206 this.services = this.config.services;
209 this.config.documentTitle ||
210 `${this.config.title} | ${this.config.subtitle}`;
211 if (this.config.stylesheet) {
213 for (const file of this.config.stylesheet) {
214 stylesheet += `@import "${file}";`;
216 this.createStylesheet(stylesheet);
219 getConfig: function (path = "assets/config.yml") {
220 return fetch(path).then((response) => {
221 if (response.redirected) {
222 // This allows to work with authentication proxies.
223 window.location.href = response.url;
228 throw Error(`${response.statusText}: ${response.body}`);
235 return jsyaml.load(body);
237 .then(function (config) {
238 if (config.externalConfig) {
239 return that.getConfig(config.externalConfig);
245 matchesFilter: function (item) {
247 item.name.toLowerCase().includes(this.filter) ||
248 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
249 (item.tag && item.tag.toLowerCase().includes(this.filter))
252 navigateToFirstService: function (target) {
254 const service = this.services[0].items[0];
255 window.open(service.url, target || service.target || "_self");
257 console.warning("fail to open service");
260 filterServices: function (filter) {
261 this.filter = filter;
264 this.services = this.config.services;
268 const searchResultItems = [];
269 for (const group of this.config.services) {
270 for (const item of group.items) {
271 if (this.matchesFilter(item)) {
272 searchResultItems.push(item);
280 icon: "fas fa-search",
281 items: searchResultItems,
285 handleErrors: function (title, content) {
294 createStylesheet: function (css) {
295 let style = document.createElement("style");
296 style.appendChild(document.createTextNode(css));
297 document.head.appendChild(style);