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">
16 <img v-if="config.logo" :src="config.logo" alt="dashboard logo" />
17 <i v-if="config.icon" :class="config.icon"></i>
19 <div class="dashboard-title">
20 <span class="headline">{{ config.subtitle }}</span>
21 <h1>{{ config.title }}</h1>
29 @navbar-toggle="showMenu = !showMenu"
31 <DarkMode @updated="isDark = $event" />
34 @updated="vlayout = $event"
41 class="navbar-item is-inline-block-mobile"
42 @input="filterServices"
43 @search-focus="showMenu = true"
44 @search-open="navigateToFirstService"
45 @search-cancel="filterServices"
50 <section id="main-section" class="section">
51 <div v-cloak class="container">
53 v-if="config.connectivityCheck"
54 @network-status-update="offline = $event"
57 <!-- Optional messages -->
58 <Message :item="config.message" />
60 <!-- Horizontal layout -->
61 <div v-if="!vlayout || filter" class="columns is-multiline">
62 <template v-for="group in services">
63 <h2 v-if="group.name" class="column is-full group-title">
64 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
65 <div v-else-if="group.logo" class="group-logo media-left">
66 <figure class="image is-48x48">
67 <img :src="group.logo" :alt="`${group.name} logo`" />
73 v-for="(item, index) in group.items"
76 :class="['column', `is-${12 / config.columns}`]"
81 <!-- Vertical layout -->
83 v-if="!filter && vlayout"
84 class="columns is-multiline layout-vertical"
87 :class="['column', `is-${12 / config.columns}`]"
88 v-for="group in services"
91 <h2 v-if="group.name" class="group-title">
92 <i v-if="group.icon" :class="['fa-fw', group.icon]"></i>
93 <div v-else-if="group.logo" class="group-logo media-left">
94 <figure class="image is-48x48">
95 <img :src="group.logo" :alt="`${group.name} logo`" />
101 v-for="(item, index) in group.items"
111 <footer class="footer">
112 <div class="container">
114 class="content has-text-centered"
116 v-html="config.footer"
124 const jsyaml = require("js-yaml");
125 const merge = require("lodash.merge");
127 import Navbar from "./components/Navbar.vue";
128 import ConnectivityChecker from "./components/ConnectivityChecker.vue";
129 import Service from "./components/Service.vue";
130 import Message from "./components/Message.vue";
131 import SearchInput from "./components/SearchInput.vue";
132 import SettingToggle from "./components/SettingToggle.vue";
133 import DarkMode from "./components/DarkMode.vue";
134 import DynamicTheme from "./components/DynamicTheme.vue";
136 import defaultConfig from "./assets/defaults.yml";
161 created: async function () {
162 const defaults = jsyaml.load(defaultConfig);
165 config = await this.getConfig();
168 config = this.handleErrors("⚠️ Error loading configuration", error);
170 this.config = merge(defaults, config);
171 this.services = this.config.services;
173 this.config.documentTitle ||
174 `${this.config.title} | ${this.config.subtitle}`;
175 if (this.config.stylesheet) {
177 for (const file of this.config.stylesheet) {
178 stylesheet += `@import "${file}";`;
180 this.createStylesheet(stylesheet);
184 getConfig: function (path = "assets/config.yml") {
185 return fetch(path).then((response) => {
186 if (response.redirected) {
187 // This allows to work with authentication proxies.
188 window.location.href = response.url;
192 throw Error(`${response.statusText}: ${response.body}`);
199 return jsyaml.load(body);
201 .then(function (config) {
202 if (config.externalConfig) {
203 return that.getConfig(config.externalConfig);
209 matchesFilter: function (item) {
211 item.name.toLowerCase().includes(this.filter) ||
212 (item.subtitle && item.subtitle.toLowerCase().includes(this.filter)) ||
213 (item.tag && item.tag.toLowerCase().includes(this.filter))
216 navigateToFirstService: function (target) {
218 const service = this.services[0].items[0];
219 window.open(service.url, target || service.target || "_self");
221 console.warning("fail to open service");
224 filterServices: function (filter) {
225 this.filter = filter;
228 this.services = this.config.services;
232 const searchResultItems = [];
233 for (const group of this.config.services) {
234 for (const item of group.items) {
235 if (this.matchesFilter(item)) {
236 searchResultItems.push(item);
244 icon: "fas fa-search",
245 items: searchResultItems,
249 handleErrors: function (title, content) {
258 createStylesheet: function (css) {
259 let style = document.createElement("style");
260 style.appendChild(document.createTextNode(css));
261 document.head.appendChild(style);