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, groupIndex) in services">
75 class="column is-full group-title"
76 :key="`header-${groupIndex}`"
78 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
79 <div v-else-if="group.logo" class="group-logo media-left">
80 <figure class="image is-48x48">
81 <img :src="group.logo" :alt="`${group.name} logo`" />
87 v-for="(item, index) in group.items"
88 :key="`service-${groupIndex}-${index}`"
91 :class="['column', `is-${12 / config.columns}`]"
96 <!-- Vertical layout -->
98 v-if="!filter && vlayout"
99 class="columns is-multiline layout-vertical"
102 :class="['column', `is-${12 / config.columns}`]"
103 v-for="(group, groupIndex) in services"
106 <h2 v-if="group.name" class="group-title">
107 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
108 <div v-else-if="group.logo" class="group-logo media-left">
109 <figure class="image is-48x48">
110 <img :src="group.logo" :alt="`${group.name} logo`" />
116 v-for="(item, index) in group.items"
119 :proxy="config.proxy"
127 <footer class="footer">
128 <div class="container">
130 class="content has-text-centered"
132 v-html="config.footer"
140 const jsyaml = require("js-yaml");
141 const merge = require("lodash.merge");
143 import Navbar from "./components/Navbar.vue";
144 import GetStarted from "./components/GetStarted.vue";
145 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
146 import Service from "./components/Service.vue";
147 import Message from "./components/Message.vue";
148 import SearchInput from "./components/SearchInput.vue";
149 import SettingToggle from "./components/SettingToggle.vue";
150 import DarkMode from "./components/DarkMode.vue";
151 import DynamicTheme from "./components/DynamicTheme.vue";
153 import defaultConfig from "./assets/defaults.yml";
180 created: async function () {
181 this.buildDashboard();
182 window.onhashchange = this.buildDashboard;
187 if (this.config.hotkey && this.config.hotkey.search) {
188 return this.config.hotkey.search;
191 buildDashboard: async function () {
192 const defaults = jsyaml.load(defaultConfig);
195 config = await this.getConfig();
197 window.location.hash.substring(1) != ""
198 ? window.location.hash.substring(1)
202 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
203 config = Object.assign(config, pathConfig);
207 config = this.handleErrors("⚠️ Error loading configuration", error);
209 this.config = merge(defaults, config);
210 this.services = this.config.services;
213 this.config.documentTitle ||
214 `${this.config.title} | ${this.config.subtitle}`;
215 if (this.config.stylesheet) {
217 for (const file of this.config.stylesheet) {
218 stylesheet += `@import "${file}";`;
220 this.createStylesheet(stylesheet);
223 getConfig: function (path = "assets/config.yml") {
224 return fetch(path).then((response) => {
225 if (response.redirected) {
226 // This allows to work with authentication proxies.
227 window.location.href = response.url;
232 throw Error(`${response.statusText}: ${response.body}`);
239 return jsyaml.load(body);
241 .then(function (config) {
242 if (config.externalConfig) {
243 return that.getConfig(config.externalConfig);
249 matchesFilter: function (item) {
251 item.name.toLowerCase().includes(this.filter) ||
252 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
253 (item.tag && item.tag.toLowerCase().includes(this.filter))
256 navigateToFirstService: function (target) {
258 const service = this.services[0].items[0];
259 window.open(service.url, target || service.target || "_self");
261 console.warning("fail to open service");
264 filterServices: function (filter) {
265 this.filter = filter;
268 this.services = this.config.services;
272 const searchResultItems = [];
273 for (const group of this.config.services) {
274 for (const item of group.items) {
275 if (this.matchesFilter(item)) {
276 searchResultItems.push(item);
284 icon: "fas fa-search",
285 items: searchResultItems,
289 handleErrors: function (title, content) {
298 createStylesheet: function (css) {
299 let style = document.createElement("style");
300 style.appendChild(document.createTextNode(css));
301 document.head.appendChild(style);