mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-24 01:12:06 +03:00
⚡ New state options for sub-config
This commit is contained in:
parent
31b40e60f6
commit
a1bf7a6931
@ -10,7 +10,8 @@
|
|||||||
Get the <a :href="defaultInfo.repoUrl">Source Code</a>.
|
Get the <a :href="defaultInfo.repoUrl">Source Code</a>.
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
Using: {{ $store.state.currentConfigId || 'Default Config' }}
|
Using:
|
||||||
|
{{ $store.state.currentConfigInfo? $store.state.currentConfigInfo.confId : 'Default Config' }}
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
</template>
|
</template>
|
||||||
|
@ -21,7 +21,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 1. Get the config, and strip appConfig if is sub-page
|
// 1. Get the config, and strip appConfig if is sub-page
|
||||||
const isSubPag = !!this.$store.state.currentConfigInfo;
|
const isSubPag = !!this.$store.state.currentConfigInfo.confId;
|
||||||
const jsonConfig = config;
|
const jsonConfig = config;
|
||||||
if (isSubPag) delete jsonConfig.appConfig;
|
if (isSubPag) delete jsonConfig.appConfig;
|
||||||
jsonConfig.sections = jsonConfig.sections.map(({ filteredItems, ...section }) => section);
|
jsonConfig.sections = jsonConfig.sections.map(({ filteredItems, ...section }) => section);
|
||||||
|
@ -14,27 +14,8 @@ import Home from '@/views/Home.vue';
|
|||||||
|
|
||||||
// Import helper functions, config data and defaults
|
// Import helper functions, config data and defaults
|
||||||
import { isAuthEnabled, isLoggedIn, isGuestAccessEnabled } from '@/utils/Auth';
|
import { isAuthEnabled, isLoggedIn, isGuestAccessEnabled } from '@/utils/Auth';
|
||||||
import { metaTagData, startingView, routePaths } from '@/utils/defaults';
|
import { metaTagData, startingView as defaultStartingView, routePaths } from '@/utils/defaults';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
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';
|
|
||||||
|
|
||||||
// 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 pageInfo = {};
|
|
||||||
const appConfig = {};
|
|
||||||
|
|
||||||
Vue.use(Router);
|
Vue.use(Router);
|
||||||
const progress = new Progress({ color: 'var(--progress-bar)' });
|
const progress = new Progress({ color: 'var(--progress-bar)' });
|
||||||
@ -47,18 +28,15 @@ const isAuthenticated = () => {
|
|||||||
return (!authEnabled || userLoggedIn || guestEnabled);
|
return (!authEnabled || userLoggedIn || guestEnabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
// appConfig.auth, appConfig.startingView, appConfig.routingMode, pageInfo.title
|
// Get the default starting view from environmental variable
|
||||||
|
const startingView = process.env.VUE_APP_STARTING_VIEW || defaultStartingView;
|
||||||
/* Get the users chosen starting view from app config, or return default */
|
|
||||||
const getStartingView = () => appConfig.startingView || startingView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the component that should be rendered at the base path,
|
* Returns the component that should be rendered at the base path,
|
||||||
* Defaults to Home, but the user can change this to Workspace of Minimal
|
* Defaults to Home, but the user can change this to Workspace of Minimal
|
||||||
*/
|
*/
|
||||||
const getStartingComponent = () => {
|
const getStartingComponent = () => {
|
||||||
const usersPreference = getStartingView();
|
switch (startingView) {
|
||||||
switch (usersPreference) {
|
|
||||||
case 'minimal': return () => import('./views/Minimal.vue');
|
case 'minimal': return () => import('./views/Minimal.vue');
|
||||||
case 'workspace': return () => import('./views/Workspace.vue');
|
case 'workspace': return () => import('./views/Workspace.vue');
|
||||||
default: return Home;
|
default: return Home;
|
||||||
@ -66,13 +44,14 @@ const getStartingComponent = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Returns the meta tags for each route */
|
/* Returns the meta tags for each route */
|
||||||
const makeMetaTags = (defaultTitle) => ({
|
const makeMetaTags = (defaultTitle) => {
|
||||||
title: pageInfo.title || defaultTitle,
|
const userTitle = process.env.VUE_APP_TITLE || '';
|
||||||
metaTags: metaTagData,
|
const title = userTitle ? `${userTitle} | ${defaultTitle}` : defaultTitle;
|
||||||
});
|
return { title, metaTags: metaTagData };
|
||||||
|
};
|
||||||
|
|
||||||
/* Routing mode, can be either 'hash', 'history' or 'abstract' */
|
/* Routing mode, can be either 'hash', 'history' or 'abstract' */
|
||||||
const mode = appConfig.routingMode || 'history';
|
const mode = process.env.VUE_APP_ROUTING_MODE || 'history';
|
||||||
|
|
||||||
/* List of all routes, props, components and metadata */
|
/* List of all routes, props, components and metadata */
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
@ -81,7 +60,7 @@ const router = new Router({
|
|||||||
// ...makeMultiPageRoutes(pages),
|
// ...makeMultiPageRoutes(pages),
|
||||||
{ // The default view can be customized by the user
|
{ // The default view can be customized by the user
|
||||||
path: '/',
|
path: '/',
|
||||||
name: `landing-page-${getStartingView()}`,
|
name: `landing-page-${startingView}`,
|
||||||
component: getStartingComponent(),
|
component: getStartingComponent(),
|
||||||
meta: makeMetaTags('Home Page'),
|
meta: makeMetaTags('Home Page'),
|
||||||
},
|
},
|
||||||
@ -157,10 +136,6 @@ const router = new Router({
|
|||||||
* */
|
* */
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
progress.start();
|
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' });
|
if (to.name !== 'login' && !isAuthenticated()) next({ name: 'login' });
|
||||||
else next();
|
else next();
|
||||||
});
|
});
|
||||||
|
@ -16,8 +16,6 @@ import ErrorHandler from '@/utils/ErrorHandler';
|
|||||||
import { applyItemId } from '@/utils/SectionHelpers';
|
import { applyItemId } from '@/utils/SectionHelpers';
|
||||||
import $store from '@/store';
|
import $store from '@/store';
|
||||||
|
|
||||||
// import buildConf from '../../public/conf.yml';
|
|
||||||
|
|
||||||
export default class ConfigAccumulator {
|
export default class ConfigAccumulator {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.conf = $store.state.config;
|
this.conf = $store.state.config;
|
||||||
|
Loading…
Reference in New Issue
Block a user