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 <!-- 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"
80 :class="['column', `is-${12 / config.columns}`]"
85 <!-- Vertical layout -->
87 v-if="!filter && vlayout"
88 class="columns is-multiline layout-vertical"
91 :class="['column', `is-${12 / config.columns}`]"
92 v-for="group in services"
95 <h2 v-if="group.name" class="group-title">
96 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
97 <div v-else-if="group.logo" class="group-logo media-left">
98 <figure class="image is-48x48">
99 <img :src="group.logo" :alt="`${group.name} logo`" />
105 v-for="(item, index) in group.items"
108 :proxy="config.proxy"
116 <footer class="footer">
117 <div class="container">
119 class="content has-text-centered"
121 v-html="config.footer"
129 const jsyaml = require("js-yaml");
130 const merge = require("lodash.merge");
132 import Navbar from "./components/Navbar.vue";
133 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
134 import Service from "./components/Service.vue";
135 import Message from "./components/Message.vue";
136 import SearchInput from "./components/SearchInput.vue";
137 import SettingToggle from "./components/SettingToggle.vue";
138 import DarkMode from "./components/DarkMode.vue";
139 import DynamicTheme from "./components/DynamicTheme.vue";
141 import defaultConfig from "./assets/defaults.yml";
166 created: async function () {
167 this.buildDashboard();
168 window.onhashchange = this.buildDashboard;
172 if (this.config.hotkey && this.config.hotkey.search) {
173 return this.config.hotkey.search;
176 buildDashboard: async function () {
177 const defaults = jsyaml.load(defaultConfig);
180 config = await this.getConfig();
182 window.location.hash.substring(1) != ""
183 ? window.location.hash.substring(1)
187 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
188 config = Object.assign(config, pathConfig);
192 config = this.handleErrors("⚠️ Error loading configuration", error);
194 this.config = merge(defaults, config);
195 this.services = this.config.services;
197 this.config.documentTitle ||
198 `${this.config.title} | ${this.config.subtitle}`;
199 if (this.config.stylesheet) {
201 for (const file of this.config.stylesheet) {
202 stylesheet += `@import "${file}";`;
204 this.createStylesheet(stylesheet);
207 getConfig: function (path = "assets/config.yml") {
208 return fetch(path).then((response) => {
209 if (response.redirected) {
210 // This allows to work with authentication proxies.
211 window.location.href = response.url;
215 throw Error(`${response.statusText}: ${response.body}`);
222 return jsyaml.load(body);
224 .then(function (config) {
225 if (config.externalConfig) {
226 return that.getConfig(config.externalConfig);
232 matchesFilter: function (item) {
234 item.name.toLowerCase().includes(this.filter) ||
235 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
236 (item.tag && item.tag.toLowerCase().includes(this.filter))
239 navigateToFirstService: function (target) {
241 const service = this.services[0].items[0];
242 window.open(service.url, target || service.target || "_self");
244 console.warning("fail to open service");
247 filterServices: function (filter) {
248 this.filter = filter;
251 this.services = this.config.services;
255 const searchResultItems = [];
256 for (const group of this.config.services) {
257 for (const item of group.items) {
258 if (this.matchesFilter(item)) {
259 searchResultItems.push(item);
267 icon: "fas fa-search",
268 items: searchResultItems,
272 handleErrors: function (title, content) {
281 createStylesheet: function (css) {
282 let style = document.createElement("style");
283 style.appendChild(document.createTextNode(css));
284 document.head.appendChild(style);