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"
78 :class="['column', `is-${12 / config.columns}`]"
83 <!-- Vertical layout -->
85 v-if="!filter && vlayout"
86 class="columns is-multiline layout-vertical"
89 :class="['column', `is-${12 / config.columns}`]"
90 v-for="group in services"
93 <h2 v-if="group.name" class="group-title">
94 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
95 <div v-else-if="group.logo" class="group-logo media-left">
96 <figure class="image is-48x48">
97 <img :src="group.logo" :alt="`${group.name} logo`" />
103 v-for="(item, index) in group.items"
113 <footer class="footer">
114 <div class="container">
116 class="content has-text-centered"
118 v-html="config.footer"
126 const jsyaml = require("js-yaml");
127 const merge = require("lodash.merge");
129 import Navbar from "./components/Navbar.vue";
130 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
131 import Service from "./components/Service.vue";
132 import Message from "./components/Message.vue";
133 import SearchInput from "./components/SearchInput.vue";
134 import SettingToggle from "./components/SettingToggle.vue";
135 import DarkMode from "./components/DarkMode.vue";
136 import DynamicTheme from "./components/DynamicTheme.vue";
138 import defaultConfig from "./assets/defaults.yml";
163 created: async function () {
164 this.buildDashboard();
165 window.onhashchange = this.buildDashboard;
168 buildDashboard: async function () {
169 const defaults = jsyaml.load(defaultConfig);
172 config = await this.getConfig();
174 window.location.hash.substring(1) != ""
175 ? window.location.hash.substring(1)
179 let pathConfig = await this.getConfig(`assets/${path}.yml`); // the slash (/) is included in the pathname
180 config = Object.assign(config, pathConfig);
184 config = this.handleErrors("⚠️ Error loading configuration", error);
186 this.config = merge(defaults, config);
187 this.services = this.config.services;
189 this.config.documentTitle ||
190 `${this.config.title} | ${this.config.subtitle}`;
191 if (this.config.stylesheet) {
193 for (const file of this.config.stylesheet) {
194 stylesheet += `@import "${file}";`;
196 this.createStylesheet(stylesheet);
199 getConfig: function (path = "assets/config.yml") {
200 return fetch(path).then((response) => {
201 if (response.redirected) {
202 // This allows to work with authentication proxies.
203 window.location.href = response.url;
207 throw Error(`${response.statusText}: ${response.body}`);
214 return jsyaml.load(body);
216 .then(function (config) {
217 if (config.externalConfig) {
218 return that.getConfig(config.externalConfig);
224 matchesFilter: function (item) {
226 item.name.toLowerCase().includes(this.filter) ||
227 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
228 (item.tag && item.tag.toLowerCase().includes(this.filter))
231 navigateToFirstService: function (target) {
233 const service = this.services[0].items[0];
234 window.open(service.url, target || service.target || "_self");
236 console.warning("fail to open service");
239 filterServices: function (filter) {
240 this.filter = filter;
243 this.services = this.config.services;
247 const searchResultItems = [];
248 for (const group of this.config.services) {
249 for (const item of group.items) {
250 if (this.matchesFilter(item)) {
251 searchResultItems.push(item);
259 icon: "fas fa-search",
260 items: searchResultItems,
264 handleErrors: function (title, content) {
273 createStylesheet: function (css) {
274 let style = document.createElement("style");
275 style.appendChild(document.createTextNode(css));
276 document.head.appendChild(style);