π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π§ WIP
Alicia Sykescdf1bb9529db
diff --git a/server.js b/server.jsindex 5c83f81e..28692a58 100644--- a/server.js+++ b/server.js@@ -73,6 +73,7 @@ const app = express().use(sslServer.middleware)// Serves up static files.use(express.static(path.join(__dirname, 'dist')))+ .use(express.static(path.join(__dirname, 'user-data'))).use(express.static(path.join(__dirname, 'public'), { index: 'initialization.html' }))// Load middlewares for parsing JSON, and supporting HTML5 history routing.use(express.json({ limit: '1mb' }))diff --git a/src/main.js b/src/main.jsindex 5b79d619..c3f626d8 100644--- a/src/main.js+++ b/src/main.js@@ -13,14 +13,15 @@ import TreeView from 'vue-json-tree-view';// Import base Dashy components and utilsimport Dashy from '@/App.vue'; // Main Dashy Vue app-import router from '@/router'; // Router, for navigationimport store from '@/store'; // Store, for local state management+import router from '@/router'; // Router, for navigationimport serviceWorker from '@/utils/InitServiceWorker'; // Service worker initializationimport { messages } from '@/utils/languages'; // Language textsimport ErrorReporting from '@/utils/ErrorReporting'; // Error reporting initializer (off)import clickOutside from '@/directives/ClickOutside'; // Directive for closing popups, modals, etcimport { toastedOptions, tooltipOptions, language as defaultLanguage } from '@/utils/defaults';import { initKeycloakAuth, isKeycloakEnabled } from '@/utils/KeycloakAuth';+import Keys from '@/utils/StoreMutations';// Initialize global Vue componentsVue.use(VueI18n);@@ -53,6 +54,8 @@ ErrorReporting(Vue, router);// Render functionconst render = (awesome) => awesome(Dashy);+store.dispatch(Keys.INITIALIZE_CONFIG).then((thing) => console.log('main', thing));+// Mount the app, with router, store i18n and render funcconst mount = () => new Vue({store, router, render, i18n,diff --git a/src/router.js b/src/router.jsindex 5fbb12ea..c9b7f5ad 100644--- a/src/router.js+++ b/src/router.js@@ -14,22 +14,27 @@ import Home from '@/views/Home.vue';// Import helper functions, config data and defaultsimport { isAuthEnabled, isLoggedIn, isGuestAccessEnabled } from '@/utils/Auth';-// import { makePageSlug, makePageName } from '@/utils/ConfigHelpers';import { metaTagData, startingView, routePaths } from '@/utils/defaults';import ErrorHandler from '@/utils/ErrorHandler';+import Keys from '@/utils/StoreMutations';+// import $store from '@/store';// Import data from users conf file. Note that rebuild is required for this to update.-import conf from '../public/conf.yml';+// import conf from '../public/conf.yml';-if (!conf) {- ErrorHandler('You\'ve not got any data in your config file yet.');-}+// this.$store.dispatch(Keys.INITIALIZE_CONFIG, undefined);+// const conf = $store.getters.config;++// if (!conf) {+// ErrorHandler('You\'ve not got any data in your config file yet.');+// }++// console.log($store.state.config);// Assign top-level config fields, check not null-const config = conf || {};-// const pages = config.pages || [];-const pageInfo = config.pageInfo || {};-const appConfig = config.appConfig || {};+// const config = conf || {};+const pageInfo = {};+const appConfig = {};Vue.use(Router);const progress = new Progress({ color: 'var(--progress-bar)' });@@ -42,6 +47,8 @@ const isAuthenticated = () => {return (!authEnabled || userLoggedIn || guestEnabled);};+// appConfig.auth, appConfig.startingView, appConfig.routingMode, pageInfo.title+/* Get the users chosen starting view from app config, or return default */const getStartingView = () => appConfig.startingView || startingView;@@ -64,55 +71,6 @@ const makeMetaTags = (defaultTitle) => ({metaTags: metaTagData,});-// const makeSubConfigPath = (rawPath) => {-// if (!rawPath) return '';-// if (rawPath.startsWith('/') || rawPath.startsWith('http')) return rawPath;-// else return `/${rawPath}`;-// };--/* For each additional config file, create routes for home, minimal and workspace views */-// const makeMultiPageRoutes = (userPages) => {-// // If no multi pages specified, or is not array, then return nothing-// if (!userPages || !Array.isArray(userPages)) return [];-// const multiPageRoutes = [];-// // For each user page, create an additional route-// userPages.forEach((page) => {-// if (!page.name || !page.path) { // Sumin not right, show warning-// ErrorHandler('Additional pages must have both a `name` and `path`');-// }-// // Props to be passed to home mixin-// const subPageInfo = {-// subPageInfo: {-// confPath: makeSubConfigPath(page.path),-// pageId: makePageName(page.name),-// pageTitle: page.name,-// },-// };-// // Create route for default homepage-// multiPageRoutes.push({-// path: makePageSlug(page.name, 'home'),-// name: `${subPageInfo.subPageInfo.pageId}-home`,-// component: Home,-// props: subPageInfo,-// });-// // Create route for the workspace view-// multiPageRoutes.push({-// path: makePageSlug(page.name, 'workspace'),-// name: `${subPageInfo.subPageInfo.pageId}-workspace`,-// component: () => import('./views/Workspace.vue'),-// props: subPageInfo,-// });-// // Create route for the minimal view-// multiPageRoutes.push({-// path: makePageSlug(page.name, 'minimal'),-// name: `${subPageInfo.subPageInfo.pageId}-minimal`,-// component: () => import('./views/Minimal.vue'),-// props: subPageInfo,-// });-// });-// return multiPageRoutes;-// };-/* Routing mode, can be either 'hash', 'history' or 'abstract' */const mode = appConfig.routingMode || 'history';@@ -197,8 +155,12 @@ const router = new Router({* if so, then ensure that they are correctly logged in as a valid user* If not logged in, prevent all access and redirect them to login page* */-router.beforeEach((to, from, next) => {+router.beforeEach(async (to, from, next) => {progress.start();+ router.app.$store.dispatch(Keys.INITIALIZE_CONFIG, null).then((finished) => {+ console.log('Done!', finished);+ });+ await console.log('router.app.$store', router.app.$store.getters.config);if (to.name !== 'login' && !isAuthenticated()) next({ name: 'login' });else next();});diff --git a/src/store.js b/src/store.jsindex 2f379599..32501767 100644--- a/src/store.js+++ b/src/store.js@@ -337,13 +337,17 @@ const store = new Vuex.Store({if (!subConfigId) { // Use root config as configcommit(SET_CONFIG, rootConfig);commit(SET_CONFIG_ID, null);+ return rootConfig;} else {// Find and format path to fetch sub-config fromconst subConfigPath = formatConfigPath(rootConfig?.pages?.find((page) => makePageName(page.name) === subConfigId,)?.path);- if (!subConfigPath) ErrorHandler(`Unable to find config for '${subConfigId}'`);+ if (!subConfigPath) {+ ErrorHandler(`Unable to find config for '${subConfigId}'`);+ return null;+ }axios.get(subConfigPath).then((response) => {const configContent = yaml.load(response.data);@@ -354,10 +358,12 @@ const store = new Vuex.Store({configContent.appConfig.theme = theme;commit(SET_CONFIG, configContent);commit(SET_CONFIG_ID, subConfigId);+ return configContent;}).catch((err) => {ErrorHandler(`Unable to load config from '${subConfigPath}'`, err);});}+ return null;},},modules: {},diff --git a/src/utils/Auth.js b/src/utils/Auth.jsindex df9f3478..6b32355f 100644--- a/src/utils/Auth.js+++ b/src/utils/Auth.js@@ -11,6 +11,8 @@ const getAppConfig = () => {return config.appConfig || {};};+// const appConfig = $store.getters.appConfig || {};+/*** Called when the user is still using array for users, prints warning* This was a breaking change, implemented in V 1.6.5diff --git a/src/utils/ConfigAccumalator.js b/src/utils/ConfigAccumalator.jsindex 7f83e28b..25c1c45a 100644--- a/src/utils/ConfigAccumalator.js+++ b/src/utils/ConfigAccumalator.js@@ -16,7 +16,7 @@ import ErrorHandler from '@/utils/ErrorHandler';import { applyItemId } from '@/utils/SectionHelpers';import $store from '@/store';-import buildConf from '../../public/conf.yml';+// import buildConf from '../../public/conf.yml';export default class ConfigAccumulator {constructor() {@@ -33,9 +33,10 @@ export default class ConfigAccumulator {// Set app config from fileif (this.conf && this.conf.appConfig) {appConfigFile = this.conf.appConfig;- } else if (buildConf && buildConf.appConfig) {- appConfigFile = buildConf.appConfig;}+ // else if (buildConf && buildConf.appConfig) {+ // appConfigFile = buildConf.appConfig;+ // }// Fill in defaults if anything missinglet usersAppConfig = defaultAppConfig;if (localStorage[localStorageKeys.APP_CONFIG]) {diff --git a/src/utils/ErrorReporting.js b/src/utils/ErrorReporting.jsindex 77cea661..536150d3 100644--- a/src/utils/ErrorReporting.js+++ b/src/utils/ErrorReporting.js@@ -9,12 +9,12 @@/* eslint-disable global-require */-import ConfigAccumulator from '@/utils/ConfigAccumalator';+import $store from '@/store';import { sentryDsn } from '@/utils/defaults';const ErrorReporting = (Vue, router) => {// Fetch users config- const appConfig = new ConfigAccumulator().appConfig() || {};+ const appConfig = $store.getters.appConfig || {};// Check if error reporting is enabled. Only proceed if user has turned it on.if (appConfig.enableErrorReporting) {// Get current app version