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>
70 v-for="(item, index) in group.items"
73 :class="['column', `is-${12 / config.columns}`]"
78 <!-- Vertical layout -->
80 v-if="!filter && vlayout"
81 class="columns is-multiline layout-vertical"
84 :class="['column', `is-${12 / config.columns}`]"
85 v-for="group in services"
88 <h2 v-if="group.name" class="group-title">
89 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
93 v-for="(item, index) in group.items"
103 <footer class="footer">
104 <div class="container">
106 class="content has-text-centered"
108 v-html="config.footer"
116 const jsyaml = require("js-yaml");
117 const merge = require("lodash.merge");
119 import Navbar from "./components/Navbar.vue";
120 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
121 import Service from "./components/Service.vue";
122 import Message from "./components/Message.vue";
123 import SearchInput from "./components/SearchInput.vue";
124 import SettingToggle from "./components/SettingToggle.vue";
125 import DarkMode from "./components/DarkMode.vue";
126 import DynamicTheme from "./components/DynamicTheme.vue";
128 import defaultConfig from "./assets/defaults.yml";
153 created: async function () {
154 this.buildDashboard();
155 window.onhashchange = this.buildDashboard;
158 buildDashboard: async function () {
159 const defaults = jsyaml.load(defaultConfig);
162 config = await this.getConfig();
164 window.location.hash.substring(1) != ""
165 ? window.location.hash.substring(1)
169 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
170 config = Object.assign(config, pathConfig);
174 config = this.handleErrors("⚠️ Error loading configuration", error);
176 this.config = merge(defaults, config);
177 this.services = this.config.services;
179 this.config.documentTitle ||
180 `${this.config.title} | ${this.config.subtitle}`;
181 if (this.config.stylesheet) {
183 for (const file of this.config.stylesheet) {
184 stylesheet += `@import "${file}";`;
186 this.createStylesheet(stylesheet);
189 getConfig: function (path = "assets/config.yml") {
190 return fetch(path).then((response) => {
191 if (response.redirected) {
192 // This allows to work with authentication proxies.
193 window.location.href = response.url;
197 throw Error(`${response.statusText}: ${response.body}`);
204 return jsyaml.load(body);
206 .then(function (config) {
207 if (config.externalConfig) {
208 return that.getConfig(config.externalConfig);
214 matchesFilter: function (item) {
216 item.name.toLowerCase().includes(this.filter) ||
217 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
218 (item.tag && item.tag.toLowerCase().includes(this.filter))
221 navigateToFirstService: function (target) {
223 const service = this.services[0].items[0];
224 window.open(service.url, target || service.target || "_self");
226 console.warning("fail to open service");
229 filterServices: function (filter) {
230 this.filter = filter;
233 this.services = this.config.services;
237 const searchResultItems = [];
238 for (const group of this.config.services) {
239 for (const item of group.items) {
240 if (this.matchesFilter(item)) {
241 searchResultItems.push(item);
249 icon: "fas fa-search",
250 items: searchResultItems,
254 handleErrors: function (title, content) {
263 createStylesheet: function (css) {
264 let style = document.createElement("style");
265 style.appendChild(document.createTextNode(css));
266 document.head.appendChild(style);