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}`">
77 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
78 <div v-else-if="group.logo" class="group-logo media-left">
79 <figure class="image is-48x48">
80 <img :src="group.logo" :alt="`${group.name} logo`" />
86 v-for="(item, index) in group.items"
87 :key="`service-${groupIndex}-${index}`"
90 :class="['column', `is-${12 / config.columns}`]"
95 <!-- Vertical layout -->
97 v-if="!filter && vlayout"
98 class="columns is-multiline layout-vertical"
101 :class="['column', `is-${12 / config.columns}`]"
102 v-for="(group, groupIndex) in services"
105 <h2 v-if="group.name" class="group-title">
106 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
107 <div v-else-if="group.logo" class="group-logo media-left">
108 <figure class="image is-48x48">
109 <img :src="group.logo" :alt="`${group.name} logo`" />
115 v-for="(item, index) in group.items"
118 :proxy="config.proxy"
126 <footer class="footer">
127 <div class="container">
129 class="content has-text-centered"
131 v-html="config.footer"
139 const jsyaml = require("js-yaml");
140 const merge = require("lodash.merge");
142 import Navbar from "./components/Navbar.vue";
143 import GetStarted from "./components/GetStarted.vue";
144 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
145 import Service from "./components/Service.vue";
146 import Message from "./components/Message.vue";
147 import SearchInput from "./components/SearchInput.vue";
148 import SettingToggle from "./components/SettingToggle.vue";
149 import DarkMode from "./components/DarkMode.vue";
150 import DynamicTheme from "./components/DynamicTheme.vue";
152 import defaultConfig from "./assets/defaults.yml";
179 created: async function () {
180 this.buildDashboard();
181 window.onhashchange = this.buildDashboard;
186 if (this.config.hotkey && this.config.hotkey.search) {
187 return this.config.hotkey.search;
190 buildDashboard: async function () {
191 const defaults = jsyaml.load(defaultConfig);
194 config = await this.getConfig();
196 window.location.hash.substring(1) != ""
197 ? window.location.hash.substring(1)
201 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
202 config = Object.assign(config, pathConfig);
206 config = this.handleErrors("⚠️ Error loading configuration", error);
208 this.config = merge(defaults, config);
209 this.services = this.config.services;
212 this.config.documentTitle ||
213 `${this.config.title} | ${this.config.subtitle}`;
214 if (this.config.stylesheet) {
216 for (const file of this.config.stylesheet) {
217 stylesheet += `@import "${file}";`;
219 this.createStylesheet(stylesheet);
222 getConfig: function (path = "assets/config.yml") {
223 return fetch(path).then((response) => {
224 if (response.redirected) {
225 // This allows to work with authentication proxies.
226 window.location.href = response.url;
231 throw Error(`${response.statusText}: ${response.body}`);
238 return jsyaml.load(body);
240 .then(function (config) {
241 if (config.externalConfig) {
242 return that.getConfig(config.externalConfig);
248 matchesFilter: function (item) {
250 item.name.toLowerCase().includes(this.filter) ||
251 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
252 (item.tag && item.tag.toLowerCase().includes(this.filter))
255 navigateToFirstService: function (target) {
257 const service = this.services[0].items[0];
258 window.open(service.url, target || service.target || "_self");
260 console.warning("fail to open service");
263 filterServices: function (filter) {
264 this.filter = filter;
267 this.services = this.config.services;
271 const searchResultItems = [];
272 for (const group of this.config.services) {
273 for (const item of group.items) {
274 if (this.matchesFilter(item)) {
275 searchResultItems.push(item);
283 icon: "fas fa-search",
284 items: searchResultItems,
288 handleErrors: function (title, content) {
297 createStylesheet: function (css) {
298 let style = document.createElement("style");
299 style.appendChild(document.createTextNode(css));
300 document.head.appendChild(style);