From 6d83a227b052837bee36a08503a042b90e5cf1cb Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Mon, 20 May 2019 01:56:40 +0000 Subject: [permissionmanager] frontend rework - bulk call for loading childs of groups - change submit to save/create - reload site after role changes - skip blacklist when no groups selected - performance improvements - new dialog system --- webapp/src/components/PermissionModule.vue | 69 +--- webapp/src/components/PermissionModuleDelete.vue | 65 +++ webapp/src/components/PermissionModuleEdit.vue | 448 +++++++-------------- .../src/components/PermissionModuleGrantRevoke.vue | 166 ++------ webapp/src/components/PermissionModuleRoleList.vue | 45 ++- webapp/src/components/PermissionModuleUserList.vue | 26 +- webapp/src/store/permissions.js | 82 +--- 7 files changed, 338 insertions(+), 563 deletions(-) create mode 100644 webapp/src/components/PermissionModuleDelete.vue (limited to 'webapp') diff --git a/webapp/src/components/PermissionModule.vue b/webapp/src/components/PermissionModule.vue index 109007c..39d9b02 100644 --- a/webapp/src/components/PermissionModule.vue +++ b/webapp/src/components/PermissionModule.vue @@ -21,16 +21,13 @@ - - + + verified_user{{ $t('roles') }} people{{ $t('users') }} - + {{ $t('roles') }} @@ -40,43 +37,22 @@ - - - - - - -
-
{{ $tc('delete-role', selectedRoles.length, [selectedRoles.length]) }}
-
-
- - {{ $tc('delete-are-you-sure', selectedRoles.length) }} - - - - - - {{ $t('cancel') }} - {{ $t('delete') }} - -
+ + + +
- - - -
@@ -85,8 +61,8 @@ import PermissionModuleRoleList from '@/components/PermissionModuleRoleList' import PermissionModuleUserList from '@/components/PermissionModuleUserList' import PermissionModuleGrantRevoke from '@/components/PermissionModuleGrantRevoke' import PermissionModuleEdit from '@/components/PermissionModuleEdit' -import NoPermissionError from '@/components/NoPermissionError' -import { mapState, mapGetters } from 'vuex' +import PermissionModuleDelete from '@/components/PermissionModuleDelete' +import { mapState, mapGetters, mapMutations } from 'vuex' export default { name: 'PermissionModule', @@ -95,31 +71,28 @@ export default { PermissionModuleUserList, PermissionModuleGrantRevoke, PermissionModuleEdit, - NoPermissionError + PermissionModuleDelete }, data () { return { - components: ['PermissionModuleRoleList', 'PermissionModuleUserList', 'NoPermissionError'], - tab: 0, - canView: false + tabs: 0 } }, computed: { ...mapGetters(['tabsDark', 'tabsColor', 'tabsSliderColor']), - ...mapState('permissions', ['selectedRoles', 'selectedUsers']) + ...mapState('permissions', ['dialog']) }, methods: { + ...mapMutations('permissions', ['setDialog']) }, created () { - this.$http.get('/api/permissions/permissions.*').then(response => { - this.canView = response.data - }) - this.$store.dispatch('permissions/loadData') + this.$store.dispatch('permissions/loadLists') + this.$store.dispatch('groups/loadLists') + this.$store.dispatch('users/loadData') } } - diff --git a/webapp/src/components/PermissionModuleDelete.vue b/webapp/src/components/PermissionModuleDelete.vue new file mode 100644 index 0000000..01e4957 --- /dev/null +++ b/webapp/src/components/PermissionModuleDelete.vue @@ -0,0 +1,65 @@ + +{ + "en": { + "delete-are-you-sure": "Are you sure you want to delete this role? | Are you sure you want to delete these roles?", + "roleDeleteSuccess": "Role deleted successfully | Roles deleted successfully" + }, + "de": { + "delete-are-you-sure": "Sind sie sicher, dass sie diese Rolle Löschen wollen? | Sind sie sicher, dass sie diese Rollen löschen wollen?", + "roleDeleteSuccess": "Rolle erfolgreich gelöscht | Rollen erfolgreich gelöscht" + } +} + + + + + + + + diff --git a/webapp/src/components/PermissionModuleEdit.vue b/webapp/src/components/PermissionModuleEdit.vue index f88eb4c..7da3565 100644 --- a/webapp/src/components/PermissionModuleEdit.vue +++ b/webapp/src/components/PermissionModuleEdit.vue @@ -36,193 +36,104 @@ diff --git a/webapp/src/components/PermissionModuleGrantRevoke.vue b/webapp/src/components/PermissionModuleGrantRevoke.vue index a137ea1..10a5ad6 100644 --- a/webapp/src/components/PermissionModuleGrantRevoke.vue +++ b/webapp/src/components/PermissionModuleGrantRevoke.vue @@ -10,8 +10,8 @@ "id": "ID", "name": "Name", "description": "Description", - "roleGrantedSuccess" : "Roles successfully granted.", - "roleRevokedSuccess" : "Roles successfully revoked." + "roleGrantedSuccess" : "Role successfully granted. | Roles successfully granted.", + "roleRevokedSuccess" : "Role successfully revoked. | Roles successfully revoked." }, "de": { "select_roles": "Rollen auswählen", @@ -23,98 +23,30 @@ "id": "ID", "name": "Name", "description": "Beschreibung", - "roleGrantedSuccess" : "Rollen erfolgreich zugewiesen.", - "roleRevokedSuccess" : "Rollen erfolgreich entzogen." + "roleGrantedSuccess" : "Rolle erfolgreich zugewiesen. | Rollen erfolgreich zugewiesen.", + "roleRevokedSuccess" : "Rolle erfolgreich entzogen. | Rollen erfolgreich entzogen." } } diff --git a/webapp/src/components/PermissionModuleUserList.vue b/webapp/src/components/PermissionModuleUserList.vue index 609ab37..d25d1e8 100644 --- a/webapp/src/components/PermissionModuleUserList.vue +++ b/webapp/src/components/PermissionModuleUserList.vue @@ -31,11 +31,11 @@ -
- +
+ remove_circle_outline{{ $t('revoke-role') }} - + add_circle_outline{{ $t('grant-role') }}
@@ -43,7 +43,7 @@ diff --git a/webapp/src/store/permissions.js b/webapp/src/store/permissions.js index 7ec454c..5f16045 100644 --- a/webapp/src/store/permissions.js +++ b/webapp/src/store/permissions.js @@ -4,88 +4,34 @@ export default { namespaced: true, state: { roles: [], - users: [], - groups: [], - permissions: [], - selectedRoles: [], + permissionsList: [], selectedUsers: [], - roleId: '', - dialog: false, - grantRevoke: false, - grant: false, - edit: false + dialog: { show: false, type: null, info: {} } }, mutations: { - setDialog (state, value) { - state.dialog = value - }, - setRoles (state, value) { - state.roles = value - }, - setUsers (state, value) { - state.users = value - }, - setGroups (state, value) { - state.groups = value - }, - setPermissions (state, value) { - state.permissions = value - }, - setSelectedRoles (state, value) { - state.selectedRoles = value - }, - setSelectedUsers (state, value) { - state.selectedUsers = value - }, - editRole (state, value) { - state.roleId = value - state.edit = true - }, - setEdit (state, value) { - state.edit = value - }, - grantRevoke (state, value) { - state.grantRevoke = value.show - state.grant = value.grant - }, - setGrantRevoke (state, value) { - state.grantRevoke = value + setRoles (state, value) { state.roles = value }, + setSelectedUsers (state, value) { state.selectedUsers = value }, + setPermissions (state, value) { state.permissionsList = value }, + setDialog (state, { show, type, info }) { + if (show !== undefined) state.dialog.show = show + if (type !== undefined) state.dialog.type = type + if (info !== undefined) state.dialog.info = info } }, actions: { - deleteSelectedRoles (context) { - // Filter selected array to get a list of ids. - const filteredArray = context.state.selectedRoles.map(x => x.id) - axios.post('/api/roles?delete', { ids: filteredArray }).then(response => { - context.dispatch('loadData') - context.commit('setSelectedRoles', []) - }) - }, - loadRoleData (context) { + loadRoles (context) { axios.get('/api/roles').then(response => { context.commit('setRoles', response.data) }) }, - loadUserData (context) { - axios.get('/api/users').then(response => { - context.commit('setUsers', response.data) - }) - }, - loadGroupData (context) { - axios.get('/api/groups').then(response => { - context.commit('setGroups', response.data) - }) - }, - loadPermissionData (context) { + loadPermissions (context) { axios.get('/api/permissions').then(response => { context.commit('setPermissions', response.data) }) }, - loadData (context) { - context.dispatch('loadRoleData') - context.dispatch('loadUserData') - context.dispatch('loadGroupData') - context.dispatch('loadPermissionData') + loadLists (context) { + context.dispatch('loadRoles') + context.dispatch('loadPermissions') } } } -- cgit v1.2.3-55-g7522