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 @input="filterServices"
49 @search-focus="showMenu = true"
50 @search-open="navigateToFirstService"
51 @search-cancel="filterServices"
56 <section id="main-section" class="section">
57 <div v-cloak class="container">
59 v-if="config.connectivityCheck"
60 @network-status-update="offline = $event"
63 <!-- Optional messages -->
64 <Message :item="config.message" />
66 <!-- Horizontal layout -->
67 <div v-if="!vlayout || filter" class="columns is-multiline">
68 <template v-for="group in services">
69 <h2 v-if="group.name" class="column is-full group-title">
70 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
71 <div v-else-if="group.logo" class="group-logo media-left">
72 <figure class="image is-48x48">
73 <img :src="group.logo" :alt="`${group.name} logo`" />
79 v-for="(item, index) in group.items"
83 :class="['column', `is-${12 / config.columns}`]"
88 <!-- Vertical layout -->
90 v-if="!filter && vlayout"
91 class="columns is-multiline layout-vertical"
94 :class="['column', `is-${12 / config.columns}`]"
95 v-for="group in services"
98 <h2 v-if="group.name" class="group-title">
99 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
100 <div v-else-if="group.logo" class="group-logo media-left">
101 <figure class="image is-48x48">
102 <img :src="group.logo" :alt="`${group.name} logo`" />
108 v-for="(item, index) in group.items"
111 :proxy="config.proxy"
119 <footer class="footer">
120 <div class="container">
122 class="content has-text-centered"
124 v-html="config.footer"
132 const jsyaml = require("js-yaml");
133 const merge = require("lodash.merge");
135 import Navbar from "./components/Navbar.vue";
136 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
137 import Service from "./components/Service.vue";
138 import Message from "./components/Message.vue";
139 import SearchInput from "./components/SearchInput.vue";
140 import SettingToggle from "./components/SettingToggle.vue";
141 import DarkMode from "./components/DarkMode.vue";
142 import DynamicTheme from "./components/DynamicTheme.vue";
144 import defaultConfig from "./assets/defaults.yml";
169 created: async function () {
170 this.buildDashboard();
171 window.onhashchange = this.buildDashboard;
174 buildDashboard: async function () {
175 const defaults = jsyaml.load(defaultConfig);
178 config = await this.getConfig();
180 window.location.hash.substring(1) != ""
181 ? window.location.hash.substring(1)
185 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
186 config = Object.assign(config, pathConfig);
190 config = this.handleErrors("⚠️ Error loading configuration", error);
192 this.config = merge(defaults, config);
193 this.services = this.config.services;
195 this.config.documentTitle ||
196 `${this.config.title} | ${this.config.subtitle}`;
197 if (this.config.stylesheet) {
199 for (const file of this.config.stylesheet) {
200 stylesheet += `@import "${file}";`;
202 this.createStylesheet(stylesheet);
205 getConfig: function (path = "assets/config.yml") {
206 return fetch(path).then((response) => {
207 if (response.redirected) {
208 // This allows to work with authentication proxies.
209 window.location.href = response.url;
213 throw Error(`${response.statusText}: ${response.body}`);
220 return jsyaml.load(body);
222 .then(function (config) {
223 if (config.externalConfig) {
224 return that.getConfig(config.externalConfig);
230 matchesFilter: function (item) {
232 item.name.toLowerCase().includes(this.filter) ||
233 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
234 (item.tag && item.tag.toLowerCase().includes(this.filter))
237 navigateToFirstService: function (target) {
239 const service = this.services[0].items[0];
240 window.open(service.url, target || service.target || "_self");
242 console.warning("fail to open service");
245 filterServices: function (filter) {
246 this.filter = filter;
249 this.services = this.config.services;
253 const searchResultItems = [];
254 for (const group of this.config.services) {
255 for (const item of group.items) {
256 if (this.matchesFilter(item)) {
257 searchResultItems.push(item);
265 icon: "fas fa-search",
266 items: searchResultItems,
270 handleErrors: function (title, content) {
279 createStylesheet: function (css) {
280 let style = document.createElement("style");
281 style.appendChild(document.createTextNode(css));
282 document.head.appendChild(style);