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 :forwarder="config.forwarder"
88 :class="['column', `is-${12 / config.columns}`]"
93 <!-- Vertical layout -->
95 v-if="!filter && vlayout"
96 class="columns is-multiline layout-vertical"
99 :class="['column', `is-${12 / config.columns}`]"
100 v-for="group in services"
103 <h2 v-if="group.name" class="group-title">
104 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
105 <div v-else-if="group.logo" class="group-logo media-left">
106 <figure class="image is-48x48">
107 <img :src="group.logo" :alt="`${group.name} logo`" />
113 v-for="(item, index) in group.items"
116 :proxy="config.proxy"
117 :forwarder="config.forwarder"
125 <footer class="footer">
126 <div class="container">
128 class="content has-text-centered"
130 v-html="config.footer"
138 const jsyaml = require("js-yaml");
139 const merge = require("lodash.merge");
141 import Navbar from "./components/Navbar.vue";
142 import GetStarted from "./components/GetStarted.vue";
143 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
144 import Service from "./components/Service.vue";
145 import Message from "./components/Message.vue";
146 import SearchInput from "./components/SearchInput.vue";
147 import SettingToggle from "./components/SettingToggle.vue";
148 import DarkMode from "./components/DarkMode.vue";
149 import DynamicTheme from "./components/DynamicTheme.vue";
151 import defaultConfig from "./assets/defaults.yml";
178 created: async function () {
179 this.buildDashboard();
180 window.onhashchange = this.buildDashboard;
185 if (this.config.hotkey && this.config.hotkey.search) {
186 return this.config.hotkey.search;
189 buildDashboard: async function () {
190 const defaults = jsyaml.load(defaultConfig);
193 config = await this.getConfig();
195 window.location.hash.substring(1) != ""
196 ? window.location.hash.substring(1)
200 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
201 config = Object.assign(config, pathConfig);
205 config = this.handleErrors("⚠️ Error loading configuration", error);
207 this.config = merge(defaults, config);
208 this.services = this.config.services;
211 this.config.documentTitle ||
212 `${this.config.title} | ${this.config.subtitle}`;
213 if (this.config.stylesheet) {
215 for (const file of this.config.stylesheet) {
216 stylesheet += `@import "${file}";`;
218 this.createStylesheet(stylesheet);
221 getConfig: function (path = "assets/config.yml") {
222 return fetch(path).then((response) => {
223 if (response.redirected) {
224 // This allows to work with authentication proxies.
225 window.location.href = response.url;
230 throw Error(`${response.statusText}: ${response.body}`);
237 return jsyaml.load(body);
239 .then(function (config) {
240 if (config.externalConfig) {
241 return that.getConfig(config.externalConfig);
247 matchesFilter: function (item) {
249 item.name.toLowerCase().includes(this.filter) ||
250 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
251 (item.tag && item.tag.toLowerCase().includes(this.filter))
254 navigateToFirstService: function (target) {
256 const service = this.services[0].items[0];
257 window.open(service.url, target || service.target || "_self");
259 console.warning("fail to open service");
262 filterServices: function (filter) {
263 this.filter = filter;
266 this.services = this.config.services;
270 const searchResultItems = [];
271 for (const group of this.config.services) {
272 for (const item of group.items) {
273 if (this.matchesFilter(item)) {
274 searchResultItems.push(item);
282 icon: "fas fa-search",
283 items: searchResultItems,
287 handleErrors: function (title, content) {
296 createStylesheet: function (css) {
297 let style = document.createElement("style");
298 style.appendChild(document.createTextNode(css));
299 document.head.appendChild(style);