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 @input="filterServices"
45 @search-focus="showMenu = true"
46 @search-open="navigateToFirstService"
47 @search-cancel="filterServices"
52 <section id="main-section" class="section">
53 <div v-cloak class="container">
55 v-if="config.connectivityCheck"
56 @network-status-update="offline = $event"
59 <!-- Optional messages -->
60 <Message :item="config.message" />
62 <!-- Horizontal layout -->
63 <div v-if="!vlayout || filter" class="columns is-multiline">
64 <template v-for="group in services">
65 <h2 v-if="group.name" class="column is-full group-title">
66 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
67 <div v-else-if="group.logo" class="group-logo media-left">
68 <figure class="image is-48x48">
69 <img :src="group.logo" :alt="`${group.name} logo`" />
75 v-for="(item, index) in group.items"
79 :class="['column', `is-${12 / config.columns}`]"
84 <!-- Vertical layout -->
86 v-if="!filter && vlayout"
87 class="columns is-multiline layout-vertical"
90 :class="['column', `is-${12 / config.columns}`]"
91 v-for="group in services"
94 <h2 v-if="group.name" class="group-title">
95 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
96 <div v-else-if="group.logo" class="group-logo media-left">
97 <figure class="image is-48x48">
98 <img :src="group.logo" :alt="`${group.name} logo`" />
104 v-for="(item, index) in group.items"
107 :proxy="config.proxy"
115 <footer class="footer">
116 <div class="container">
118 class="content has-text-centered"
120 v-html="config.footer"
128 const jsyaml = require("js-yaml");
129 const merge = require("lodash.merge");
131 import Navbar from "./components/Navbar.vue";
132 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
133 import Service from "./components/Service.vue";
134 import Message from "./components/Message.vue";
135 import SearchInput from "./components/SearchInput.vue";
136 import SettingToggle from "./components/SettingToggle.vue";
137 import DarkMode from "./components/DarkMode.vue";
138 import DynamicTheme from "./components/DynamicTheme.vue";
140 import defaultConfig from "./assets/defaults.yml";
165 created: async function () {
166 this.buildDashboard();
167 window.onhashchange = this.buildDashboard;
170 buildDashboard: async function () {
171 const defaults = jsyaml.load(defaultConfig);
174 config = await this.getConfig();
176 window.location.hash.substring(1) != ""
177 ? window.location.hash.substring(1)
181 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
182 config = Object.assign(config, pathConfig);
186 config = this.handleErrors("⚠️ Error loading configuration", error);
188 this.config = merge(defaults, config);
189 this.services = this.config.services;
191 this.config.documentTitle ||
192 `${this.config.title} | ${this.config.subtitle}`;
193 if (this.config.stylesheet) {
195 for (const file of this.config.stylesheet) {
196 stylesheet += `@import "${file}";`;
198 this.createStylesheet(stylesheet);
201 getConfig: function (path = "assets/config.yml") {
202 return fetch(path).then((response) => {
203 if (response.redirected) {
204 // This allows to work with authentication proxies.
205 window.location.href = response.url;
209 throw Error(`${response.statusText}: ${response.body}`);
216 return jsyaml.load(body);
218 .then(function (config) {
219 if (config.externalConfig) {
220 return that.getConfig(config.externalConfig);
226 matchesFilter: function (item) {
228 item.name.toLowerCase().includes(this.filter) ||
229 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
230 (item.tag && item.tag.toLowerCase().includes(this.filter))
233 navigateToFirstService: function (target) {
235 const service = this.services[0].items[0];
236 window.open(service.url, target || service.target || "_self");
238 console.warning("fail to open service");
241 filterServices: function (filter) {
242 this.filter = filter;
245 this.services = this.config.services;
249 const searchResultItems = [];
250 for (const group of this.config.services) {
251 for (const item of group.items) {
252 if (this.matchesFilter(item)) {
253 searchResultItems.push(item);
261 icon: "fas fa-search",
262 items: searchResultItems,
266 handleErrors: function (title, content) {
275 createStylesheet: function (css) {
276 let style = document.createElement("style");
277 style.appendChild(document.createTextNode(css));
278 document.head.appendChild(style);