π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
Pull conf.yml from server
ateroxaeec449dc763
diff --git a/server.js b/server.jsindex 4cef9e23..7d395ade 100644--- a/server.js+++ b/server.js@@ -27,6 +27,7 @@ const rebuild = require('./services/rebuild-app'); // A script to programmaticalconst systemInfo = require('./services/system-info'); // Basic system info, for resource widgetconst sslServer = require('./services/ssl-server'); // TLS-enabled web serverconst corsProxy = require('./services/cors-proxy'); // Enables API requests to CORS-blocked services+const getConf = require('./services/get-conf'); // Returns the configuration as a JSON object/* Helper functions, and default config */const printMessage = require('./services/print-message'); // Function to print welcome msg on start@@ -116,6 +117,14 @@ const app = express()} catch (e) {res.end(JSON.stringify({ success: false, message: e }));}+ })+ // GET endpoint returns the app configuration+ .use(ENDPOINTS.getConf, (req, res) => {+ try {+ res.end(JSON.stringify(getConf()));+ } catch (e) {+ res.end(JSON.stringify({ success: false, message: e }));+ }});/* Create HTTP server from app on port, and print welcome message */diff --git a/services/get-conf.js b/services/get-conf.jsnew file mode 100644index 00000000..df952256--- /dev/null+++ b/services/get-conf.js@@ -0,0 +1,10 @@+/**+ * Gets the configuration from conf.yml+ */+const fs = require('fs');+const yaml = require('js-yaml');++module.exports = () => {+ const conf = yaml.load(fs.readFileSync('./public/conf.yml', 'utf-8'));+ return conf;+};diff --git a/src/store.js b/src/store.jsindex 95ae846c..83bf628b 100644--- a/src/store.js+++ b/src/store.js@@ -1,6 +1,7 @@/* eslint-disable no-param-reassign, prefer-destructuring */import Vue from 'vue';import Vuex from 'vuex';+import axios from 'axios';import Keys from '@/utils/StoreMutations';import ConfigAccumulator from '@/utils/ConfigAccumalator';import { componentVisibility } from '@/utils/ConfigHelpers';@@ -8,12 +9,14 @@ import { applyItemId } from '@/utils/SectionHelpers';import filterUserSections from '@/utils/CheckSectionVisibility';import { InfoHandler, InfoKeys } from '@/utils/ErrorHandler';import { isUserAdmin } from '@/utils/Auth';+import { serviceEndpoints } from '@/utils/defaults';Vue.use(Vuex);const {INITIALIZE_CONFIG,SET_CONFIG,+ SET_REMOTE_CONFIG,SET_MODAL_OPEN,SET_LANGUAGE,SET_ITEM_LAYOUT,@@ -38,6 +41,7 @@ const {const store = new Vuex.Store({state: {config: {},+ remoteConfig: {}, // The configuration stored on the servereditMode: false, // While true, the user can drag and edit items + sectionsmodalOpen: false, // KB shortcut functionality will be disabled when modal is opennavigateConfToTab: undefined, // Used to switch active tab in config modal@@ -126,6 +130,9 @@ const store = new Vuex.Store({[SET_CONFIG](state, config) {state.config = config;},+ [SET_REMOTE_CONFIG](state, config) {+ state.remoteConfig = config;+ },[SET_LANGUAGE](state, lang) {const newConfig = state.config;newConfig.appConfig.language = lang;@@ -271,7 +278,9 @@ const store = new Vuex.Store({},actions: {/* Called when app first loaded. Reads config and sets state */- [INITIALIZE_CONFIG]({ commit }) {+ async [INITIALIZE_CONFIG]({ commit }) {+ // Get the config file from the server and store it for use by the accumulator+ commit(SET_REMOTE_CONFIG, (await axios.get(serviceEndpoints.getConf)).data);const deepCopy = (json) => JSON.parse(JSON.stringify(json));const config = deepCopy(new ConfigAccumulator().config());commit(SET_CONFIG, config);diff --git a/src/utils/ConfigAccumalator.js b/src/utils/ConfigAccumalator.jsindex a1756461..15131e7d 100644--- a/src/utils/ConfigAccumalator.js+++ b/src/utils/ConfigAccumalator.js@@ -14,11 +14,11 @@ import {} from '@/utils/defaults';import ErrorHandler from '@/utils/ErrorHandler';import { applyItemId } from '@/utils/SectionHelpers';-import conf from '../../public/conf.yml';+import $store from '../store';export default class ConfigAccumulator {constructor() {- this.conf = conf;+ this.conf = $store.state.remoteConfig;}/* App Config */diff --git a/src/utils/defaults.js b/src/utils/defaults.jsindex 57cabb6d..aba08691 100644--- a/src/utils/defaults.js+++ b/src/utils/defaults.js@@ -42,6 +42,7 @@ module.exports = {statusCheck: '/status-check',save: '/config-manager/save',rebuild: '/config-manager/rebuild',+ getConf: '/config-manager/get',systemInfo: '/system-info',corsProxy: '/cors-proxy',},