@drax/identity-vue 0.31.0 → 0.34.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/package.json +8 -8
- package/src/components/IdentityProfileAvatar/IdentityProfileAvatar.vue +1 -1
- package/src/components/IdentityProfileView/IdentityProfileView.vue +1 -1
- package/src/components/PermissionSelector/PermissionSelector.vue +58 -33
- package/src/components/SwitchTenant/SwitchTenant.vue +1 -1
- package/src/composables/useAuth.ts +1 -1
- package/src/cruds/role-crud/RoleCrud.ts +13 -5
- package/src/cruds/role-crud/RoleForm.vue +18 -2
- package/src/cruds/tenant-crud/TenantCrud.ts +8 -0
- package/src/cruds/user-api-key-crud/UserApiKeyCrud.ts +8 -0
- package/src/cruds/user-crud/UserCrud.ts +39 -10
- package/src/cruds/user-crud/UserForm.vue +26 -8
- package/src/index.ts +3 -1
- package/src/pages/crud/RoleCrudPage.vue +4 -4
- package/src/pages/crud/TenantCrudPage.vue +3 -2
- package/src/pages/crud/UserApiKeyCrudPage.vue +4 -3
- package/src/pages/crud/UserCrudPage.vue +10 -4
- package/src/stores/IdentityCrudStore.ts +36 -0
- /package/src/stores/{auth/AuthStore.ts → AuthStore.ts} +0 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.34.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"format": "prettier --write src/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@drax/common-front": "^0.
|
|
28
|
-
"@drax/common-vue": "^0.
|
|
29
|
-
"@drax/crud-front": "^0.
|
|
30
|
-
"@drax/crud-share": "^0.
|
|
31
|
-
"@drax/crud-vue": "^0.
|
|
32
|
-
"@drax/identity-share": "^0.
|
|
27
|
+
"@drax/common-front": "^0.34.0",
|
|
28
|
+
"@drax/common-vue": "^0.34.0",
|
|
29
|
+
"@drax/crud-front": "^0.34.0",
|
|
30
|
+
"@drax/crud-share": "^0.34.0",
|
|
31
|
+
"@drax/crud-vue": "^0.34.0",
|
|
32
|
+
"@drax/identity-share": "^0.34.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"pinia": "^2.2.2",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"vue-tsc": "^2.1.6",
|
|
67
67
|
"vuetify": "^3.7.1"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "3a121099fcdd0814fd232d90aeac0b2086e2e625"
|
|
70
70
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {useAuthStore} from "../../stores/
|
|
2
|
+
import {useAuthStore} from "../../stores/AuthStore";
|
|
3
3
|
import IdentityProfileAvatarEdit from "../IdentityProfileAvatarEdit/IdentityProfileAvatarEdit.vue";
|
|
4
4
|
import {useI18n} from "vue-i18n";
|
|
5
5
|
defineEmits(['click'])
|
|
@@ -3,21 +3,39 @@
|
|
|
3
3
|
import {ref, onMounted, defineModel, computed} from 'vue'
|
|
4
4
|
import type {PropType} from 'vue'
|
|
5
5
|
import {useI18n} from "vue-i18n";
|
|
6
|
-
|
|
6
|
+
import { useTheme } from 'vuetify'
|
|
7
|
+
const {t, te} = useI18n()
|
|
7
8
|
|
|
8
9
|
defineProps({
|
|
9
10
|
errorMessages: {type: String as PropType<string | string[] | undefined>,},
|
|
10
11
|
readonly: {type: Boolean, default: false},
|
|
11
12
|
})
|
|
12
13
|
|
|
14
|
+
const theme = useTheme()
|
|
15
|
+
|
|
16
|
+
function hasCustomColor(colorName: string) {
|
|
17
|
+
return colorName in theme.current.value.colors
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let enableColor = ref(hasCustomColor('enable') ? 'enable' : 'green-darken-3')
|
|
21
|
+
|
|
22
|
+
|
|
13
23
|
const model = defineModel()
|
|
14
24
|
import {useRole} from "../../composables/useRole";
|
|
15
25
|
|
|
16
26
|
const {fetchPermissions} = useRole()
|
|
17
27
|
let items = ref([])
|
|
28
|
+
let loading = ref(false)
|
|
29
|
+
|
|
30
|
+
async function sleep(ms: number) {
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
32
|
+
}
|
|
18
33
|
|
|
19
34
|
onMounted(async () => {
|
|
35
|
+
loading.value = true
|
|
36
|
+
await sleep(1000) // simulate network delay
|
|
20
37
|
items.value = await fetchPermissions()
|
|
38
|
+
loading.value = false
|
|
21
39
|
})
|
|
22
40
|
|
|
23
41
|
interface PermissionGroups {
|
|
@@ -49,39 +67,46 @@ const permissionGroups = computed(() => {
|
|
|
49
67
|
</script>
|
|
50
68
|
|
|
51
69
|
<template>
|
|
52
|
-
<v-sheet
|
|
53
|
-
<h5 class="text-h5 mb-2">{{te('permission.permissions') ? t('permission.permissions') : 'Permissions'}}</h5>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
<v-sheet class="pa-2">
|
|
71
|
+
<h5 class="text-h5 mb-2">{{ te('permission.permissions') ? t('permission.permissions') : 'Permissions' }}</h5>
|
|
72
|
+
<v-skeleton-loader
|
|
73
|
+
:loading="loading"
|
|
74
|
+
height="340"
|
|
75
|
+
type="list-item-two-line, list-item-two-line, list-item-two-line, list-item-two-line, list-item-two-line"
|
|
76
|
+
>
|
|
77
|
+
|
|
78
|
+
<v-item-group
|
|
79
|
+
v-model="model"
|
|
80
|
+
variant="outlined"
|
|
81
|
+
divided
|
|
82
|
+
multiple
|
|
83
|
+
color="green"
|
|
84
|
+
>
|
|
85
|
+
<template v-for="(permissions, entity) in permissionGroups" :key="entity">
|
|
86
|
+
<v-card class="mb-2" variant="outlined">
|
|
87
|
+
<v-card-title class="text-capitalize">
|
|
88
|
+
{{ t ? t('permission.' + entity) : entity }}
|
|
89
|
+
</v-card-title>
|
|
90
|
+
<v-card-text>
|
|
91
|
+
<v-item
|
|
92
|
+
v-for="permission in permissions"
|
|
93
|
+
v-slot="{ isSelected, toggle }"
|
|
94
|
+
:value="permission" :disabled="readonly"
|
|
95
|
+
>
|
|
96
|
+
|
|
97
|
+
<v-btn
|
|
98
|
+
:color="isSelected? enableColor : 'grey-darken-3'" :readonly="readonly"
|
|
99
|
+
@click="toggle" variant="flat" :rounded="false" border
|
|
100
|
+
>
|
|
101
|
+
{{ te('permission.' + permission) ? t('permission.' + permission) : permission }}
|
|
102
|
+
</v-btn>
|
|
103
|
+
</v-item>
|
|
104
|
+
</v-card-text>
|
|
105
|
+
</v-card>
|
|
106
|
+
</template>
|
|
107
|
+
</v-item-group>
|
|
84
108
|
|
|
109
|
+
</v-skeleton-loader>
|
|
85
110
|
</v-sheet>
|
|
86
111
|
</template>
|
|
87
112
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {ref} from "vue"
|
|
3
3
|
import TenantCombobox from "../../combobox/TenantCombobox.vue";
|
|
4
4
|
import {useAuth} from "../../composables/useAuth"
|
|
5
|
-
import {useAuthStore} from "../../stores/
|
|
5
|
+
import {useAuthStore} from "../../stores/AuthStore"
|
|
6
6
|
import {useI18n} from "vue-i18n"
|
|
7
7
|
|
|
8
8
|
const authStore = useAuthStore()
|
|
@@ -22,11 +22,11 @@ class RoleCrud extends EntityCrud implements IEntityCrud {
|
|
|
22
22
|
|
|
23
23
|
get permissions(){
|
|
24
24
|
return {
|
|
25
|
-
manage: '
|
|
26
|
-
view: '
|
|
27
|
-
create: '
|
|
28
|
-
update: '
|
|
29
|
-
delete: '
|
|
25
|
+
manage: 'role:manage',
|
|
26
|
+
view: 'role:view',
|
|
27
|
+
create: 'role:create',
|
|
28
|
+
update: 'role:update',
|
|
29
|
+
delete: 'role:delete'
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -86,6 +86,14 @@ class RoleCrud extends EntityCrud implements IEntityCrud {
|
|
|
86
86
|
return false
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
get searchEnable() {
|
|
90
|
+
return true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get filterButtons() {
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
export default RoleCrud
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {useFormUtils, useCrudStore} from "@drax/crud-vue";
|
|
3
|
-
import {defineEmits, defineModel, ref} from "vue";
|
|
3
|
+
import {computed, defineEmits, defineModel, ref} from "vue";
|
|
4
4
|
import {useI18nValidation} from "@drax/common-vue";
|
|
5
5
|
import PermissionSelector from "../../components/PermissionSelector/PermissionSelector.vue";
|
|
6
6
|
import RoleCombobox from "../../combobox/RoleCombobox.vue";
|
|
7
|
+
import {useIdentityCrudStore} from "../../stores/IdentityCrudStore";
|
|
7
8
|
import {useI18n} from "vue-i18n";
|
|
8
9
|
|
|
9
10
|
const {$ta} = useI18nValidation()
|
|
@@ -14,6 +15,8 @@ const valueModel = defineModel({type: [Object]})
|
|
|
14
15
|
const emit = defineEmits(['submit', 'cancel'])
|
|
15
16
|
|
|
16
17
|
const store = useCrudStore()
|
|
18
|
+
const identityCrudStore = useIdentityCrudStore()
|
|
19
|
+
const entity = identityCrudStore.roleCrud
|
|
17
20
|
|
|
18
21
|
const valid = ref()
|
|
19
22
|
const formRef = ref()
|
|
@@ -33,8 +36,21 @@ function cancel() {
|
|
|
33
36
|
emit('cancel')
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
const variant = computed(() => {
|
|
40
|
+
if (store.operation === 'create') {
|
|
41
|
+
return entity.inputVariantCreate
|
|
42
|
+
} else if (store.operation === 'edit') {
|
|
43
|
+
return entity.inputVariantEdit
|
|
44
|
+
} else if (store.operation === 'delete') {
|
|
45
|
+
return entity.inputVariantDelete
|
|
46
|
+
} else if (store.operation === 'view') {
|
|
47
|
+
return entity.inputVariantView
|
|
48
|
+
}
|
|
49
|
+
return 'outlined'
|
|
50
|
+
})
|
|
51
|
+
|
|
36
52
|
const {
|
|
37
|
-
|
|
53
|
+
submitColor, readonly
|
|
38
54
|
} = useFormUtils(store.operation)
|
|
39
55
|
|
|
40
56
|
</script>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import {EntityCrud} from "@drax/crud-vue";
|
|
4
2
|
import {UserSystemFactory} from "@drax/identity-front";
|
|
5
3
|
import {RoleCrud} from '../role-crud/RoleCrud'
|
|
6
4
|
import {TenantCrud} from '../tenant-crud/TenantCrud'
|
|
5
|
+
import {useAuthStore} from '../../stores/AuthStore'
|
|
6
|
+
|
|
7
7
|
import type {
|
|
8
8
|
IEntityCrud,
|
|
9
9
|
IEntityCrudField,
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
IEntityCrudRefs
|
|
13
13
|
} from "@drax/crud-share";
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
class UserCrud extends EntityCrud implements IEntityCrud {
|
|
17
16
|
|
|
18
17
|
static singleton: UserCrud
|
|
@@ -31,17 +30,16 @@ class UserCrud extends EntityCrud implements IEntityCrud {
|
|
|
31
30
|
|
|
32
31
|
get permissions(){
|
|
33
32
|
return {
|
|
34
|
-
manage: '
|
|
35
|
-
view: '
|
|
36
|
-
create: '
|
|
37
|
-
update: '
|
|
38
|
-
delete: '
|
|
33
|
+
manage: 'user:manage',
|
|
34
|
+
view: 'user:view',
|
|
35
|
+
create: 'user:create',
|
|
36
|
+
update: 'user:update',
|
|
37
|
+
delete: 'user:delete'
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
get headers():IEntityCrudHeader[] {
|
|
43
42
|
return [
|
|
44
|
-
//{title: 'id',key:'_id', align: 'start'},
|
|
45
43
|
{ title: 'name', key: 'name', align: 'start' },
|
|
46
44
|
{ title: 'username', key: 'username', align: 'start' },
|
|
47
45
|
{ title: 'email', key: 'email', align: 'start' },
|
|
@@ -75,7 +73,7 @@ class UserCrud extends EntityCrud implements IEntityCrud {
|
|
|
75
73
|
{name: 'email', type: 'string', label: 'email', default:'' },
|
|
76
74
|
{name: 'phone', type: 'string', label: 'phone', default:'' },
|
|
77
75
|
{name: 'role', type: 'ref', ref: 'role', label: 'role', default:null },
|
|
78
|
-
{name: 'tenant', type: 'ref', ref: 'tenant', label: 'tenant', default:null },
|
|
76
|
+
{name: 'tenant', type: 'ref', ref: 'tenant', label: 'tenant', default:null, permission: 'tenant:manage' },
|
|
79
77
|
{name: 'active', type: 'boolean', label: 'active', default:true },
|
|
80
78
|
|
|
81
79
|
]
|
|
@@ -106,6 +104,37 @@ class UserCrud extends EntityCrud implements IEntityCrud {
|
|
|
106
104
|
get isImportable(){
|
|
107
105
|
return false
|
|
108
106
|
}
|
|
107
|
+
|
|
108
|
+
get isEditable(){
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
isItemEditable(item?:any) {
|
|
113
|
+
const authStore = useAuthStore()
|
|
114
|
+
if(authStore?.authUser?.role?.childRoles && authStore?.authUser?.role?.childRoles.length > 0){
|
|
115
|
+
return authStore.authUser.role.childRoles.some(role => role.name === item.role.name)
|
|
116
|
+
}else{
|
|
117
|
+
return true
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isItemDeletable(item?:any) {
|
|
122
|
+
const authStore = useAuthStore()
|
|
123
|
+
if(authStore?.authUser?.role?.childRoles && authStore?.authUser?.role?.childRoles.length > 0){
|
|
124
|
+
return authStore.authUser.role.childRoles.some(role => role.name === item.role.name)
|
|
125
|
+
}else{
|
|
126
|
+
return true
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get searchEnable() {
|
|
131
|
+
return true
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get filterButtons() {
|
|
135
|
+
return false
|
|
136
|
+
}
|
|
137
|
+
|
|
109
138
|
}
|
|
110
139
|
|
|
111
140
|
export default UserCrud
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {useFormUtils, useCrudStore} from "@drax/crud-vue";
|
|
3
|
-
import {defineEmits, defineModel, defineProps, type PropType, ref} from "vue";
|
|
3
|
+
import {computed, defineEmits, defineModel, defineProps, type PropType, ref} from "vue";
|
|
4
4
|
import {useI18nValidation} from "@drax/common-vue";
|
|
5
5
|
import RoleCombobox from "../../combobox/RoleCombobox.vue";
|
|
6
6
|
import TenantCombobox from "../../combobox/TenantCombobox.vue";
|
|
7
|
+
import {useAuth} from "../../composables/useAuth";
|
|
7
8
|
import {useI18n} from "vue-i18n";
|
|
8
|
-
import
|
|
9
|
+
import {useIdentityCrudStore} from "../../stores/IdentityCrudStore";
|
|
9
10
|
|
|
10
11
|
const {$ta} = useI18nValidation()
|
|
11
12
|
const {t, te} = useI18n()
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
enablePassword: {type: Boolean, default: false}
|
|
16
|
-
})
|
|
14
|
+
const {hasPermission} = useAuth()
|
|
15
|
+
|
|
17
16
|
|
|
18
17
|
const valueModel = defineModel({type: [Object]})
|
|
19
18
|
|
|
20
19
|
const emit = defineEmits(['submit', 'cancel'])
|
|
21
20
|
|
|
22
21
|
const store = useCrudStore()
|
|
22
|
+
const enablePassword = store.operation === 'create'
|
|
23
|
+
|
|
24
|
+
const identityCrudStore = useIdentityCrudStore()
|
|
25
|
+
const entity = identityCrudStore.userCrud
|
|
23
26
|
|
|
24
27
|
const valid = ref()
|
|
25
28
|
const formRef = ref()
|
|
@@ -28,7 +31,7 @@ const formRef = ref()
|
|
|
28
31
|
async function submit() {
|
|
29
32
|
store.resetErrors()
|
|
30
33
|
|
|
31
|
-
if(operation === 'delete') {
|
|
34
|
+
if(store.operation === 'delete') {
|
|
32
35
|
emit('submit',valueModel.value)
|
|
33
36
|
return
|
|
34
37
|
}
|
|
@@ -46,10 +49,24 @@ function cancel() {
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
const {
|
|
49
|
-
|
|
52
|
+
submitColor, readonly
|
|
50
53
|
} = useFormUtils(store.operation)
|
|
51
54
|
|
|
52
55
|
|
|
56
|
+
const variant = computed(() => {
|
|
57
|
+
if (store.operation === 'create') {
|
|
58
|
+
return entity.inputVariantCreate
|
|
59
|
+
} else if (store.operation === 'edit') {
|
|
60
|
+
return entity.inputVariantEdit
|
|
61
|
+
} else if (store.operation === 'delete') {
|
|
62
|
+
return entity.inputVariantDelete
|
|
63
|
+
} else if (store.operation === 'view') {
|
|
64
|
+
return entity.inputVariantView
|
|
65
|
+
}
|
|
66
|
+
return 'outlined'
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
|
|
53
70
|
let passwordVisibility = ref(false)
|
|
54
71
|
|
|
55
72
|
</script>
|
|
@@ -119,6 +136,7 @@ let passwordVisibility = ref(false)
|
|
|
119
136
|
></RoleCombobox>
|
|
120
137
|
|
|
121
138
|
<TenantCombobox
|
|
139
|
+
v-if="hasPermission('tenant:manage')"
|
|
122
140
|
v-model="valueModel.tenant"
|
|
123
141
|
:label="t('user.field.tenant')"
|
|
124
142
|
:variant="variant"
|
package/src/index.ts
CHANGED
|
@@ -38,7 +38,8 @@ import RoleCrud from "./cruds/role-crud/RoleCrud"
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
import {useAuthStore} from "./stores/
|
|
41
|
+
import {useAuthStore} from "./stores/AuthStore.js";
|
|
42
|
+
import {useIdentityCrudStore} from "./stores/IdentityCrudStore.js";
|
|
42
43
|
|
|
43
44
|
import IdentityAuthRoutes from "./routes/IdentityAuthRoutes.js";
|
|
44
45
|
import IdentityCrudRoutes from "./routes/IdentityCrudRoutes.js";
|
|
@@ -92,6 +93,7 @@ export {
|
|
|
92
93
|
|
|
93
94
|
//Stores
|
|
94
95
|
useAuthStore,
|
|
96
|
+
useIdentityCrudStore,
|
|
95
97
|
|
|
96
98
|
//Routes
|
|
97
99
|
IdentityCrudRoutes,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {Crud, useCrud} from "@drax/crud-vue";
|
|
3
|
-
import RoleCrud from "../../cruds/role-crud/RoleCrud";
|
|
4
3
|
import RoleForm from "../../cruds/role-crud/RoleForm.vue";
|
|
5
4
|
import {useI18n} from "vue-i18n";
|
|
6
|
-
|
|
5
|
+
import {useIdentityCrudStore} from "../../stores/IdentityCrudStore"
|
|
6
|
+
const identityCrudStore = useIdentityCrudStore();
|
|
7
7
|
const {t, te} = useI18n()
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
10
|
onCancel, onSubmit,form
|
|
11
|
-
} = useCrud(
|
|
11
|
+
} = useCrud(identityCrudStore.roleCrud);
|
|
12
12
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<crud :entity="
|
|
16
|
+
<crud :entity="identityCrudStore.roleCrud">
|
|
17
17
|
|
|
18
18
|
<template v-slot:form>
|
|
19
19
|
<role-form
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import {useIdentityCrudStore} from "../../stores/IdentityCrudStore"
|
|
3
|
+
const identityCrudStore = useIdentityCrudStore();
|
|
3
4
|
import {Crud} from "@drax/crud-vue";
|
|
4
5
|
</script>
|
|
5
6
|
|
|
6
7
|
<template>
|
|
7
|
-
<crud :entity="
|
|
8
|
+
<crud :entity="identityCrudStore.tenantCrud">
|
|
8
9
|
|
|
9
10
|
</crud>
|
|
10
11
|
</template>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
|
|
3
|
-
import UserApiKeyCrud from "../../cruds/user-api-key-crud/UserApiKeyCrud";
|
|
4
3
|
import UserApiKeyForm from "../../cruds/user-api-key-crud/UserApiKeyForm.vue";
|
|
5
4
|
import {Crud, useCrud} from "@drax/crud-vue";
|
|
6
5
|
import type {IUserApiKey} from "@drax/identity-share";
|
|
7
6
|
import {formatDateTime} from "@drax/common-front";
|
|
8
7
|
import UserApiKeyCreated from "../../cruds/user-api-key-crud/UserApiKeyCreated.vue";
|
|
9
8
|
import {ref} from "vue";
|
|
9
|
+
import {useIdentityCrudStore} from "../../stores/IdentityCrudStore"
|
|
10
|
+
const identityCrudStore = useIdentityCrudStore();
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
onCancel, onSubmit,form
|
|
13
|
-
} = useCrud(
|
|
14
|
+
} = useCrud(identityCrudStore.userApiKeyCrud);
|
|
14
15
|
|
|
15
16
|
const userApiKeyCreated = ref<IUserApiKey>();
|
|
16
17
|
const userApiKeyCreatedDialog = ref<boolean>(false);
|
|
@@ -37,7 +38,7 @@ function onCreated(item:IUserApiKey) {
|
|
|
37
38
|
v-model="userApiKeyCreatedDialog"
|
|
38
39
|
/>
|
|
39
40
|
|
|
40
|
-
<crud :entity="
|
|
41
|
+
<crud :entity="identityCrudStore.userApiKeyCrud" @created="onCreated">
|
|
41
42
|
|
|
42
43
|
<template v-slot:form>
|
|
43
44
|
<user-api-key-form
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {ref} from "vue"
|
|
3
3
|
import UserCrud from "../../cruds/user-crud/UserCrud";
|
|
4
|
+
import {useAuth} from "../../composables/useAuth";
|
|
4
5
|
import {Crud, useCrud} from "@drax/crud-vue";
|
|
5
6
|
import UserForm from "../../cruds/user-crud/UserForm.vue";
|
|
6
7
|
import PasswordUpdateButton from "../../cruds/user-crud/PasswordUpdateButton.vue";
|
|
7
8
|
import UserPasswordDialog from "../../cruds/user-crud/UserPasswordDialog.vue";
|
|
8
9
|
import type {IUser} from "@drax/identity-share";
|
|
10
|
+
import {useIdentityCrudStore} from "../../stores/IdentityCrudStore"
|
|
11
|
+
|
|
12
|
+
const identityCrudStore = useIdentityCrudStore();
|
|
9
13
|
|
|
10
14
|
const {onCancel, onSubmit,form, operation } = useCrud(UserCrud.instance);
|
|
11
15
|
|
|
12
16
|
const dialogPassword = ref(false);
|
|
13
17
|
const userSelected = ref();
|
|
14
18
|
|
|
19
|
+
const {hasPermission } = useAuth();
|
|
20
|
+
|
|
15
21
|
function onChangePassword(user:IUser){
|
|
16
22
|
console.log("onChangePassword for user: ", user);
|
|
17
23
|
userSelected.value = user;
|
|
@@ -28,12 +34,10 @@ function onChangePassword(user:IUser){
|
|
|
28
34
|
:user="userSelected"
|
|
29
35
|
/>
|
|
30
36
|
|
|
31
|
-
<crud :entity="
|
|
37
|
+
<crud :entity="identityCrudStore.userCrud">
|
|
32
38
|
|
|
33
39
|
<template v-slot:form>
|
|
34
40
|
<user-form
|
|
35
|
-
:enable-password="operation === 'create'"
|
|
36
|
-
:operation="operation"
|
|
37
41
|
v-model="form"
|
|
38
42
|
@submit="onSubmit"
|
|
39
43
|
@cancel="onCancel"
|
|
@@ -43,7 +47,9 @@ function onChangePassword(user:IUser){
|
|
|
43
47
|
|
|
44
48
|
|
|
45
49
|
<template v-slot:item.actions="{ item }">
|
|
46
|
-
<password-update-button
|
|
50
|
+
<password-update-button v-if="hasPermission('user:changePassword')"
|
|
51
|
+
@click="onChangePassword(item as IUser)"
|
|
52
|
+
></password-update-button>
|
|
47
53
|
</template>
|
|
48
54
|
|
|
49
55
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Utilities
|
|
2
|
+
import { defineStore } from 'pinia'
|
|
3
|
+
import UserCrud from "../cruds/user-crud/UserCrud";
|
|
4
|
+
import UserApiKeyCrud from "../cruds/user-api-key-crud/UserApiKeyCrud";
|
|
5
|
+
import RoleCrud from "../cruds/role-crud/RoleCrud";
|
|
6
|
+
import TenantCrud from "../cruds/tenant-crud/TenantCrud";
|
|
7
|
+
import type {IEntityCrud} from "@drax/crud-share";
|
|
8
|
+
|
|
9
|
+
export const useIdentityCrudStore = defineStore('IdentityCrudStore', {
|
|
10
|
+
state: (): {
|
|
11
|
+
userCrud: IEntityCrud;
|
|
12
|
+
userApiKeyCrud: IEntityCrud;
|
|
13
|
+
roleCrud: IEntityCrud;
|
|
14
|
+
tenantCrud: IEntityCrud;
|
|
15
|
+
} => ({
|
|
16
|
+
userCrud: UserCrud.instance,
|
|
17
|
+
userApiKeyCrud: UserApiKeyCrud.instance,
|
|
18
|
+
roleCrud: RoleCrud.instance,
|
|
19
|
+
tenantCrud: TenantCrud.instance,
|
|
20
|
+
}),
|
|
21
|
+
actions:{
|
|
22
|
+
setUserCrud(userCrud: IEntityCrud){
|
|
23
|
+
this.userCrud = userCrud
|
|
24
|
+
},
|
|
25
|
+
setUserApiKeyCrud(userApiKeyCrud: IEntityCrud){
|
|
26
|
+
this.userApiKeyCrud = userApiKeyCrud
|
|
27
|
+
},
|
|
28
|
+
setRoleCrud(roleCrud:IEntityCrud){
|
|
29
|
+
this.roleCrud = roleCrud
|
|
30
|
+
},
|
|
31
|
+
setTenantCrud(tenantCrud:IEntityCrud){
|
|
32
|
+
this.tenantCrud = tenantCrud
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
})
|
|
File without changes
|