From 213dbd6f01af59e7633adb2709ce24276569a8f3 Mon Sep 17 00:00:00 2001 From: "r.zaritskyi" Date: Mon, 17 Jun 2024 15:54:11 +0300 Subject: [PATCH 01/32] refactor: directory and mixins[WTEL-4559] --- package-lock.json | 55 ++++--- package.json | 3 +- src/app/api/instance.js | 1 + .../baseObjectMixin/baseObjectMixin.js | 18 ++- .../baseTableMixin/itemLinkMixin.js | 2 +- .../objectTableMixin/tableComponentMixin.js | 2 +- .../openedObjectAccessControlMixin.js | 2 +- .../openedObjectMixin/openedObjectMixin.js | 16 ++- .../openedObjectTabAccessControlMixin.js | 2 +- .../openedObjectTableTabMixin.js | 5 +- .../permissionsTabMixin.js | 20 +++ src/app/plugins/webitel-ui.js | 2 +- .../_internals/tabs/DevicesRouteNames.enum.js | 10 ++ .../tabs/LicencesRouteNames.enum.js | 6 + .../_internals/tabs/UsersRouteNames.enum.js | 11 ++ src/app/router/router.js | 136 +++++++++++++----- src/main.js | 3 + .../components/permissions-tab-role-popup.vue | 3 +- .../components/permissions-tab.vue | 4 +- .../components/upload-csv-popup.vue | 3 +- .../upload-csv-popup/mixins/uploadCSVMixin.js | 8 +- .../components/create-device-popup.vue | 9 +- .../devices/components/opened-device.vue | 17 ++- .../devices/components/the-devices.vue | 33 ++--- .../components/all-licenses/all-licenses.vue | 60 ++++++-- .../components/all-licenses/license-popup.vue | 3 +- .../license/components/the-license.vue | 18 ++- .../components/license-users-popup.vue | 6 +- .../users/components/licenses-by-user.vue | 4 +- .../users/components/opened-user-devices.vue | 16 ++- .../modules/users/components/opened-user.vue | 24 +++- .../modules/users/components/the-users.vue | 33 +++-- .../users/components/upload-users-popup.vue | 1 + .../opened-user-token-created-popup.vue | 1 + .../components/opened-user-token-popup.vue | 3 +- .../tokens/components/opened-user-token.vue | 27 +++- 36 files changed, 407 insertions(+), 160 deletions(-) create mode 100644 src/app/router/_internals/tabs/DevicesRouteNames.enum.js create mode 100644 src/app/router/_internals/tabs/LicencesRouteNames.enum.js create mode 100644 src/app/router/_internals/tabs/UsersRouteNames.enum.js diff --git a/package-lock.json b/package-lock.json index 6421a5e05..380f85ef5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "web-client", - "version": "24.04.0", + "version": "24.04.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "web-client", - "version": "24.04.0", + "version": "24.04.1", "dependencies": { "@vue/compat": "^3.2.47", "@vuelidate/core": "^2.0.0", "@vuelidate/validators": "^2.0.0", "@vueuse/core": "^10.3.0", "@webitel/flow-ui-sdk": "^0.1.14", - "@webitel/ui-sdk": "=24.4.38", + "@webitel/ui-sdk": "^24.6.40", "axios": "^1.6.8", "clipboard-copy": "^4.0.1", "cron-validator": "^1.3.1", @@ -21,7 +21,6 @@ "deep-copy": "^1.4.2", "deep-equal": "^1.1.0", "deepmerge": "^4.2.2", - "file-saver": "^2.0.2", "jszip": "^3.2.2", "jszip-utils": "^0.1.0", "monaco-editor": "^0.44.0", @@ -2200,9 +2199,9 @@ } }, "node_modules/@webitel/ui-sdk": { - "version": "24.4.38", - "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.4.38.tgz", - "integrity": "sha512-aGWZ/jU6NVxaLKAqwIUGwkM8QGCco/v7Ji8WIugwSpMa9V4MNEPxzhrQmykrRKOvORNAZkSg1zlioBSv8za0SA==", + "version": "24.6.40", + "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.6.40.tgz", + "integrity": "sha512-JUFYXUDmRqoCWN2nmf/S3P5l+NoGU9R3TslwrcDvZW7H/sstKD5tHvD9vBpE9/s5TPRGMIANX2Nvp33h+J2Gzg==", "dependencies": { "@floating-ui/vue": "^1.0.1", "@morev/vue-transitions": "^3.0.2", @@ -2210,26 +2209,27 @@ "@vuelidate/validators": "^2.0.4", "@vuepic/vue-datepicker": "^4.4.0", "@vueuse/components": "^10.7.2", - "axios": "^1.6.8", + "axios": "^1.7.1", "clipboard-copy": "^4.0.1", "csv-stringify": "^5.5.3", "deep-copy": "^1.4.2", "deep-equal": "^2.0.3", "deepmerge": "^4.3.1", - "file-saver": "^2.0.2", + "file-saver-es": "^2.0.5", "is-valid-domain": "^0.1.6", "jszip": "^3.5.0", "jszip-utils": "^0.1.0", "lodash": "^4.17.21", + "mitt": "^3.0.1", + "path-browserify": "^1.0.1", "plyr": "3.6.3", "query-string": "^8.1.0", "sortablejs": "^1.15.0", - "tiny-emitter": "^2.1.0", "vue-i18n": "^9.2.2", "vue-multiselect": "^3.0.0-beta.3", "vue-observe-visibility": "^2.0.0-alpha.1", "vue-router": "^4.1.6", - "webitel-sdk": "^24.2.6" + "webitel-sdk": "^24.2.16" } }, "node_modules/@webitel/ui-sdk/node_modules/decode-uri-component": { @@ -2559,9 +2559,9 @@ } }, "node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -4453,10 +4453,10 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-saver": { + "node_modules/file-saver-es": { "version": "2.0.5", - "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", - "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + "resolved": "https://registry.npmjs.org/file-saver-es/-/file-saver-es-2.0.5.tgz", + "integrity": "sha512-Kg0lt+is9nOyi/VDms9miScNGot25jVFbjFccXuCL/shd2Q+rt70MALxHVkXllsX83JEBLiHQNjDPGd/6FIOoQ==" }, "node_modules/fill-range": { "version": "7.0.1", @@ -6350,6 +6350,11 @@ "node": ">=8" } }, + "node_modules/mitt": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==" + }, "node_modules/mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -6985,8 +6990,7 @@ "node_modules/path-browserify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "dev": true + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" }, "node_modules/path-exists": { "version": "4.0.0", @@ -8822,11 +8826,6 @@ "node": ">=0.6.0" } }, - "node_modules/tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" - }, "node_modules/tinybench": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.6.0.tgz", @@ -9669,9 +9668,9 @@ } }, "node_modules/webitel-sdk": { - "version": "24.2.12", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.2.12.tgz", - "integrity": "sha512-5O0klvepANTe9upNrEgXoKsbCVO2jYEhMFUrieY+mh/sgcs4k4tIW/vwgOalFDRIHtlDeiHUZkhZTokpIJ7jTQ==", + "version": "24.4.3", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.4.3.tgz", + "integrity": "sha512-MblmAA1GmQANEZzJigGP9PlZ3DhlQumfgIW/T7Rbsf1ZgEVO8+/vjfbr8+PmXoTUYZ1Wag/eIsbFFcXhkHhbFg==", "dependencies": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", @@ -9681,7 +9680,7 @@ "query-string": "7.0.0" }, "peerDependencies": { - "axios": "^1.6.5", + "axios": "^1.6.8", "ee-ts": "1.0.1" } }, diff --git a/package.json b/package.json index 01b36d30d..fa00f88b7 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@vuelidate/validators": "^2.0.0", "@vueuse/core": "^10.3.0", "@webitel/flow-ui-sdk": "^0.1.14", - "@webitel/ui-sdk": "=24.4.38", + "@webitel/ui-sdk": "^24.6.40", "axios": "^1.6.8", "clipboard-copy": "^4.0.1", "cron-validator": "^1.3.1", @@ -24,7 +24,6 @@ "deep-copy": "^1.4.2", "deep-equal": "^1.1.0", "deepmerge": "^4.2.2", - "file-saver": "^2.0.2", "jszip": "^3.2.2", "jszip-utils": "^0.1.0", "monaco-editor": "^0.44.0", diff --git a/src/app/api/instance.js b/src/app/api/instance.js index 2bd6f16d5..0b1579b0e 100644 --- a/src/app/api/instance.js +++ b/src/app/api/instance.js @@ -9,4 +9,5 @@ export default generateInstance({ request: [updateTokenInterceptor], response: [handleUnauthorizedInterceptor], }, + baseURL: import.meta.env.VITE_API_URL, }); diff --git a/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js b/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js index 6fea2e6c3..d524832dc 100644 --- a/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js +++ b/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js @@ -15,10 +15,16 @@ export default { mixins: [resetOnDestroyMixin, openedObjectValidationMixin], computed: { + id() { + throw new Error('Override id param for a component'); + }, + new() { + return this.$route.params.id === 'new'; + }, saveText() { // if it's a new item // OR any fields have changed - return !this.id || this.itemInstance._dirty + return this.new || this.itemInstance._dirty ? this.$t('objects.save') : this.$t('objects.saved'); }, @@ -26,7 +32,7 @@ export default { // if there's a validation problem // OR it's edit and any fields haven't changed return this.checkValidations() || - (!this.itemInstance._dirty && !!this.id); + (!this.itemInstance._dirty && !this.new); }, }, @@ -45,7 +51,7 @@ export default { async save() { if (!this.disabledSave) { - if (this.id) { + if (!this.new) { await this.updateItem(); } else { try { @@ -61,11 +67,9 @@ export default { }, async redirectToEdit() { - const routeName = this.$route.name.replace('-new', '-edit'); return this.$router.replace({ - name: routeName, - params: { id: this.id }, - hash: this.$route.hash, + ...this.$route, + params: { id }, }); }, }, diff --git a/src/app/mixins/baseMixins/baseTableMixin/itemLinkMixin.js b/src/app/mixins/baseMixins/baseTableMixin/itemLinkMixin.js index deb5801d0..c8e22e647 100644 --- a/src/app/mixins/baseMixins/baseTableMixin/itemLinkMixin.js +++ b/src/app/mixins/baseMixins/baseTableMixin/itemLinkMixin.js @@ -7,7 +7,7 @@ export default { methods: { editLink({ id }) { const routeName = this.routeName || this.tableObjectRouteName; - return { name: `${routeName}-edit`, params: { id } }; + return { name: `${routeName}-card`, params: { id } }; }, }, }; diff --git a/src/app/mixins/objectPagesMixins/objectTableMixin/tableComponentMixin.js b/src/app/mixins/objectPagesMixins/objectTableMixin/tableComponentMixin.js index bdd7b100d..f68bc09a3 100644 --- a/src/app/mixins/objectPagesMixins/objectTableMixin/tableComponentMixin.js +++ b/src/app/mixins/objectPagesMixins/objectTableMixin/tableComponentMixin.js @@ -85,7 +85,7 @@ export default { }, }), create() { - this.$router.push({ name: `${this.routeName}-new` }); + this.$router.push({ name: `${this.routeName}-card`, params: { id: 'new' } }); }, edit(item) { this.$router.push(this.editLink(item)); diff --git a/src/app/mixins/objectPagesMixins/openedObjectMixin/_internals/openedObjectAccessControlMixin.js b/src/app/mixins/objectPagesMixins/openedObjectMixin/_internals/openedObjectAccessControlMixin.js index c0ece204e..649fe3ed1 100644 --- a/src/app/mixins/objectPagesMixins/openedObjectMixin/_internals/openedObjectAccessControlMixin.js +++ b/src/app/mixins/objectPagesMixins/openedObjectMixin/_internals/openedObjectAccessControlMixin.js @@ -5,7 +5,7 @@ export default { mixins: [accessControlMixin], computed: { hasSaveActionAccess() { - if (this.$route.name.includes('-edit')) return this.hasEditAccess; + if (this.$route.params.id === 'new') return this.hasEditAccess; return this.hasCreateAccess; }, }, diff --git a/src/app/mixins/objectPagesMixins/openedObjectMixin/openedObjectMixin.js b/src/app/mixins/objectPagesMixins/openedObjectMixin/openedObjectMixin.js index b11b38b17..ca53ac668 100644 --- a/src/app/mixins/objectPagesMixins/openedObjectMixin/openedObjectMixin.js +++ b/src/app/mixins/objectPagesMixins/openedObjectMixin/openedObjectMixin.js @@ -25,13 +25,13 @@ export default { Permissions, }, data: () => ({ - currentTab: { - value: 'general', - }, + // currentTab: { + // value: 'general', + // }, }), created() { - this.setInitialTab(); + // this.setInitialTab(); this.loadPageData(); }, @@ -48,8 +48,12 @@ export default { return { text: this.$tc('objects.permissions.permissions', 2), value: 'permissions', + pathName: this.permissionsTabPathName, }; }, + currentTab() { + return this.tabs.find(({pathName}) => this.$route.name === pathName) || this.tabs[0]; + }, }, methods: { @@ -60,6 +64,7 @@ export default { }), async loadPageData() { + if (this.new) return; await this.setId(this.$route.params.id); return this.loadItem(); }, @@ -77,5 +82,8 @@ export default { if(window.history.length === 1) window.close(); this.$router.go(-1); }, + changeTab(tab) { + this.$router.push({name: tab.pathName}); + } }, }; diff --git a/src/app/mixins/objectPagesMixins/openedObjectTabMixin/_internals/openedObjectTabAccessControlMixin.js b/src/app/mixins/objectPagesMixins/openedObjectTabMixin/_internals/openedObjectTabAccessControlMixin.js index 46ca8aae2..d4b5a06ce 100644 --- a/src/app/mixins/objectPagesMixins/openedObjectTabMixin/_internals/openedObjectTabAccessControlMixin.js +++ b/src/app/mixins/objectPagesMixins/openedObjectTabMixin/_internals/openedObjectTabAccessControlMixin.js @@ -5,7 +5,7 @@ export default { mixins: [accessControlMixin], computed: { disableUserInput() { - if (this.$route.name.includes('-edit')) return !this.hasEditAccess; + if (this.$route.params.id === 'new') return !this.hasEditAccess; return !this.hasCreateAccess; }, }, diff --git a/src/app/mixins/objectPagesMixins/openedObjectTableTabMixin/openedObjectTableTabMixin.js b/src/app/mixins/objectPagesMixins/openedObjectTableTabMixin/openedObjectTableTabMixin.js index fb6579e42..ae8147bca 100644 --- a/src/app/mixins/objectPagesMixins/openedObjectTableTabMixin/openedObjectTableTabMixin.js +++ b/src/app/mixins/objectPagesMixins/openedObjectTableTabMixin/openedObjectTableTabMixin.js @@ -120,13 +120,12 @@ export default { try { if (!this.parentId) { await this.addParentItem(); - const routeName = this.$route.name.replace('-new', '-edit'); await this.$router.replace({ - name: routeName, + ...this.$route, params: { id: this.parentId }, }); } - this.openPopup(); + this.addItem(); } catch (err) { throw err; } diff --git a/src/app/mixins/objectPagesMixins/permissionsTabMixin/permissionsTabMixin.js b/src/app/mixins/objectPagesMixins/permissionsTabMixin/permissionsTabMixin.js index 5f08154c8..cddf705f9 100644 --- a/src/app/mixins/objectPagesMixins/permissionsTabMixin/permissionsTabMixin.js +++ b/src/app/mixins/objectPagesMixins/permissionsTabMixin/permissionsTabMixin.js @@ -39,6 +39,9 @@ export default { isNext(state) { return getNamespacedState(state, `${this.namespace}/${this.subNamespace}`).isNextPage; }, + permissionId() { + return this.$route.params.permissionId; + }, }), headers() { if (!this.headersValue) return []; @@ -108,11 +111,28 @@ export default { return dispatch(`${this.namespace}/${this.subNamespace}/RESET_ITEM_STATE`, payload); }, }), + addItem() { + return this.$router.push({ + ...this.$route, + params: { permissionId: 'new' }, + }); + }, openRoleSelectPopup() { this.isRoleSelectPopup = true; }, closeRoleSelectPopup() { + this.$router.go(-1); this.isRoleSelectPopup = false; }, }, + watch: { + permissionId: { + handler(value) { + if (value === 'new') { + this.openRoleSelectPopup(); + } + }, + immediate: true, + }, + } }; diff --git a/src/app/plugins/webitel-ui.js b/src/app/plugins/webitel-ui.js index 0edd2e95d..d72b0f7fe 100644 --- a/src/app/plugins/webitel-ui.js +++ b/src/app/plugins/webitel-ui.js @@ -2,7 +2,7 @@ import '@webitel/ui-sdk/dist/img/sprite'; // import styles import '@webitel/ui-sdk/dist/ui-sdk.css'; -import WebitelUI from '@webitel/ui-sdk/dist/ui-sdk.mjs'; +import WebitelUI from '@webitel/ui-sdk/dist/ui-sdk.umd.cjs'; // import locale import WebitelUIEn from '@webitel/ui-sdk/src/locale/en/en'; diff --git a/src/app/router/_internals/tabs/DevicesRouteNames.enum.js b/src/app/router/_internals/tabs/DevicesRouteNames.enum.js new file mode 100644 index 000000000..4fa20e24f --- /dev/null +++ b/src/app/router/_internals/tabs/DevicesRouteNames.enum.js @@ -0,0 +1,10 @@ +import RouteNames from '../RouteNames.enum.js'; + +export default Object.freeze({ + GENERAL: `${RouteNames.DEVICES}-general`, + PHONE_INFO: `${RouteNames.DEVICES}-phone-info`, + PERMISSIONS: `${RouteNames.DEVICES}-permissions`, + HOTDESK_GENERAL: `${RouteNames.DEVICES}-hotdesk-general`, + HOTDESK_HOTDESKING: `${RouteNames.DEVICES}-hotdesk-hotdesking`, + HOTDESK_PHONE_INFO: `${RouteNames.DEVICES}-hotdesk-phone-info`, +}); diff --git a/src/app/router/_internals/tabs/LicencesRouteNames.enum.js b/src/app/router/_internals/tabs/LicencesRouteNames.enum.js new file mode 100644 index 000000000..040fa3abb --- /dev/null +++ b/src/app/router/_internals/tabs/LicencesRouteNames.enum.js @@ -0,0 +1,6 @@ +import RouteNames from '../RouteNames.enum.js'; + +export default Object.freeze({ + ALL: `${RouteNames.LICENSE}-all`, + BY_USER: `${RouteNames.LICENSE}-by-user`, +}); diff --git a/src/app/router/_internals/tabs/UsersRouteNames.enum.js b/src/app/router/_internals/tabs/UsersRouteNames.enum.js new file mode 100644 index 000000000..dceb67172 --- /dev/null +++ b/src/app/router/_internals/tabs/UsersRouteNames.enum.js @@ -0,0 +1,11 @@ +import RouteNames from '../RouteNames.enum.js'; +export default Object.freeze({ + GENERAL: `${RouteNames.USERS}-general`, + ROLES: `${RouteNames.USERS}-roles`, + LICENSE: `${RouteNames.USERS}-license`, + DEVICES: `${RouteNames.USERS}-devices`, + VARIABLES: `${RouteNames.USERS}-variables`, + TOKENS: `${RouteNames.USERS}-tokens`, + LOGS: `${RouteNames.USERS}-logs`, + PERMISSIONS: `${RouteNames.USERS}-permissions`, +}); diff --git a/src/app/router/router.js b/src/app/router/router.js index 1bfa7b225..7b19e6afa 100755 --- a/src/app/router/router.js +++ b/src/app/router/router.js @@ -1,7 +1,9 @@ import { createRouter, createWebHistory } from 'vue-router'; import store from '../store/store'; import RouteNames from './_internals/RouteNames.enum'; - +import DevicesRouteNames from './_internals/tabs/DevicesRouteNames.enum.js'; +import LicencesRouteNames from './_internals/tabs/LicencesRouteNames.enum.js'; +import UsersRouteNames from './_internals/tabs/UsersRouteNames.enum.js'; const ApplicationHub = () => import('../../modules/application-hub/components/application-hub.vue'); const ModuleWrap = () => import('../../modules/_shared/object-wrap/the-object-wrap.vue'); const StartPage = () => import('../../modules/start-page/components/the-start-page.vue'); @@ -70,7 +72,20 @@ const Changelogs = () => import('../../modules/system/modules/changelogs/compone const OpenedChangelog = () => import('../../modules/system/modules/changelogs/components/opened-changelog.vue'); const Configuration = () => import('../../modules/system/modules/configuration/components/the-configuration.vue'); const GlobalVariables = () => import('../../modules/system/modules/global-variables/components/the-global-variables.vue'); - +const AllLicenses = () => import('../../modules/directory/modules/license/components/all-licenses/all-licenses.vue'); +const LicensesByUser = () => import('../../modules/directory/modules/license/modules/users/components/licenses-by-user.vue'); +const OpenedUserGeneral = () => import('../../modules/directory/modules/users/components/opened-user-general.vue'); +const OpenedUserRoles = () => import('../../modules/directory/modules/users/components/opened-user-roles.vue'); +const OpenedUserLicense = () => import('../../modules/directory/modules/users/components/opened-user-license.vue'); +const OpenedUserDevices = () => import('../../modules/directory/modules/users/components/opened-user-devices.vue'); +const OpenedUserVariables = () => import('../../modules/directory/modules/users/components/opened-user-variables.vue'); +const OpenedUserLogs = () => import('../../modules/directory/modules/users/modules/logs/components/opened-user-logs.vue'); +const OpenedUserToken = () => import('../../modules/directory/modules/users/modules/tokens/components/opened-user-token.vue'); +const PermissionsTab = () => import('../../modules/_shared/permissions-tab/components/permissions-tab.vue'); +const OpenedDeviceGeneral = () => import('../../modules/directory/modules/devices/components/opened-device-general.vue'); +const OpenedDevicePhoneInfo = () => import('../../modules/directory/modules/devices/components/opened-device-phone-info.vue'); +const OpenedHotdeskDeviceGeneral = () => import('../../modules/directory/modules/devices/components/opened-hotdesk-device-general.vue'); +const OpenedHotdeskDeviceHotdesking = () => import('../../modules/directory/modules/devices/components/opened-hotdesk-device-hotdesking.vue'); const checkAppAccess = (to, from, next) => { // check for === false because it can be undefined if (to.meta.requiresAccess === false) next(); @@ -88,6 +103,7 @@ const checkRouteAccess = ((to, from, next) => { if (hasReadAccess) { next(); } else { + console.log('error?') next('/access-denied'); } }); @@ -139,39 +155,65 @@ const router = createRouter({ }, { path: '/directory/devices/:id', - name: `${RouteNames.DEVICES}-edit`, + name: `${RouteNames.DEVICES}-card`, component: OpenedDevice, - beforeEnter: checkRouteAccess, - }, - { - path: '/directory/devices/new', - name: `${RouteNames.DEVICES}-new`, - component: OpenedDevice, - beforeEnter: checkRouteAccess, + redirect: {name: DevicesRouteNames.GENERAL}, + beforeEnter: checkRouteAccess, + children: [ + { + path: 'general', + name: DevicesRouteNames.GENERAL, + component: OpenedDeviceGeneral, + },{ + path: 'phone-info', + name: DevicesRouteNames.PHONE_INFO, + component: OpenedDevicePhoneInfo, + },{ + path: 'permissions/:permissionId?', + name: `${DevicesRouteNames.PERMISSIONS}-card`, + component: PermissionsTab, + }, + ], }, { path: '/directory/devices/hotdesk/:id', - name: `${RouteNames.DEVICES}-hotdesk-edit`, + name: `${RouteNames.DEVICES}-hotdesk-card`, component: OpenedDevice, - beforeEnter: checkRouteAccess, - }, - { - path: '/directory/devices/hotdesk/new', - name: `${RouteNames.DEVICES}-hotdesk-new`, - component: OpenedDevice, - beforeEnter: checkRouteAccess, + redirect: {name: DevicesRouteNames.HOTDESK_GENERAL}, + beforeEnter: checkRouteAccess, + children: [ + { + path: 'hotdesk-general', + name: DevicesRouteNames.HOTDESK_GENERAL, + component: OpenedHotdeskDeviceGeneral, + },{ + path: 'hotdesk-hotdesking', + name: DevicesRouteNames.HOTDESK_HOTDESKING, + component: OpenedHotdeskDeviceHotdesking, + },{ + path: 'phone-info', + name: DevicesRouteNames.HOTDESK_PHONE_INFO, + component: OpenedDevicePhoneInfo, + }, + ] }, { path: '/directory/license', name: RouteNames.LICENSE, component: License, + redirect: {name: `${LicencesRouteNames.ALL}-card`}, beforeEnter: checkRouteAccess, - }, - { - path: '/directory/license/:id', - name: `${RouteNames.LICENSE}-edit`, - component: License, - beforeEnter: checkRouteAccess, + children: [ + { + path: 'all/:id?', + name: `${LicencesRouteNames.ALL}-card`, + component: AllLicenses, + },{ + path: 'by-user', + name: LicencesRouteNames.BY_USER, + component: LicensesByUser, + } + ], }, { path: '/directory/users', @@ -181,15 +223,45 @@ const router = createRouter({ }, { path: '/directory/users/:id', - name: `${RouteNames.USERS}-edit`, + name: `${RouteNames.USERS}-card`, component: OpenedUser, - beforeEnter: checkRouteAccess, - }, - { - path: '/directory/users/new', - name: `${RouteNames.USERS}-new`, - component: OpenedUser, - beforeEnter: checkRouteAccess, + redirect: {name: UsersRouteNames.GENERAL}, + beforeEnter: checkRouteAccess, + children: [ + { + path: 'general', + name: UsersRouteNames.GENERAL, + component: OpenedUserGeneral, + },{ + path: 'roles', + name: UsersRouteNames.ROLES, + component: OpenedUserRoles, + },{ + path: 'license', + name: UsersRouteNames.LICENSE, + component: OpenedUserLicense, + },{ + path: 'devices', + name: UsersRouteNames.DEVICES, + component: OpenedUserDevices, + },{ + path: 'variables', + name: UsersRouteNames.VARIABLES, + component: OpenedUserVariables, + },{ + path: 'tokens/:tokenId?', + name: UsersRouteNames.TOKENS, + component: OpenedUserToken, + },{ + path: 'logs', + name: UsersRouteNames.LOGS, + component: OpenedUserLogs, + },{ + path: 'permissions/:permissionId?', + name: `${UsersRouteNames.PERMISSIONS}-card`, + component: PermissionsTab, + } + ], }, // ----------DIRECTORY END------------ diff --git a/src/main.js b/src/main.js index 1caba7c7b..9585d1ed6 100755 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ I think, this issue should go on migration to Vue 3, so I left it "as is". import './app/css/do-not-delete-me.scss'; import ActionComponents from './app/components/actions'; import App from './app/components/app.vue'; +import AdmItemLink from './app/components/utils/adm-item-link.vue'; import i18n from './app/locale/i18n'; import BreakpointPlugin from './app/plugins/breakpoint'; import './app/plugins/webitel-flow-ui'; @@ -56,6 +57,8 @@ const createVueInstance = () => { app.component(component.name, component); }); + app.component('adm-item-link', AdmItemLink); + return app; }; diff --git a/src/modules/_shared/permissions-tab/components/permissions-tab-role-popup.vue b/src/modules/_shared/permissions-tab/components/permissions-tab-role-popup.vue index 9b6f22f57..4eea47f01 100644 --- a/src/modules/_shared/permissions-tab/components/permissions-tab-role-popup.vue +++ b/src/modules/_shared/permissions-tab/components/permissions-tab-role-popup.vue @@ -1,7 +1,8 @@