@enso-ui/ui 6.2.6 → 7.0.0
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/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 -12
- 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,86 +1,79 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
3
|
-
mapState, mapGetters, mapMutations, mapActions,
|
|
4
|
-
} from 'vuex';
|
|
5
2
|
import eventBus from '../services/eventBus';
|
|
3
|
+
import { useStore } from '../services/pinia';
|
|
4
|
+
import { layout as useLayout } from '../../pinia/layout';
|
|
5
|
+
import { preferences as usePreferences } from '../../pinia/preferences';
|
|
6
|
+
import { loadAppState } from '../../pinia/loadState';
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
name: 'Default',
|
|
9
10
|
|
|
10
11
|
inject: ['errorHandler', 'http', 'route', 'toastr'],
|
|
11
12
|
|
|
13
|
+
data: () => ({
|
|
14
|
+
appState: false,
|
|
15
|
+
}),
|
|
16
|
+
|
|
12
17
|
computed: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'header', 'isTablet', 'isMobile', 'sidebar', 'settings', 'footer',
|
|
16
|
-
]),
|
|
17
|
-
...mapGetters('localisation', ['rtl']),
|
|
18
|
-
...mapGetters('preferences', ['bookmarks', 'toastrPosition']),
|
|
19
|
-
slideIn() {
|
|
20
|
-
return this.rtl ? 'slideInLeft' : 'slideInRight';
|
|
21
|
-
},
|
|
22
|
-
slideOut() {
|
|
23
|
-
return this.rtl ? 'slideOutLeft' : 'slideOutRight';
|
|
18
|
+
isTablet() {
|
|
19
|
+
return useLayout().isTablet;
|
|
24
20
|
},
|
|
25
21
|
},
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.$router.push({name: 'default'});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
immediate: true,
|
|
23
|
+
methods: {
|
|
24
|
+
rtl() {
|
|
25
|
+
const localisation = useStore('localisation');
|
|
26
|
+
const lang = usePreferences().global.lang;
|
|
27
|
+
const rtl = localisation?.rtlLanguages ?? [];
|
|
28
|
+
|
|
29
|
+
return rtl.includes(lang);
|
|
39
30
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return this.isTablet
|
|
43
|
-
? this.hideSidebar()
|
|
44
|
-
: this.showSidebar();
|
|
45
|
-
},
|
|
31
|
+
setIsTablet(value) {
|
|
32
|
+
useLayout().setIsTablet(value);
|
|
46
33
|
},
|
|
47
|
-
|
|
34
|
+
setIsMobile(value) {
|
|
35
|
+
useLayout().setIsMobile(value);
|
|
36
|
+
},
|
|
37
|
+
setIsTouch(value) {
|
|
38
|
+
useLayout().setIsTouch(value);
|
|
39
|
+
},
|
|
40
|
+
showSidebar() {
|
|
41
|
+
useLayout().showSidebar();
|
|
42
|
+
},
|
|
43
|
+
hideSidebar() {
|
|
44
|
+
useLayout().hideSidebar();
|
|
45
|
+
},
|
|
46
|
+
async bootstrap() {
|
|
47
|
+
this.appState = false;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
await this.connect();
|
|
51
|
-
eventBus.$on('start-impersonating', this.startImpersonating);
|
|
52
|
-
eventBus.$on('stop-impersonating', this.stopImpersonating);
|
|
53
|
-
},
|
|
49
|
+
await loadAppState();
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
this.addTouchBreakpointsListeners();
|
|
57
|
-
this.updateTouchMode();
|
|
58
|
-
},
|
|
51
|
+
this.toastr.setup(usePreferences().global.toastrPosition);
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
if (this.$route.path === '/') {
|
|
54
|
+
this.$router.push({ name: 'default' });
|
|
55
|
+
}
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...mapMutations('layout/sidebar', { showSidebar: 'show', hideSidebar: 'hide' }),
|
|
67
|
-
...mapActions(['loadAppState']),
|
|
68
|
-
...mapActions('websockets', ['connect']),
|
|
57
|
+
this.appState = true;
|
|
58
|
+
},
|
|
69
59
|
addTouchBreakpointsListeners() {
|
|
70
60
|
document.addEventListener('visibilitychange', this.updateTouchMode);
|
|
71
61
|
window.addEventListener('DOMContentLoaded', this.updateTouchMode);
|
|
72
62
|
window.addEventListener('resize', this.updateTouchMode);
|
|
63
|
+
window.visualViewport?.addEventListener('resize', this.updateTouchMode);
|
|
73
64
|
},
|
|
74
65
|
updateTouchMode() {
|
|
75
66
|
const TabletMaxWidth = 1023;
|
|
76
67
|
const MobileMaxWidth = 768;
|
|
77
68
|
|
|
78
69
|
if (!document.hidden) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
const width = window.visualViewport?.width
|
|
71
|
+
|| document.documentElement.clientWidth
|
|
72
|
+
|| window.innerWidth;
|
|
73
|
+
this.setIsTablet(width <= TabletMaxWidth);
|
|
74
|
+
this.setIsMobile(width <= MobileMaxWidth);
|
|
82
75
|
this.setIsTouch(
|
|
83
|
-
|
|
76
|
+
width <= TabletMaxWidth || width <= MobileMaxWidth,
|
|
84
77
|
);
|
|
85
78
|
}
|
|
86
79
|
},
|
|
@@ -88,34 +81,72 @@ export default {
|
|
|
88
81
|
document.removeEventListener('visibilitychange', this.updateTouchMode);
|
|
89
82
|
window.removeEventListener('DOMContentLoaded', this.updateTouchMode);
|
|
90
83
|
window.removeEventListener('resize', this.updateTouchMode);
|
|
84
|
+
window.visualViewport?.removeEventListener('resize', this.updateTouchMode);
|
|
91
85
|
},
|
|
92
86
|
startImpersonating(id) {
|
|
93
87
|
this.http.get(this.route('core.impersonate.start', id))
|
|
94
88
|
.then(({ data }) => {
|
|
95
89
|
this.toastr.warning(data.message);
|
|
96
|
-
this.
|
|
90
|
+
this.bootstrap();
|
|
97
91
|
}).catch(this.errorHandler);
|
|
98
92
|
},
|
|
99
93
|
stopImpersonating() {
|
|
100
94
|
this.http.get(this.route('core.impersonate.stop'))
|
|
101
95
|
.then(({ data }) => {
|
|
102
96
|
this.toastr.info(data.message);
|
|
103
|
-
this.
|
|
97
|
+
this.bootstrap();
|
|
104
98
|
}).catch(this.errorHandler);
|
|
105
99
|
},
|
|
106
100
|
},
|
|
107
101
|
|
|
102
|
+
watch: {
|
|
103
|
+
isTablet: {
|
|
104
|
+
handler() {
|
|
105
|
+
return this.isTablet
|
|
106
|
+
? this.hideSidebar()
|
|
107
|
+
: this.showSidebar();
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
async created() {
|
|
113
|
+
eventBus.$on('start-impersonating', this.startImpersonating);
|
|
114
|
+
eventBus.$on('stop-impersonating', this.stopImpersonating);
|
|
115
|
+
await this.bootstrap();
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
beforeMount() {
|
|
119
|
+
this.addTouchBreakpointsListeners();
|
|
120
|
+
this.updateTouchMode();
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
unmounted() {
|
|
124
|
+
this.removeTouchBreakpointsListeners();
|
|
125
|
+
},
|
|
126
|
+
|
|
108
127
|
render() {
|
|
128
|
+
if (!this.appState) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const layout = useLayout();
|
|
133
|
+
const preferences = usePreferences();
|
|
134
|
+
const {
|
|
135
|
+
header, sidebar, settings, footer,
|
|
136
|
+
} = layout;
|
|
137
|
+
const { bookmarks } = preferences.global;
|
|
138
|
+
const rtl = this.rtl();
|
|
139
|
+
|
|
109
140
|
return this.$slots.default({
|
|
110
|
-
appState:
|
|
111
|
-
sidebar
|
|
112
|
-
rtl
|
|
113
|
-
slideIn:
|
|
114
|
-
slideOut:
|
|
115
|
-
settings
|
|
116
|
-
bookmarks
|
|
117
|
-
header
|
|
118
|
-
footer
|
|
141
|
+
appState: true,
|
|
142
|
+
sidebar,
|
|
143
|
+
rtl,
|
|
144
|
+
slideIn: rtl ? 'slideInLeft' : 'slideInRight',
|
|
145
|
+
slideOut: rtl ? 'slideOutLeft' : 'slideOutRight',
|
|
146
|
+
settings,
|
|
147
|
+
bookmarks,
|
|
148
|
+
header,
|
|
149
|
+
footer,
|
|
119
150
|
});
|
|
120
151
|
},
|
|
121
152
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
2
|
+
import { useStore } from '../services/pinia';
|
|
3
|
+
import { app } from '../../pinia/app';
|
|
4
|
+
import { layout } from '../../pinia/layout';
|
|
5
|
+
import { loadAppState } from '../../pinia/loadState';
|
|
3
6
|
|
|
4
7
|
export default {
|
|
5
8
|
name: 'Home',
|
|
@@ -10,44 +13,40 @@ export default {
|
|
|
10
13
|
loading: true,
|
|
11
14
|
}),
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...mapState(['appState', 'showQuote']),
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
watch: {
|
|
20
|
-
appState(appState) {
|
|
21
|
-
if (appState) {
|
|
22
|
-
this.enterApp();
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
created() {
|
|
28
|
-
this.loadAppState();
|
|
16
|
+
async created() {
|
|
17
|
+
await loadAppState();
|
|
18
|
+
this.enterApp();
|
|
29
19
|
},
|
|
30
20
|
|
|
31
21
|
methods: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
setIntendedRoute(value) {
|
|
23
|
+
useStore('auth')?.setIntendedRoute(value);
|
|
24
|
+
},
|
|
25
|
+
setIntendedPath(value) {
|
|
26
|
+
useStore('auth')?.setIntendedPath(value);
|
|
27
|
+
},
|
|
35
28
|
enterApp() {
|
|
29
|
+
const showQuote = app().showQuote;
|
|
30
|
+
|
|
36
31
|
this.redirectIfNeeded();
|
|
37
32
|
this.loading = false;
|
|
38
33
|
|
|
39
|
-
if (!
|
|
34
|
+
if (!showQuote) {
|
|
40
35
|
this.hide();
|
|
41
36
|
}
|
|
42
37
|
},
|
|
43
38
|
redirectIfNeeded() {
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const auth = useStore('auth');
|
|
40
|
+
const intendedRoute = auth?.intendedRoute;
|
|
41
|
+
const intendedPath = auth?.intendedPath;
|
|
42
|
+
|
|
43
|
+
if (intendedRoute) {
|
|
44
|
+
const { name, params, query } = intendedRoute;
|
|
46
45
|
this.$router.push({ name, params, query })
|
|
47
46
|
.catch(this.routerErrorHandler);
|
|
48
47
|
this.setIntendedRoute(null);
|
|
49
|
-
} else if (
|
|
50
|
-
this.$router.push({ path:
|
|
48
|
+
} else if (intendedPath) {
|
|
49
|
+
this.$router.push({ path: intendedPath })
|
|
51
50
|
.catch(this.routerErrorHandler);
|
|
52
51
|
this.setIntendedPath(null);
|
|
53
52
|
} else if (this.$route.meta.guestGuard) {
|
|
@@ -56,15 +55,15 @@ export default {
|
|
|
56
55
|
}
|
|
57
56
|
},
|
|
58
57
|
hide() {
|
|
59
|
-
|
|
58
|
+
layout().setHome(false);
|
|
60
59
|
},
|
|
61
60
|
},
|
|
62
61
|
|
|
63
62
|
render() {
|
|
64
63
|
return this.$slots.default({
|
|
65
64
|
loading: this.loading,
|
|
66
|
-
showQuote:
|
|
67
|
-
quote:
|
|
65
|
+
showQuote: app().showQuote,
|
|
66
|
+
quote: app().meta.quote,
|
|
68
67
|
hide: this.hide,
|
|
69
68
|
});
|
|
70
69
|
},
|
|
@@ -1,15 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const makeContext = (modules, { keyTransform } = {}) => {
|
|
2
|
+
const entries = Object.entries(modules).map(([key, value]) => [
|
|
3
|
+
keyTransform ? keyTransform(key) : key,
|
|
4
|
+
value,
|
|
5
|
+
]);
|
|
6
|
+
|
|
7
|
+
const map = Object.fromEntries(entries);
|
|
8
|
+
const keys = Object.keys(map);
|
|
9
|
+
|
|
10
|
+
const context = (key) => {
|
|
11
|
+
if (!(key in map)) {
|
|
12
|
+
const error = new Error(`Cannot find module '${key}'`);
|
|
13
|
+
error.code = 'MODULE_NOT_FOUND';
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return map[key];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
context.keys = () => keys;
|
|
21
|
+
context.resolve = key => key;
|
|
22
|
+
context.id = 'vite-require-context';
|
|
23
|
+
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const localRoutes = () => makeContext(
|
|
28
|
+
import.meta.glob('/src/js/routes/*.js', { eager: true }),
|
|
29
|
+
{
|
|
30
|
+
keyTransform: key => key.replace('/src/js/routes/', './'),
|
|
10
31
|
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const coreRoutes = () => makeContext(
|
|
35
|
+
import.meta.glob('/node_modules/@enso-ui/ui/src/bulma/routes/*.js', { eager: true }),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const icons = () => makeContext(
|
|
39
|
+
import.meta.glob('/node_modules/@enso-ui/**/src/icons.js', { eager: true }),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const register = () => makeContext(
|
|
43
|
+
import.meta.glob('/node_modules/@enso-ui/**/src/bulma/register.js', { eager: true }),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const routes = () => makeContext(
|
|
47
|
+
import.meta.glob('/node_modules/@enso-ui/**/src/bulma/routes/*.js', { eager: true }),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
bulma: { coreRoutes, icons, register, routes },
|
|
11
52
|
local: {
|
|
12
|
-
|
|
13
|
-
routes: require.context('@root/routes', false, /.*\.js$/),
|
|
53
|
+
routes: localRoutes,
|
|
14
54
|
},
|
|
15
55
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { showReportDialog } from '@sentry/browser';
|
|
2
2
|
import { isNavigationFailure } from 'vue-router';
|
|
3
|
+
import { useStore } from './pinia';
|
|
3
4
|
|
|
4
5
|
const routerErrorHandler = error => {
|
|
5
6
|
if (!isNavigationFailure(error)) {
|
|
@@ -30,15 +31,14 @@ const getUserFeedback = vm => vm.http.get('api/sentry')
|
|
|
30
31
|
|
|
31
32
|
const redirectToLogin = vm => {
|
|
32
33
|
if (vm.$route.name !== 'login') {
|
|
33
|
-
|
|
34
|
+
useStore('auth')?.setIntendedRoute(vm.$route);
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
vm.$store.commit('auth/logout');
|
|
36
|
+
useStore('auth')?.logout();
|
|
37
37
|
vm.$router.push({ name: 'login' })
|
|
38
38
|
.catch(routerErrorHandler);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const report = vm => (
|
|
41
|
+
const report = vm => ((useStore('app')?.meta?.env) === 'production'
|
|
42
42
|
? getUserFeedback(vm)
|
|
43
43
|
: toastError(vm));
|
|
44
44
|
|
|
@@ -2,48 +2,53 @@ import contexts from './contexts';
|
|
|
2
2
|
|
|
3
3
|
class Resources {
|
|
4
4
|
constructor() {
|
|
5
|
-
this.profile =
|
|
5
|
+
this.profile = 'bulma';
|
|
6
6
|
this.contexts = contexts;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
boot() {
|
|
10
|
-
this.requireContext(this.register())
|
|
9
|
+
boot(app) {
|
|
10
|
+
this.requireContext(this.register(), app)
|
|
11
11
|
.requireContext(this.icons());
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
coreRoutes() {
|
|
15
|
-
return this.contexts[this.profile].coreRoutes;
|
|
15
|
+
return this.resolve(this.contexts[this.profile].coreRoutes);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
icons() {
|
|
19
|
-
return this.contexts[this.profile].icons;
|
|
19
|
+
return this.resolve(this.contexts[this.profile].icons);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
register() {
|
|
23
|
-
return this.contexts[this.profile].register;
|
|
23
|
+
return this.resolve(this.contexts[this.profile].register);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
routes() {
|
|
27
|
-
return this.contexts[this.profile].routes;
|
|
27
|
+
return this.resolve(this.contexts[this.profile].routes);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
localRoutes() {
|
|
31
|
-
return this.contexts.local.routes;
|
|
31
|
+
return this.resolve(this.contexts.local.routes);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
localStore() {
|
|
39
|
-
return this.contexts.local.store;
|
|
40
|
-
}
|
|
34
|
+
requireContext(requireContext, app = null) {
|
|
35
|
+
requireContext.keys().forEach(file => {
|
|
36
|
+
const module = requireContext(file);
|
|
37
|
+
const register = module?.default ?? module;
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
if (app && typeof register === 'function') {
|
|
40
|
+
register(app);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
44
43
|
|
|
45
44
|
return this;
|
|
46
45
|
}
|
|
46
|
+
|
|
47
|
+
resolve(contextOrFactory) {
|
|
48
|
+
return typeof contextOrFactory === 'function'
|
|
49
|
+
? contextOrFactory()
|
|
50
|
+
: contextOrFactory;
|
|
51
|
+
}
|
|
47
52
|
};
|
|
48
53
|
|
|
49
54
|
export default new Resources();
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { createRouter, createWebHistory } from 'vue-router';
|
|
2
2
|
import RouteBuilder from './routeBuilder';
|
|
3
|
-
import store from './store';
|
|
4
3
|
import before from '../../middleware/before';
|
|
5
4
|
|
|
6
5
|
const router = createRouter({
|
|
7
|
-
history: createWebHistory(
|
|
6
|
+
history: createWebHistory(import.meta.env.BASE_URL),
|
|
8
7
|
routes: new RouteBuilder().handle(),
|
|
9
8
|
scrollBehavior(to, from, savedPosition) {
|
|
10
9
|
return savedPosition || { left: 0, top: 0 };
|
|
11
10
|
},
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
router.beforeEach((to, from, next) => before(to, from, next
|
|
13
|
+
router.beforeEach((to, from, next) => before(to, from, next));
|
|
15
14
|
|
|
16
15
|
router.onError(error => {
|
|
17
16
|
const regExp = new RegExp('Loading chunk chunk-\\w* failed.');
|
package/src/icons.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
faEye,
|
|
4
|
+
faGears,
|
|
5
|
+
faListUl,
|
|
6
|
+
faPen,
|
|
7
|
+
faSliders,
|
|
8
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
3
9
|
|
|
4
|
-
library.add(
|
|
10
|
+
library.add(faEye, faGears, faListUl, faPen, faSliders);
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { useStore } from '../../core/services/pinia';
|
|
2
|
+
|
|
1
3
|
const exceptions = ['notFound', 'unauthorized', 'maintenanceMode'];
|
|
2
4
|
|
|
3
|
-
const authorized = (
|
|
4
|
-
||
|
|
5
|
+
const authorized = (app, to) => !app.meta?.appUrl
|
|
6
|
+
|| Object.keys(app.routes ?? {}).includes(to.name)
|
|
5
7
|
|| exceptions.includes(to.name);
|
|
6
8
|
|
|
7
|
-
export default (to, from, next
|
|
9
|
+
export default (to, from, next) => {
|
|
10
|
+
const app = useStore('app');
|
|
11
|
+
|
|
8
12
|
if (to.meta.guestGuard) {
|
|
9
13
|
next({ path: '/' });
|
|
10
|
-
} else if (
|
|
14
|
+
} else if (app.appUpdate) {
|
|
11
15
|
next(false);
|
|
12
|
-
} else if (!authorized(
|
|
16
|
+
} else if (!authorized(app, to)) {
|
|
13
17
|
next({ name: 'unauthorized' });
|
|
14
18
|
} else {
|
|
15
19
|
next();
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { useStore } from '../../core/services/pinia';
|
|
2
|
+
|
|
3
|
+
export default (to, from, next) => {
|
|
4
|
+
const auth = useStore('auth');
|
|
5
|
+
|
|
2
6
|
if (to.meta.guestGuard) {
|
|
3
7
|
next();
|
|
4
8
|
} else {
|
|
5
9
|
if (!['login', '/'].includes(window.location.pathname)) {
|
|
6
|
-
|
|
10
|
+
auth.setIntendedPath(window.location.pathname);
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
next({ name: 'login' });
|
package/src/middleware/before.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import guest from './before/guest';
|
|
2
2
|
import auth from './before/auth';
|
|
3
|
+
import { useStore } from '../core/services/pinia';
|
|
3
4
|
|
|
4
|
-
export default (to, from, next
|
|
5
|
-
if (
|
|
6
|
-
auth(to, from, next
|
|
5
|
+
export default (to, from, next) => {
|
|
6
|
+
if (useStore('auth')?.isAuth) {
|
|
7
|
+
auth(to, from, next);
|
|
7
8
|
} else {
|
|
8
|
-
guest(to, from, next
|
|
9
|
+
guest(to, from, next);
|
|
9
10
|
}
|
|
10
11
|
};
|
|
@@ -4,4 +4,27 @@ const routeImporter = requireContext => requireContext.keys()
|
|
|
4
4
|
? [...routes, ...route.default]
|
|
5
5
|
: [...routes, route.default]), []);
|
|
6
6
|
|
|
7
|
+
const makeContext = modules => {
|
|
8
|
+
const map = Object.fromEntries(Object.entries(modules));
|
|
9
|
+
const keys = Object.keys(map);
|
|
10
|
+
|
|
11
|
+
const context = key => {
|
|
12
|
+
if (!(key in map)) {
|
|
13
|
+
const error = new Error(`Cannot find module '${key}'`);
|
|
14
|
+
error.code = 'MODULE_NOT_FOUND';
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return map[key];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
context.keys = () => keys;
|
|
22
|
+
context.resolve = key => key;
|
|
23
|
+
context.id = 'vite-require-context';
|
|
24
|
+
|
|
25
|
+
return context;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
routeImporter.fromGlob = modules => routeImporter(makeContext(modules));
|
|
29
|
+
|
|
7
30
|
export default routeImporter;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import Enum from '@enso-ui/enums';
|
|
2
|
+
import { useStore } from '../../core/services/pinia';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const translate = key => {
|
|
5
|
+
const localisation = useStore('localisation');
|
|
6
|
+
|
|
7
|
+
return localisation?.ready
|
|
8
|
+
? localisation.translate(key)
|
|
9
|
+
: key;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bootEnums = (enums, i18n = translate) => {
|
|
4
13
|
const obj = {};
|
|
5
14
|
|
|
6
15
|
Object.keys(enums)
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import format from '@enso-ui/date/src/format.js';
|
|
2
|
-
import
|
|
2
|
+
import { useStore } from '../../../core/services/pinia';
|
|
3
3
|
|
|
4
|
-
export default (date, formatStr = null) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default (date, formatStr = null) => {
|
|
5
|
+
const state = useStore('app');
|
|
6
|
+
const preferences = useStore('preferences');
|
|
7
|
+
|
|
8
|
+
return format(
|
|
9
|
+
date,
|
|
10
|
+
formatStr || state.meta.dateFormat,
|
|
11
|
+
preferences.global.lang,
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import store from '../../../core/services/store';
|
|
2
1
|
import formatDistance from '@enso-ui/date/src/formatDistance.js';
|
|
2
|
+
import { useStore } from '../../../core/services/pinia';
|
|
3
3
|
|
|
4
|
-
export default date => formatDistance(date,
|
|
4
|
+
export default date => formatDistance(date, useStore('preferences').global.lang);
|