mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-23 05:35:07 +02:00
🔥 Implementation of VueX, delete all emit events
This commit is contained in:
parent
8d111a1623
commit
fddb77dec9
@ -9,6 +9,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Keys from '@/utils/StoreMutations';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'IframeModal',
|
name: 'IframeModal',
|
||||||
props: {
|
props: {
|
||||||
@ -21,13 +23,13 @@ export default {
|
|||||||
show(url) {
|
show(url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.$modal.show(this.name);
|
this.$modal.show(this.name);
|
||||||
this.$emit('modalChanged', true);
|
this.$store.commit(Keys.SET_MODAL_OPEN, true);
|
||||||
},
|
},
|
||||||
hide() {
|
hide() {
|
||||||
this.$modal.hide(this.name);
|
this.$modal.hide(this.name);
|
||||||
},
|
},
|
||||||
modalClosed() {
|
modalClosed() {
|
||||||
this.$emit('modalChanged', false);
|
this.$store.commit(Keys.SET_MODAL_OPEN, false);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
:ref="`iframeModal-${groupId}`"
|
:ref="`iframeModal-${groupId}`"
|
||||||
:name="`iframeModal-${groupId}`"
|
:name="`iframeModal-${groupId}`"
|
||||||
@closed="$emit('itemClicked')"
|
@closed="$emit('itemClicked')"
|
||||||
@modalChanged="modalChanged"
|
|
||||||
/>
|
/>
|
||||||
</Collapsable>
|
</Collapsable>
|
||||||
</template>
|
</template>
|
||||||
@ -65,7 +64,6 @@ export default {
|
|||||||
displayData: Object,
|
displayData: Object,
|
||||||
items: Array,
|
items: Array,
|
||||||
itemSize: String,
|
itemSize: String,
|
||||||
modalOpen: Boolean,
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Collapsable,
|
Collapsable,
|
||||||
@ -124,10 +122,6 @@ export default {
|
|||||||
triggerModal(url) {
|
triggerModal(url) {
|
||||||
this.$refs[`iframeModal-${this.groupId}`].show(url);
|
this.$refs[`iframeModal-${this.groupId}`].show(url);
|
||||||
},
|
},
|
||||||
/* Emmit value upwards when iframe modal opened/ closed */
|
|
||||||
modalChanged(changedTo) {
|
|
||||||
this.$emit('change-modal-visibility', changedTo);
|
|
||||||
},
|
|
||||||
/* Determines if user has enabled online status checks */
|
/* Determines if user has enabled online status checks */
|
||||||
shouldEnableStatusCheck(itemPreference) {
|
shouldEnableStatusCheck(itemPreference) {
|
||||||
const globalPreference = this.appConfig.statusCheck || false;
|
const globalPreference = this.appConfig.statusCheck || false;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
:ref="`iframeModal-${groupId}`"
|
:ref="`iframeModal-${groupId}`"
|
||||||
:name="`iframeModal-${groupId}`"
|
:name="`iframeModal-${groupId}`"
|
||||||
@closed="$emit('itemClicked')"
|
@closed="$emit('itemClicked')"
|
||||||
@modalChanged="modalChanged"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -70,9 +69,6 @@ export default {
|
|||||||
triggerModal(url) {
|
triggerModal(url) {
|
||||||
this.$refs[`iframeModal-${this.groupId}`].show(url);
|
this.$refs[`iframeModal-${this.groupId}`].show(url);
|
||||||
},
|
},
|
||||||
modalChanged(changedTo) {
|
|
||||||
this.$emit('change-modal-visibility', changedTo);
|
|
||||||
},
|
|
||||||
shouldEnableStatusCheck(itemPreference) {
|
shouldEnableStatusCheck(itemPreference) {
|
||||||
const globalPreference = this.appConfig.statusCheck || false;
|
const globalPreference = this.appConfig.statusCheck || false;
|
||||||
return itemPreference !== undefined ? itemPreference : globalPreference;
|
return itemPreference !== undefined ? itemPreference : globalPreference;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<!-- Modal containing all the configuration options -->
|
<!-- Modal containing all the configuration options -->
|
||||||
<modal :name="modalNames.CONF_EDITOR" :resizable="true" width="60%" height="85%"
|
<modal :name="modalNames.CONF_EDITOR" :resizable="true" width="60%" height="85%"
|
||||||
@closed="$emit('modalChanged', false)" classes="dashy-modal">
|
@closed="editorClosed" classes="dashy-modal">
|
||||||
<ConfigContainer :config="combineConfig()" />
|
<ConfigContainer :config="combineConfig()" />
|
||||||
</modal>
|
</modal>
|
||||||
|
|
||||||
@ -48,6 +48,7 @@
|
|||||||
import ConfigContainer from '@/components/Configuration/ConfigContainer';
|
import ConfigContainer from '@/components/Configuration/ConfigContainer';
|
||||||
import LanguageSwitcher from '@/components/Settings/LanguageSwitcher';
|
import LanguageSwitcher from '@/components/Settings/LanguageSwitcher';
|
||||||
import { topLevelConfKeys, localStorageKeys, modalNames } from '@/utils/defaults';
|
import { topLevelConfKeys, localStorageKeys, modalNames } from '@/utils/defaults';
|
||||||
|
import Keys from '@/utils/StoreMutations';
|
||||||
import IconSpanner from '@/assets/interface-icons/config-editor.svg';
|
import IconSpanner from '@/assets/interface-icons/config-editor.svg';
|
||||||
import IconViewMode from '@/assets/interface-icons/application-change-view.svg';
|
import IconViewMode from '@/assets/interface-icons/application-change-view.svg';
|
||||||
import IconHome from '@/assets/interface-icons/application-home.svg';
|
import IconHome from '@/assets/interface-icons/application-home.svg';
|
||||||
@ -85,7 +86,10 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
showEditor: function show() {
|
showEditor: function show() {
|
||||||
this.$modal.show(modalNames.CONF_EDITOR);
|
this.$modal.show(modalNames.CONF_EDITOR);
|
||||||
this.$emit('modalChanged', true);
|
this.$store.commit(Keys.SET_MODAL_OPEN, true);
|
||||||
|
},
|
||||||
|
editorClosed: function show() {
|
||||||
|
this.$store.commit(Keys.SET_MODAL_OPEN, false);
|
||||||
},
|
},
|
||||||
combineConfig() {
|
combineConfig() {
|
||||||
const conf = {};
|
const conf = {};
|
||||||
|
@ -35,9 +35,6 @@ import {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FilterTile',
|
name: 'FilterTile',
|
||||||
props: {
|
|
||||||
active: Boolean,
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
input: '', // Users current search term
|
input: '', // Users current search term
|
||||||
@ -46,6 +43,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
active() {
|
||||||
|
return !this.$store.state.modalOpen;
|
||||||
|
},
|
||||||
searchPrefs() {
|
searchPrefs() {
|
||||||
return this.$store.getters.webSearch || {};
|
return this.$store.getters.webSearch || {};
|
||||||
},
|
},
|
||||||
|
@ -3,15 +3,14 @@
|
|||||||
<SearchBar ref="SearchBar"
|
<SearchBar ref="SearchBar"
|
||||||
@user-is-searchin="userIsTypingSomething"
|
@user-is-searchin="userIsTypingSomething"
|
||||||
v-if="searchVisible"
|
v-if="searchVisible"
|
||||||
:active="!modalOpen"
|
|
||||||
/>
|
/>
|
||||||
<div class="options-outer">
|
<div class="options-outer">
|
||||||
<div :class="`options-container ${!settingsVisible ? 'hide' : ''}`">
|
<div :class="`options-container ${!settingsVisible ? 'hide' : ''}`">
|
||||||
<ThemeSelector :externalThemes="externalThemes" @modalChanged="modalChanged"
|
<ThemeSelector :externalThemes="externalThemes"
|
||||||
:confTheme="getInitialTheme()" :userThemes="getUserThemes()" />
|
:confTheme="getInitialTheme()" :userThemes="getUserThemes()" />
|
||||||
<LayoutSelector :displayLayout="displayLayout" @layoutUpdated="updateDisplayLayout"/>
|
<LayoutSelector :displayLayout="displayLayout" @layoutUpdated="updateDisplayLayout"/>
|
||||||
<ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" />
|
<ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" />
|
||||||
<ConfigLauncher @modalChanged="modalChanged" />
|
<ConfigLauncher />
|
||||||
<AuthButtons v-if="userState != 'noone'" :userType="userState" />
|
<AuthButtons v-if="userState != 'noone'" :userType="userState" />
|
||||||
</div>
|
</div>
|
||||||
<div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`">
|
<div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`">
|
||||||
@ -51,7 +50,6 @@ export default {
|
|||||||
displayLayout: String,
|
displayLayout: String,
|
||||||
iconSize: String,
|
iconSize: String,
|
||||||
externalThemes: Object,
|
externalThemes: Object,
|
||||||
modalOpen: Boolean,
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
SearchBar,
|
SearchBar,
|
||||||
@ -110,9 +108,6 @@ export default {
|
|||||||
updateIconSize(iconSize) {
|
updateIconSize(iconSize) {
|
||||||
this.$emit('change-icon-size', iconSize);
|
this.$emit('change-icon-size', iconSize);
|
||||||
},
|
},
|
||||||
modalChanged(changedTo) {
|
|
||||||
this.$emit('change-modal-visibility', changedTo);
|
|
||||||
},
|
|
||||||
getInitialTheme() {
|
getInitialTheme() {
|
||||||
return this.appConfig.theme || '';
|
return this.appConfig.theme || '';
|
||||||
},
|
},
|
||||||
|
@ -31,6 +31,7 @@ import {
|
|||||||
ApplyCustomVariables,
|
ApplyCustomVariables,
|
||||||
} from '@/utils/ThemeHelper';
|
} from '@/utils/ThemeHelper';
|
||||||
import Defaults, { localStorageKeys } from '@/utils/defaults';
|
import Defaults, { localStorageKeys } from '@/utils/defaults';
|
||||||
|
import Keys from '@/utils/StoreMutations';
|
||||||
import IconPalette from '@/assets/interface-icons/config-color-palette.svg';
|
import IconPalette from '@/assets/interface-icons/config-color-palette.svg';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -94,12 +95,12 @@ export default {
|
|||||||
},
|
},
|
||||||
/* Opens the theme color configurator popup */
|
/* Opens the theme color configurator popup */
|
||||||
openThemeConfigurator() {
|
openThemeConfigurator() {
|
||||||
this.$emit('modalChanged', true);
|
this.$store.commit(Keys.SET_MODAL_OPEN, true);
|
||||||
this.themeConfiguratorOpen = true;
|
this.themeConfiguratorOpen = true;
|
||||||
},
|
},
|
||||||
/* Closes the theme color configurator popup */
|
/* Closes the theme color configurator popup */
|
||||||
closeThemeConfigurator() {
|
closeThemeConfigurator() {
|
||||||
// this.$emit('modalChanged', false);
|
this.$store.commit(Keys.SET_MODAL_OPEN, false);
|
||||||
this.themeConfiguratorOpen = false;
|
this.themeConfiguratorOpen = false;
|
||||||
},
|
},
|
||||||
/* Updates theme. Checks if the new theme is local or external,
|
/* Updates theme. Checks if the new theme is local or external,
|
||||||
|
@ -51,7 +51,7 @@ const render = (awesome) => awesome(Dashy);
|
|||||||
|
|
||||||
// Mount the app, with router, store i18n and render func
|
// Mount the app, with router, store i18n and render func
|
||||||
const mount = () => new Vue({
|
const mount = () => new Vue({
|
||||||
router, render, i18n, store,
|
store, router, render, i18n,
|
||||||
}).$mount('#app');
|
}).$mount('#app');
|
||||||
|
|
||||||
// If Keycloak not enabled, then proceed straight to the app
|
// If Keycloak not enabled, then proceed straight to the app
|
||||||
|
@ -14,10 +14,10 @@ import Home from '@/views/Home.vue';
|
|||||||
import Login from '@/views/Login.vue';
|
import Login from '@/views/Login.vue';
|
||||||
import Workspace from '@/views/Workspace.vue';
|
import Workspace from '@/views/Workspace.vue';
|
||||||
import Minimal from '@/views/Minimal.vue';
|
import Minimal from '@/views/Minimal.vue';
|
||||||
|
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||||
|
|
||||||
// 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 { config } from '@/utils/ConfigHelpers';
|
|
||||||
import { metaTagData, startingView, routePaths } from '@/utils/defaults';
|
import { metaTagData, startingView, routePaths } from '@/utils/defaults';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
|
|
||||||
@ -32,8 +32,18 @@ const isAuthenticated = () => {
|
|||||||
return (!authEnabled || userLoggedIn || guestEnabled);
|
return (!authEnabled || userLoggedIn || guestEnabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getConfig = () => {
|
||||||
|
const Accumulator = new ConfigAccumulator();
|
||||||
|
return {
|
||||||
|
appConfig: Accumulator.appConfig(),
|
||||||
|
pageInfo: Accumulator.pageInfo(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const { appConfig, pageInfo } = getConfig();
|
||||||
|
|
||||||
/* Get the users chosen starting view from app config, or return default */
|
/* Get the users chosen starting view from app config, or return default */
|
||||||
const getStartingView = () => config.appConfig.startingView || startingView;
|
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,
|
||||||
@ -51,7 +61,7 @@ const getStartingComponent = () => {
|
|||||||
|
|
||||||
/* Returns the meta tags for each route */
|
/* Returns the meta tags for each route */
|
||||||
const makeMetaTags = (defaultTitle) => ({
|
const makeMetaTags = (defaultTitle) => ({
|
||||||
title: config.pageInfo.title || defaultTitle,
|
title: pageInfo.title || defaultTitle,
|
||||||
metaTags: metaTagData,
|
metaTags: metaTagData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,9 +16,7 @@ const getAppConfig = () => {
|
|||||||
* Support for old user structure will be removed in V 1.7.0
|
* Support for old user structure will be removed in V 1.7.0
|
||||||
*/
|
*/
|
||||||
const printWarning = () => {
|
const printWarning = () => {
|
||||||
const msg = 'From V 1.6.5 onwards, the structure of the users object has changed.';
|
ErrorHandler('From V 1.6.5 onwards, the structure of the users object has changed.');
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.warn(msg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Returns true if keycloak is enabled */
|
/* Returns true if keycloak is enabled */
|
||||||
|
@ -11,9 +11,8 @@ import {
|
|||||||
pageInfo as defaultPageInfo,
|
pageInfo as defaultPageInfo,
|
||||||
iconSize as defaultIconSize,
|
iconSize as defaultIconSize,
|
||||||
layout as defaultLayout,
|
layout as defaultLayout,
|
||||||
// language as defaultLanguage,
|
|
||||||
} from '@/utils/defaults';
|
} from '@/utils/defaults';
|
||||||
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
import conf from '../../public/conf.yml';
|
import conf from '../../public/conf.yml';
|
||||||
|
|
||||||
export default class ConfigAccumulator {
|
export default class ConfigAccumulator {
|
||||||
@ -46,24 +45,14 @@ export default class ConfigAccumulator {
|
|||||||
|
|
||||||
/* Page Info */
|
/* Page Info */
|
||||||
pageInfo() {
|
pageInfo() {
|
||||||
const defaults = defaultPageInfo;
|
let localPageInfo = {};
|
||||||
let localPageInfo;
|
if (localStorage[localStorageKeys.PAGE_INFO]) {
|
||||||
try {
|
// eslint-disable-next-line brace-style
|
||||||
localPageInfo = JSON.parse(localStorage[localStorageKeys.PAGE_INFO]);
|
try { localPageInfo = JSON.parse(localStorage[localStorageKeys.PAGE_INFO]); }
|
||||||
} catch (e) {
|
catch (e) { ErrorHandler('Malformed pageInfo data in local storage'); }
|
||||||
localPageInfo = {};
|
|
||||||
}
|
}
|
||||||
let filePageInfo = {};
|
const filePageInfo = this.conf ? this.conf.pageInfo || {} : {};
|
||||||
if (this.conf) {
|
return { ...defaultPageInfo, ...filePageInfo, ...localPageInfo };
|
||||||
filePageInfo = this.conf.pageInfo || {};
|
|
||||||
}
|
|
||||||
const pi = filePageInfo || defaults; // The page info object to return
|
|
||||||
pi.title = localPageInfo.title || filePageInfo.title || defaults.title;
|
|
||||||
pi.logo = localPageInfo.logo || filePageInfo.logo || defaults.logo;
|
|
||||||
pi.description = localPageInfo.description || filePageInfo.description || defaults.description;
|
|
||||||
pi.navLinks = localPageInfo.navLinks || filePageInfo.navLinks || defaults.navLinks;
|
|
||||||
pi.footerText = localPageInfo.footerText || filePageInfo.footerText || defaults.footerText;
|
|
||||||
return pi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sections */
|
/* Sections */
|
||||||
@ -75,13 +64,11 @@ export default class ConfigAccumulator {
|
|||||||
const json = JSON.parse(localSections);
|
const json = JSON.parse(localSections);
|
||||||
if (json.length >= 1) return json;
|
if (json.length >= 1) return json;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// The data in local storage has been malformed, will return conf.sections instead
|
ErrorHandler('Malformed section data in local storage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the function hasn't yet returned, then return the config file sections
|
// If the function hasn't yet returned, then return the config file sections
|
||||||
let sectionsFile = [];
|
return this.conf ? this.conf.sections || [] : [];
|
||||||
if (this.conf) sectionsFile = this.conf.sections || [];
|
|
||||||
return sectionsFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Complete config */
|
/* Complete config */
|
||||||
|
@ -60,7 +60,6 @@ export default {
|
|||||||
searchValue: '',
|
searchValue: '',
|
||||||
layout: '',
|
layout: '',
|
||||||
itemSizeBound: '',
|
itemSizeBound: '',
|
||||||
modalOpen: false, // When true, keybindings are disabled
|
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
sections() {
|
sections() {
|
||||||
@ -72,6 +71,9 @@ export default {
|
|||||||
pageInfo() {
|
pageInfo() {
|
||||||
return this.$store.getters.pageInfo;
|
return this.$store.getters.pageInfo;
|
||||||
},
|
},
|
||||||
|
modalOpen() {
|
||||||
|
return this.$store.state.modalOpen;
|
||||||
|
},
|
||||||
/* Get class for num columns, if specified by user */
|
/* Get class for num columns, if specified by user */
|
||||||
colCount() {
|
colCount() {
|
||||||
let { colCount } = this.appConfig;
|
let { colCount } = this.appConfig;
|
||||||
@ -144,7 +146,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/* Update data when modal is open (so that key bindings can be disabled) */
|
/* Update data when modal is open (so that key bindings can be disabled) */
|
||||||
updateModalVisibility(modalState) {
|
updateModalVisibility(modalState) {
|
||||||
this.modalOpen = modalState;
|
this.$store.commit('SET_MODAL_OPEN', modalState);
|
||||||
},
|
},
|
||||||
/* Returns an array of links to external CSS from the Config */
|
/* Returns an array of links to external CSS from the Config */
|
||||||
getExternalCSSLinks() {
|
getExternalCSSLinks() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user