@enso-ui/ui 6.2.7 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/bulma/index.js +2 -2
- package/package.json +34 -31
- package/renderless/components/settings/index.js +1 -8
- package/renderless/index.js +2 -2
- package/src/bulma/components/AppFooter.vue +11 -11
- package/src/bulma/components/Breadcrumbs.vue +32 -5
- package/src/bulma/components/VueAside.vue +7 -11
- package/src/bulma/components/menu/Sidebar.vue +26 -10
- package/src/bulma/components/navbar/AppUpdate.vue +38 -14
- package/src/bulma/components/navbar/Navbar.vue +17 -15
- package/src/bulma/components/navbar/NavbarItem.vue +2 -4
- package/src/bulma/components/navbar/Search.vue +6 -5
- package/src/bulma/components/navbar/SettingsControl.vue +6 -5
- package/src/bulma/components/settings/Settings.vue +17 -3
- package/src/bulma/components/settings/SidebarState.vue +1 -2
- package/src/bulma/layouts/Default.vue +8 -22
- package/src/bulma/pages/MaintenanceMode.vue +5 -7
- package/src/bulma/pages/NotFound.vue +6 -5
- package/src/bulma/pages/Unauthorized.vue +5 -4
- package/src/bulma/styles/components/form.scss +151 -0
- package/src/bulma/styles/components/tables.scss +695 -0
- package/src/bulma/styles/components/vue-filter.scss +173 -0
- package/src/bulma/styles/components.sass +3 -0
- package/src/core/Root.vue +26 -7
- package/src/core/app.js +1 -1
- package/src/core/components/AppFooter.vue +2 -6
- package/src/core/components/DocumentTitle.vue +8 -3
- package/src/core/components/PageHeader.vue +7 -3
- package/src/core/components/menu/Sidebar.vue +2 -6
- package/src/core/components/navbar/Navbar.vue +17 -19
- package/src/core/components/navbar/Search.vue +10 -3
- package/src/core/components/navbar/SettingsControl.vue +4 -2
- package/src/core/components/settings/Settings.vue +6 -20
- package/src/core/components/settings/SidebarState.vue +5 -7
- package/src/core/layouts/Default.vue +96 -65
- package/src/core/layouts/Home.vue +27 -28
- package/src/core/services/contexts.js +51 -11
- package/src/core/services/errorHandler.js +4 -4
- package/src/core/services/pinia.js +7 -0
- package/src/core/services/resources.js +22 -17
- package/src/core/services/router.js +2 -3
- package/src/icons.js +8 -2
- package/src/middleware/before/auth.js +9 -5
- package/src/middleware/before/guest.js +6 -2
- package/src/middleware/before.js +5 -4
- package/src/modules/importers/routeImporter.js +23 -0
- package/src/modules/plugins/bootEnums.js +10 -1
- package/src/modules/plugins/date-fns/format.js +11 -6
- package/src/modules/plugins/date-fns/formatDistance.js +2 -2
- package/src/modules/plugins/i18n.js +7 -5
- package/src/modules/plugins/route.js +3 -3
- package/src/pinia/app.js +75 -0
- package/src/pinia/layout.js +115 -0
- package/src/pinia/loadState.js +78 -0
- package/src/pinia/preferences.js +90 -0
- package/src/pinia/websockets.js +48 -0
- package/src/core/services/store.js +0 -26
- package/src/modules/importers/storeImporter.js +0 -8
- package/src/modules/importers/themeImporter.js +0 -5
- package/src/modules/store/layout/navbar.js +0 -8
- package/src/modules/store/layout/settings.js +0 -7
- package/src/modules/store/layout/sidebar.js +0 -22
- package/src/modules/store/layout.js +0 -72
- package/src/modules/store/preferences.js +0 -80
- package/src/modules/store/websockets.js +0 -39
- package/src/modules/store.js +0 -115
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useStore } from '../../core/services/pinia';
|
|
2
2
|
|
|
3
3
|
export default (key, params = null) => {
|
|
4
4
|
if (key === null || key === '' || typeof key === 'undefined') {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const localisation = useStore('localisation');
|
|
9
|
+
|
|
10
|
+
if (!localisation?.ready) {
|
|
9
11
|
return key;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
let translation =
|
|
14
|
+
let translation = localisation.translate(key);
|
|
13
15
|
|
|
14
16
|
if (typeof translation === 'undefined' || translation === null) {
|
|
15
17
|
translation = key;
|
|
16
18
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
+
if (localisation.keyCollector) {
|
|
20
|
+
localisation.addMissingKey(key);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import RouteMapper from '@enso-ui/route-mapper';
|
|
2
|
-
import
|
|
2
|
+
import { useStore } from '../../core/services/pinia';
|
|
3
3
|
|
|
4
4
|
export default (name, params, absolute) => {
|
|
5
|
-
const
|
|
5
|
+
const state = useStore('app');
|
|
6
6
|
|
|
7
|
-
return
|
|
7
|
+
return new RouteMapper(state.meta.appUrl, state.routes).get(name, params, absolute);
|
|
8
8
|
};
|
package/src/pinia/app.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import App from '../core/app';
|
|
3
|
+
|
|
4
|
+
export const app = defineStore('app', {
|
|
5
|
+
state: () => ({
|
|
6
|
+
appUpdate: false,
|
|
7
|
+
impersonating: null,
|
|
8
|
+
meta: {},
|
|
9
|
+
pendingRequests: [],
|
|
10
|
+
routes: {},
|
|
11
|
+
showQuote: false,
|
|
12
|
+
user: {},
|
|
13
|
+
avatarKey: 1,
|
|
14
|
+
}),
|
|
15
|
+
|
|
16
|
+
getters: {
|
|
17
|
+
isWebview: () => typeof ReactNativeWebView !== 'undefined',
|
|
18
|
+
requests: state => state.pendingRequests.length,
|
|
19
|
+
requestIndex: state => ({ url, method }) => state.pendingRequests
|
|
20
|
+
.findIndex(request => method === request.method && url === request.url),
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
actions: {
|
|
24
|
+
addRequest(payload) {
|
|
25
|
+
this.pendingRequests.push(payload);
|
|
26
|
+
},
|
|
27
|
+
newRelease() {
|
|
28
|
+
this.appUpdate = true;
|
|
29
|
+
},
|
|
30
|
+
removeRequest(index) {
|
|
31
|
+
this.pendingRequests.splice(index, 1);
|
|
32
|
+
},
|
|
33
|
+
setDefaultRoute(route) {
|
|
34
|
+
App.router?.addRoute({
|
|
35
|
+
name: 'default',
|
|
36
|
+
path: '/',
|
|
37
|
+
redirect: { name: route },
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
setImpersonating(impersonating) {
|
|
41
|
+
this.impersonating = impersonating;
|
|
42
|
+
},
|
|
43
|
+
setMeta(meta) {
|
|
44
|
+
this.meta = meta;
|
|
45
|
+
},
|
|
46
|
+
setPageTitle(title) {
|
|
47
|
+
this.meta.pageTitle = title;
|
|
48
|
+
},
|
|
49
|
+
setRoutes(routes) {
|
|
50
|
+
this.routes = routes;
|
|
51
|
+
},
|
|
52
|
+
setShowQuote(value) {
|
|
53
|
+
this.showQuote = value;
|
|
54
|
+
},
|
|
55
|
+
setUser(user) {
|
|
56
|
+
this.user = user;
|
|
57
|
+
},
|
|
58
|
+
set({
|
|
59
|
+
meta,
|
|
60
|
+
user,
|
|
61
|
+
routes,
|
|
62
|
+
defaultRoute,
|
|
63
|
+
impersonating,
|
|
64
|
+
}) {
|
|
65
|
+
this.setMeta(meta);
|
|
66
|
+
this.setUser(user);
|
|
67
|
+
this.setRoutes(routes);
|
|
68
|
+
this.setDefaultRoute(defaultRoute);
|
|
69
|
+
this.setImpersonating(impersonating);
|
|
70
|
+
},
|
|
71
|
+
updateAvatar() {
|
|
72
|
+
this.avatarKey += 1;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { preferences } from './preferences';
|
|
3
|
+
|
|
4
|
+
const root = () => document.documentElement;
|
|
5
|
+
|
|
6
|
+
const applyTheme = theme => {
|
|
7
|
+
const element = root();
|
|
8
|
+
|
|
9
|
+
if (theme === 'system') {
|
|
10
|
+
element.removeAttribute('data-theme');
|
|
11
|
+
element.style.colorScheme = 'light dark';
|
|
12
|
+
} else {
|
|
13
|
+
element.style.colorScheme = theme;
|
|
14
|
+
element.setAttribute('data-theme', theme);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const layout = defineStore('layout', {
|
|
19
|
+
state: () => ({
|
|
20
|
+
home: true,
|
|
21
|
+
isMobile: false,
|
|
22
|
+
isTablet: false,
|
|
23
|
+
isTouch: false,
|
|
24
|
+
footer: true,
|
|
25
|
+
header: true,
|
|
26
|
+
themes: [],
|
|
27
|
+
sidebar: {
|
|
28
|
+
isExpanded: true,
|
|
29
|
+
isVisible: true,
|
|
30
|
+
},
|
|
31
|
+
navbar: {
|
|
32
|
+
isVisible: false,
|
|
33
|
+
},
|
|
34
|
+
settings: {
|
|
35
|
+
isVisible: false,
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
actions: {
|
|
40
|
+
set({ themes }) {
|
|
41
|
+
this.themes = themes;
|
|
42
|
+
},
|
|
43
|
+
setHome(status) {
|
|
44
|
+
this.home = status;
|
|
45
|
+
},
|
|
46
|
+
setIsMobile(isMobile) {
|
|
47
|
+
this.isMobile = isMobile;
|
|
48
|
+
},
|
|
49
|
+
setIsTablet(isTablet) {
|
|
50
|
+
this.isTablet = isTablet;
|
|
51
|
+
},
|
|
52
|
+
setIsTouch(isTouch) {
|
|
53
|
+
this.isTouch = isTouch;
|
|
54
|
+
},
|
|
55
|
+
hideFooter() {
|
|
56
|
+
this.footer = false;
|
|
57
|
+
},
|
|
58
|
+
showFooter() {
|
|
59
|
+
this.footer = true;
|
|
60
|
+
},
|
|
61
|
+
hideHeader() {
|
|
62
|
+
this.header = false;
|
|
63
|
+
},
|
|
64
|
+
showHeader() {
|
|
65
|
+
this.header = true;
|
|
66
|
+
},
|
|
67
|
+
showSidebar() {
|
|
68
|
+
this.sidebar.isVisible = true;
|
|
69
|
+
},
|
|
70
|
+
hideSidebar() {
|
|
71
|
+
this.sidebar.isVisible = false;
|
|
72
|
+
},
|
|
73
|
+
expandSidebar() {
|
|
74
|
+
this.sidebar.isExpanded = true;
|
|
75
|
+
},
|
|
76
|
+
collapseSidebar() {
|
|
77
|
+
this.sidebar.isExpanded = false;
|
|
78
|
+
},
|
|
79
|
+
updateSidebar(status) {
|
|
80
|
+
this.sidebar.isExpanded = status;
|
|
81
|
+
},
|
|
82
|
+
toggleSidebar() {
|
|
83
|
+
if (this.isTouch) {
|
|
84
|
+
this.sidebar.isExpanded = true;
|
|
85
|
+
this.sidebar.isVisible = !this.sidebar.isVisible;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.sidebar.isVisible = true;
|
|
90
|
+
this.sidebar.isExpanded = !this.sidebar.isExpanded;
|
|
91
|
+
},
|
|
92
|
+
showNavbar() {
|
|
93
|
+
this.navbar.isVisible = true;
|
|
94
|
+
},
|
|
95
|
+
hideNavbar() {
|
|
96
|
+
this.navbar.isVisible = false;
|
|
97
|
+
},
|
|
98
|
+
toggleSettings() {
|
|
99
|
+
this.settings.isVisible = !this.settings.isVisible;
|
|
100
|
+
},
|
|
101
|
+
async setTheme(theme = null) {
|
|
102
|
+
const nextTheme = theme ?? preferences().global.theme;
|
|
103
|
+
|
|
104
|
+
applyTheme(nextTheme);
|
|
105
|
+
|
|
106
|
+
return Promise.resolve(nextTheme);
|
|
107
|
+
},
|
|
108
|
+
async loadTheme() {
|
|
109
|
+
return this.setTheme();
|
|
110
|
+
},
|
|
111
|
+
async switchTheme(theme = null) {
|
|
112
|
+
return this.setTheme(theme);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import App from '../core/app';
|
|
3
|
+
import eventBus from '../core/services/eventBus';
|
|
4
|
+
import { useStore } from '../core/services/pinia';
|
|
5
|
+
import { app as useApp } from './app';
|
|
6
|
+
import { layout } from './layout';
|
|
7
|
+
import { preferences } from './preferences';
|
|
8
|
+
import { websockets } from './websockets';
|
|
9
|
+
|
|
10
|
+
const load = (name, payload) => {
|
|
11
|
+
const store = useStore(name);
|
|
12
|
+
|
|
13
|
+
if (!store) {
|
|
14
|
+
throw new Error(`Unknown Pinia store "${name}"`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (typeof store.set !== 'function') {
|
|
18
|
+
throw new Error(`Store "${name}" must expose set(payload)`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
store.set(payload);
|
|
22
|
+
|
|
23
|
+
return store;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const loadAppState = async (state = useApp()) => {
|
|
27
|
+
try {
|
|
28
|
+
const { data } = await axios.get('/api/core/home');
|
|
29
|
+
|
|
30
|
+
data.forEach(({ store, state: payload }) => load(store, payload));
|
|
31
|
+
|
|
32
|
+
layout().updateSidebar(preferences().global.expandedSidebar);
|
|
33
|
+
window.Laravel = state.meta.csrfToken;
|
|
34
|
+
|
|
35
|
+
if (state.meta.sentryDsn) {
|
|
36
|
+
const { default: Sentry } = await import('../modules/sentry');
|
|
37
|
+
const sentry = new Sentry(App.instance, App.router);
|
|
38
|
+
sentry.init(state);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
eventBus.$emit('app-state-loaded');
|
|
42
|
+
|
|
43
|
+
await layout().setTheme();
|
|
44
|
+
await websockets().connect(state.meta.csrfToken);
|
|
45
|
+
|
|
46
|
+
if (state.meta.env === 'local') {
|
|
47
|
+
window.http = axios;
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error.response && error.response.status === 401) {
|
|
51
|
+
useStore('auth')?.logout();
|
|
52
|
+
App.router?.push({ name: 'login' });
|
|
53
|
+
} else {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const loadGuestState = async (state = useApp()) => {
|
|
60
|
+
const { data } = await axios.get('/api/meta', {
|
|
61
|
+
params: { locale: localStorage.getItem('locale') },
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const { meta, i18n, routes } = data;
|
|
65
|
+
const lang = Object.keys(i18n).shift();
|
|
66
|
+
|
|
67
|
+
useStore('localisation')?.setI18n(i18n);
|
|
68
|
+
preferences().setLangValue(lang);
|
|
69
|
+
state.setMeta(meta);
|
|
70
|
+
state.setRoutes(routes);
|
|
71
|
+
|
|
72
|
+
const loginRoutes = ['login', 'password.email', 'password.reset'];
|
|
73
|
+
const route = App.router?.currentRoute?.value;
|
|
74
|
+
|
|
75
|
+
if (!route || !loginRoutes.includes(route.name)) {
|
|
76
|
+
App.router?.push({ name: 'login' });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
|
+
import { currentRoute } from '../core/services/pinia';
|
|
4
|
+
import { layout } from './layout';
|
|
5
|
+
|
|
6
|
+
const storePreference = payload => axios.patch('/api/core/preferences/store', payload);
|
|
7
|
+
|
|
8
|
+
export const preferences = defineStore('preferences', {
|
|
9
|
+
state: () => ({
|
|
10
|
+
global: {},
|
|
11
|
+
local: {},
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
getters: {
|
|
15
|
+
lang: state => state.global.lang,
|
|
16
|
+
theme: state => state.global.theme,
|
|
17
|
+
expandedSidebar: state => state.global.expandedSidebar,
|
|
18
|
+
toastrPosition: state => state.global.toastrPosition,
|
|
19
|
+
bookmarks: state => state.global.bookmarks,
|
|
20
|
+
localByRoute: state => route => state.local[route],
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
actions: {
|
|
24
|
+
set(preferences) {
|
|
25
|
+
this.global = preferences.global;
|
|
26
|
+
this.local = preferences.local;
|
|
27
|
+
},
|
|
28
|
+
setGlobalValue({ key, value }) {
|
|
29
|
+
this.global[key] = value;
|
|
30
|
+
},
|
|
31
|
+
setLangValue(lang) {
|
|
32
|
+
this.global.lang = lang;
|
|
33
|
+
},
|
|
34
|
+
setThemeValue(theme) {
|
|
35
|
+
this.global.theme = theme;
|
|
36
|
+
},
|
|
37
|
+
setToastrPositionValue(position) {
|
|
38
|
+
this.global.toastrPosition = position;
|
|
39
|
+
},
|
|
40
|
+
setExpandedSidebarValue(expandedSidebar) {
|
|
41
|
+
this.global.expandedSidebar = expandedSidebar;
|
|
42
|
+
},
|
|
43
|
+
setBookmarksValue(bookmarks) {
|
|
44
|
+
this.global.bookmarks = bookmarks;
|
|
45
|
+
},
|
|
46
|
+
setLocalValue(value) {
|
|
47
|
+
const route = currentRoute();
|
|
48
|
+
|
|
49
|
+
if (route?.name) {
|
|
50
|
+
this.local[route.name] = value;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
async setGlobal(payload) {
|
|
54
|
+
this.setGlobalValue(payload);
|
|
55
|
+
await storePreference({ global: this.global });
|
|
56
|
+
},
|
|
57
|
+
async setLocal(value) {
|
|
58
|
+
this.setLocalValue(value);
|
|
59
|
+
|
|
60
|
+
const route = currentRoute();
|
|
61
|
+
|
|
62
|
+
if (route?.name) {
|
|
63
|
+
await storePreference({ route: route.name, value });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
async setLang(lang) {
|
|
67
|
+
this.setLangValue(lang);
|
|
68
|
+
localStorage.setItem('locale', lang);
|
|
69
|
+
await storePreference({ global: this.global });
|
|
70
|
+
},
|
|
71
|
+
async setTheme(theme) {
|
|
72
|
+
this.setThemeValue(theme);
|
|
73
|
+
await layout().switchTheme(theme);
|
|
74
|
+
await storePreference({ global: this.global });
|
|
75
|
+
},
|
|
76
|
+
async setToastrPosition(position) {
|
|
77
|
+
this.setToastrPositionValue(position);
|
|
78
|
+
await storePreference({ global: this.global });
|
|
79
|
+
},
|
|
80
|
+
async setBookmarksState(bookmarks) {
|
|
81
|
+
this.setBookmarksValue(bookmarks);
|
|
82
|
+
await storePreference({ global: this.global });
|
|
83
|
+
},
|
|
84
|
+
async setSidebarState(state) {
|
|
85
|
+
this.setExpandedSidebarValue(state);
|
|
86
|
+
layout().updateSidebar(state);
|
|
87
|
+
await storePreference({ global: this.global });
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Echo from 'laravel-echo';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
|
+
|
|
4
|
+
const resolvePusher = async () => {
|
|
5
|
+
const module = await import('pusher-js');
|
|
6
|
+
const Pusher = module.default ?? module;
|
|
7
|
+
|
|
8
|
+
window.Pusher = Pusher;
|
|
9
|
+
|
|
10
|
+
return Pusher;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const initEcho = async ({ authEndpoint, pusher }, csrfToken) => {
|
|
14
|
+
await resolvePusher();
|
|
15
|
+
|
|
16
|
+
window.Echo = new Echo({
|
|
17
|
+
broadcaster: 'pusher',
|
|
18
|
+
key: pusher.key,
|
|
19
|
+
cluster: pusher.options.cluster,
|
|
20
|
+
useTLS: pusher.options.useTLS,
|
|
21
|
+
namespace: 'App.Events',
|
|
22
|
+
csrfToken,
|
|
23
|
+
authEndpoint,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return window.Echo;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const websockets = defineStore('websockets', {
|
|
30
|
+
state: () => ({
|
|
31
|
+
authEndpoint: null,
|
|
32
|
+
channels: null,
|
|
33
|
+
pusher: null,
|
|
34
|
+
}),
|
|
35
|
+
|
|
36
|
+
actions: {
|
|
37
|
+
set(config) {
|
|
38
|
+
this.channels = config.channels;
|
|
39
|
+
this.pusher = config.pusher;
|
|
40
|
+
this.authEndpoint = config.authEndpoint;
|
|
41
|
+
},
|
|
42
|
+
async connect(csrfToken) {
|
|
43
|
+
if (!window.Echo && this.authEndpoint && this.pusher) {
|
|
44
|
+
await initEcho(this, csrfToken);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createStore } from 'vuex';
|
|
2
|
-
import Resources from './resources';
|
|
3
|
-
import importer from '../../modules/importers/storeImporter';
|
|
4
|
-
import {
|
|
5
|
-
actions, getters, modules, mutations, state,
|
|
6
|
-
} from '../../modules/store';
|
|
7
|
-
|
|
8
|
-
const packageStore = () => {
|
|
9
|
-
const modules = importer(Resources.store());
|
|
10
|
-
|
|
11
|
-
return Object.keys(modules).reduce((module, key) => {
|
|
12
|
-
module[key.split('/').pop()] = modules[key];
|
|
13
|
-
return module;
|
|
14
|
-
}, {});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
Object.assign(modules, packageStore(), importer(Resources.localStore()));
|
|
18
|
-
|
|
19
|
-
export default createStore({
|
|
20
|
-
strict: process.env.NODE_ENV !== 'production',
|
|
21
|
-
modules,
|
|
22
|
-
state,
|
|
23
|
-
getters,
|
|
24
|
-
mutations,
|
|
25
|
-
actions,
|
|
26
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const storeImporter = requireContext => requireContext.keys()
|
|
2
|
-
.map(fileName => [fileName.replace(/(^.\/)|(\.js$)/g, ''), requireContext(fileName)])
|
|
3
|
-
.reduce((modules, [name, module]) => {
|
|
4
|
-
module.namespaced = true;
|
|
5
|
-
return Object.assign({}, modules, { [name]: module });
|
|
6
|
-
}, {});
|
|
7
|
-
|
|
8
|
-
export default storeImporter;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const themeImporter = requireContext => requireContext.keys()
|
|
2
|
-
.map(fileName => [fileName.replace(/(^.\/)|(\.lazy.scss$)/g, ''), requireContext(fileName)])
|
|
3
|
-
.reduce((themes, [name, theme]) => ({ ...themes, [name]: theme.default }), {});
|
|
4
|
-
|
|
5
|
-
export default themeImporter;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const state = {
|
|
2
|
-
isExpanded: true,
|
|
3
|
-
isVisible: true,
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export const mutations = {
|
|
7
|
-
show: state => (state.isVisible = true),
|
|
8
|
-
hide: state => (state.isVisible = false),
|
|
9
|
-
expand: state => (state.isExpanded = true),
|
|
10
|
-
collapse: state => (state.isExpanded = false),
|
|
11
|
-
update: (state, status) => (state.isExpanded = status),
|
|
12
|
-
toggle: (state, isTouch) => {
|
|
13
|
-
if (isTouch) {
|
|
14
|
-
state.isExpanded = true;
|
|
15
|
-
state.isVisible = !state.isVisible;
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
state.isVisible = true;
|
|
20
|
-
state.isExpanded = !state.isExpanded;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import storeImporter from '../importers/storeImporter';
|
|
2
|
-
import themeImporter from '../importers/themeImporter';
|
|
3
|
-
|
|
4
|
-
const themes = themeImporter(require.context('@enso-ui/themes/bulma', false, /.*\.lazy\.scss$/));
|
|
5
|
-
|
|
6
|
-
export const modules = storeImporter(require.context('./layout', false, /.*\.js$/));
|
|
7
|
-
|
|
8
|
-
export const state = {
|
|
9
|
-
home: true,
|
|
10
|
-
themes: {},
|
|
11
|
-
lightsOff: false,
|
|
12
|
-
isMobile: false,
|
|
13
|
-
isTablet: false,
|
|
14
|
-
isTouch: false,
|
|
15
|
-
footer: true,
|
|
16
|
-
header: true,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const getters = {
|
|
20
|
-
current: (state, getters, rootState) => {
|
|
21
|
-
if (!rootState.auth.isAuth) {
|
|
22
|
-
return 'auth';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return state.home
|
|
26
|
-
? 'home'
|
|
27
|
-
: 'default';
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const mutations = {
|
|
32
|
-
home: (state, status) => (state.home = status),
|
|
33
|
-
setThemes: (state, themes) => (state.themes = themes),
|
|
34
|
-
toggleLights: state => (state.lightsOff = !state.lightsOff),
|
|
35
|
-
setIsMobile: (state, isMobile) => (state.isMobile = isMobile),
|
|
36
|
-
setIsTablet: (state, isTablet) => (state.isTablet = isTablet),
|
|
37
|
-
setIsTouch: (state, isTouch) => (state.isTouch = isTouch),
|
|
38
|
-
hideFooter: state => (state.footer = false),
|
|
39
|
-
showFooter: state => (state.footer = true),
|
|
40
|
-
hideHeader: state => (state.header = false),
|
|
41
|
-
showHeader: state => (state.header = true),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const actions = {
|
|
45
|
-
setTheme: ({ state, rootGetters }, theme = null) => {
|
|
46
|
-
if (!theme) {
|
|
47
|
-
theme = state.themes[rootGetters['preferences/theme']];
|
|
48
|
-
localStorage.setItem('theme', theme);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Object.keys(themes).forEach(theme => themes[theme].unuse());
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
themes[theme].use();
|
|
55
|
-
} catch (e) {
|
|
56
|
-
themes.light.use();
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
loadTheme: async ({ dispatch }) => {
|
|
60
|
-
const theme = localStorage.getItem('theme') || 'light';
|
|
61
|
-
|
|
62
|
-
if (theme) {
|
|
63
|
-
await dispatch('setTheme', theme);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
switchTheme: async ({ commit, dispatch }) => {
|
|
67
|
-
commit('toggleLights');
|
|
68
|
-
|
|
69
|
-
await setTimeout(() => dispatch('setTheme')
|
|
70
|
-
.then(() => commit('toggleLights')), 150);
|
|
71
|
-
},
|
|
72
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import route from '../plugins/route';
|
|
3
|
-
|
|
4
|
-
export const state = {
|
|
5
|
-
global: {},
|
|
6
|
-
local: {},
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const store = payload => axios.patch(route('core.preferences.store'), payload);
|
|
10
|
-
|
|
11
|
-
const updateGlobal = () => store({ global: state.global });
|
|
12
|
-
|
|
13
|
-
export const getters = {
|
|
14
|
-
global: state => state.global,
|
|
15
|
-
local: state => route => state.local[route],
|
|
16
|
-
lang: state => state.global.lang,
|
|
17
|
-
theme: state => state.global.theme,
|
|
18
|
-
expandedSidebar: state => state.global.expandedSidebar,
|
|
19
|
-
toastrPosition: state => state.global.toastrPosition,
|
|
20
|
-
bookmarks: state => state.global.bookmarks,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const mutations = {
|
|
24
|
-
set: (state, preferences) => {
|
|
25
|
-
state.global = preferences.global;
|
|
26
|
-
state.local = preferences.local;
|
|
27
|
-
},
|
|
28
|
-
global: (state, { key, value }) => (state.global[key] = value),
|
|
29
|
-
lang: (state, lang) => (state.global.lang = lang),
|
|
30
|
-
theme: (state, theme) => (state.global.theme = theme),
|
|
31
|
-
toastrPosition: (state, position) => (state.global.toastrPosition = position),
|
|
32
|
-
expandedSidebar: (state, expandedSidebar) => (state.global.expandedSidebar = expandedSidebar),
|
|
33
|
-
bookmarks: (state, bookmarks) => (state.global.bookmarks = bookmarks),
|
|
34
|
-
local: (state, value) => (state.local[state.route.name] = value),
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const actions = {
|
|
38
|
-
setGlobal: async ({ commit }, payload) => {
|
|
39
|
-
commit('global', payload);
|
|
40
|
-
await updateGlobal();
|
|
41
|
-
},
|
|
42
|
-
setLocal: ({ commit, state }, value) => {
|
|
43
|
-
commit('local', value);
|
|
44
|
-
store({ route: state.route.name, value });
|
|
45
|
-
},
|
|
46
|
-
setLang: async ({
|
|
47
|
-
commit, dispatch, getters, rootGetters,
|
|
48
|
-
}, lang) => {
|
|
49
|
-
const isRtl = rootGetters['localisation/rtl'];
|
|
50
|
-
commit('lang', lang);
|
|
51
|
-
localStorage.setItem('locale', lang);
|
|
52
|
-
|
|
53
|
-
if (rootGetters['localisation/isRtl'](lang) !== isRtl) {
|
|
54
|
-
await dispatch('setTheme', getters.theme);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await updateGlobal();
|
|
58
|
-
},
|
|
59
|
-
setTheme: async ({ commit, dispatch, rootGetters }, theme) => {
|
|
60
|
-
const isRtl = rootGetters['localisation/rtl'];
|
|
61
|
-
const nextTheme = theme.replace('-rtl', '') + (isRtl ? '-rtl' : '');
|
|
62
|
-
commit('theme', nextTheme);
|
|
63
|
-
|
|
64
|
-
await dispatch('layout/switchTheme', null, { root: true })
|
|
65
|
-
.then(() => updateGlobal());
|
|
66
|
-
},
|
|
67
|
-
setToastrPosition: async ({ commit }, position) => {
|
|
68
|
-
commit('toastrPosition', position);
|
|
69
|
-
await updateGlobal();
|
|
70
|
-
},
|
|
71
|
-
setBookmarksState: async ({ commit }, bookmarks) => {
|
|
72
|
-
commit('bookmarks', bookmarks);
|
|
73
|
-
await updateGlobal();
|
|
74
|
-
},
|
|
75
|
-
setSidebarState: async ({ commit }, state) => {
|
|
76
|
-
commit('expandedSidebar', state);
|
|
77
|
-
commit('layout/sidebar/update', state, { root: true });
|
|
78
|
-
await updateGlobal();
|
|
79
|
-
},
|
|
80
|
-
};
|