@drax/identity-vue 0.40.0 → 0.43.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/combobox/RoleCombobox.vue +1 -1
- package/src/combobox/TenantCombobox.vue +15 -4
- package/src/components/SwitchTenant/SwitchTenant.vue +6 -1
- package/src/composables/useRole.ts +19 -9
- package/src/composables/useTenant.ts +39 -22
- package/src/composables/useUser.ts +23 -17
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.43.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.43.0",
|
|
28
|
+
"@drax/common-vue": "^0.43.0",
|
|
29
|
+
"@drax/crud-front": "^0.43.0",
|
|
30
|
+
"@drax/crud-share": "^0.43.0",
|
|
31
|
+
"@drax/crud-vue": "^0.43.0",
|
|
32
|
+
"@drax/identity-share": "^0.43.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": "3451a1c66eaf3facd4fef67d96750bf5d38a1d5c"
|
|
70
70
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
2
|
import {ref, onMounted, defineModel} from 'vue'
|
|
4
3
|
import type { PropType } from 'vue'
|
|
5
4
|
import {useI18n} from "vue-i18n";
|
|
@@ -9,6 +8,7 @@ defineProps({
|
|
|
9
8
|
clearable: {type: Boolean, default: false},
|
|
10
9
|
readonly: {type: Boolean, default: false},
|
|
11
10
|
hideDetails: {type: Boolean, default: false},
|
|
11
|
+
refresh: {type: Boolean, default: false},
|
|
12
12
|
itemTitle: {type: String, default: "name"},
|
|
13
13
|
itemValue: {type: String, default: "_id"},
|
|
14
14
|
rules: {type: Array as PropType<any[]>, default: () => []},
|
|
@@ -19,13 +19,18 @@ defineProps({
|
|
|
19
19
|
|
|
20
20
|
const model = defineModel<any>()
|
|
21
21
|
import {useTenant} from "../composables/useTenant";
|
|
22
|
-
const {fetchTenant} = useTenant()
|
|
22
|
+
const {fetchTenant, loading} = useTenant()
|
|
23
23
|
let items = ref([])
|
|
24
24
|
|
|
25
25
|
onMounted(async () => {
|
|
26
|
-
|
|
26
|
+
await fillItems()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
+
async function fillItems() {
|
|
30
|
+
loading.value = true
|
|
31
|
+
items.value = await fetchTenant()
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
|
|
30
35
|
</script>
|
|
31
36
|
|
|
@@ -43,7 +48,13 @@ onMounted(async () => {
|
|
|
43
48
|
:readonly="readonly"
|
|
44
49
|
:hide-details="hideDetails"
|
|
45
50
|
:density="density"
|
|
46
|
-
|
|
51
|
+
:loading="loading"
|
|
52
|
+
>
|
|
53
|
+
<template v-if="refresh" v-slot:prepend>
|
|
54
|
+
<v-btn @click="fillItems" icon="mdi-refresh" :loading="loading"></v-btn>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
</v-select>
|
|
47
58
|
</template>
|
|
48
59
|
|
|
49
60
|
<style scoped>
|
|
@@ -24,7 +24,12 @@ async function changeTenant() {
|
|
|
24
24
|
<b>{{t('tenant.current')}}:</b> {{authStore.authUser?.tenant ? authStore.authUser?.tenant?.name : '-'}}
|
|
25
25
|
</v-toolbar-title>
|
|
26
26
|
<v-spacer></v-spacer>
|
|
27
|
-
<tenant-combobox v-model="tenant"
|
|
27
|
+
<tenant-combobox v-model="tenant"
|
|
28
|
+
hide-details
|
|
29
|
+
variant="outlined"
|
|
30
|
+
density="compact"
|
|
31
|
+
clearable refresh
|
|
32
|
+
/>
|
|
28
33
|
<v-btn size="small" @click="changeTenant">{{t('action.change')}}</v-btn>
|
|
29
34
|
</v-toolbar>
|
|
30
35
|
|
|
@@ -17,23 +17,33 @@ export function useRole() {
|
|
|
17
17
|
|
|
18
18
|
async function fetchPermissions(page = 1, perPage = 5) {
|
|
19
19
|
loading.value = true
|
|
20
|
-
let permissions = roleSystem.fetchPermissions()
|
|
20
|
+
let permissions = await roleSystem.fetchPermissions()
|
|
21
21
|
loading.value = false
|
|
22
22
|
return permissions
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async function fetchRole(page = 1, perPage = 5) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
try {
|
|
27
|
+
loading.value = true
|
|
28
|
+
let roles = await roleSystem.fetchRole()
|
|
29
|
+
return roles
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error(e)
|
|
32
|
+
} finally {
|
|
33
|
+
loading.value = false
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
async function paginateRole({page = 1, limit = 5, orderBy = "", order = "asc", search = ""}: IDraxPaginateOptions) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
try {
|
|
39
|
+
loading.value = true
|
|
40
|
+
let paginatedrole = await roleSystem.paginate({page, limit, orderBy, order, search})
|
|
41
|
+
return paginatedrole
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(e)
|
|
44
|
+
} finally {
|
|
45
|
+
loading.value = false
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
async function createRole(roleData: IRoleBase) {
|
|
@@ -1,47 +1,64 @@
|
|
|
1
1
|
import {ref} from "vue";
|
|
2
2
|
import type {ITenant, ITenantBase} from "@drax/identity-share";
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
3
|
+
import type {TenantSystem} from "@drax/identity-front";
|
|
4
|
+
import {TenantSystemFactory} from "@drax/identity-front";
|
|
5
5
|
import {ClientError} from "@drax/common-front";
|
|
6
|
-
import type {
|
|
6
|
+
import type {IClientInputError} from "@drax/common-front";
|
|
7
7
|
import type {IDraxPaginateOptions} from "@drax/crud-share";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export function useTenant() {
|
|
11
11
|
|
|
12
|
-
const tenantSystem
|
|
12
|
+
const tenantSystem: TenantSystem = TenantSystemFactory.getInstance()
|
|
13
13
|
|
|
14
14
|
let tenantError = ref<string>('')
|
|
15
15
|
let inputErrors = ref<IClientInputError>()
|
|
16
16
|
let loading = ref(false);
|
|
17
17
|
|
|
18
18
|
async function fetchTenant(page = 1, perPage = 5) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
try {
|
|
20
|
+
loading.value = true
|
|
21
|
+
let tenants = await tenantSystem.fetchTenant()
|
|
22
|
+
return tenants
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(e)
|
|
25
|
+
} finally {
|
|
26
|
+
loading.value = false
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
async function paginateTenant({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
async function paginateTenant({
|
|
31
|
+
page = 1,
|
|
32
|
+
limit = 5,
|
|
33
|
+
orderBy = "",
|
|
34
|
+
order = "asc",
|
|
35
|
+
search = ""
|
|
36
|
+
}: IDraxPaginateOptions) {
|
|
37
|
+
try {
|
|
38
|
+
loading.value = true
|
|
39
|
+
let paginatedtenant = await tenantSystem.paginate({page, limit, orderBy, order, search})
|
|
40
|
+
return paginatedtenant
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(e)
|
|
43
|
+
} finally {
|
|
44
|
+
loading.value = false
|
|
45
|
+
}
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
async function createTenant(tenantData: ITenantBase) {
|
|
33
49
|
try {
|
|
34
50
|
loading.value = true
|
|
35
|
-
let tenant: ITenant =
|
|
51
|
+
let tenant: ITenant = await tenantSystem.create(tenantData)
|
|
36
52
|
return tenant
|
|
37
53
|
} catch (err) {
|
|
38
54
|
if (err instanceof ClientError) {
|
|
39
55
|
inputErrors.value = err.inputErrors
|
|
40
|
-
}
|
|
56
|
+
}
|
|
57
|
+
if (err instanceof Error) {
|
|
41
58
|
tenantError.value = err.message
|
|
42
59
|
}
|
|
43
60
|
throw err
|
|
44
|
-
}finally {
|
|
61
|
+
} finally {
|
|
45
62
|
loading.value = false
|
|
46
63
|
}
|
|
47
64
|
|
|
@@ -57,11 +74,11 @@ export function useTenant() {
|
|
|
57
74
|
if (err instanceof ClientError) {
|
|
58
75
|
inputErrors.value = err.inputErrors
|
|
59
76
|
}
|
|
60
|
-
if(err instanceof Error) {
|
|
77
|
+
if (err instanceof Error) {
|
|
61
78
|
tenantError.value = err.message
|
|
62
79
|
}
|
|
63
80
|
throw err
|
|
64
|
-
}finally {
|
|
81
|
+
} finally {
|
|
65
82
|
loading.value = false
|
|
66
83
|
}
|
|
67
84
|
}
|
|
@@ -71,19 +88,19 @@ export function useTenant() {
|
|
|
71
88
|
loading.value = true
|
|
72
89
|
await tenantSystem.delete(id)
|
|
73
90
|
} catch (err) {
|
|
74
|
-
console.log("composable delete error: ", err,
|
|
91
|
+
console.log("composable delete error: ", err,)
|
|
75
92
|
if (err instanceof ClientError) {
|
|
76
93
|
inputErrors.value = err.inputErrors
|
|
77
94
|
}
|
|
78
|
-
if(err instanceof Error) {
|
|
95
|
+
if (err instanceof Error) {
|
|
79
96
|
tenantError.value = err.message
|
|
80
97
|
}
|
|
81
98
|
throw err
|
|
82
|
-
}finally {
|
|
99
|
+
} finally {
|
|
83
100
|
loading.value = false
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
103
|
|
|
87
|
-
return {fetchTenant,
|
|
104
|
+
return {fetchTenant, paginateTenant, createTenant, editTenant, deleteTenant, loading, tenantError, inputErrors}
|
|
88
105
|
|
|
89
106
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ref} from "vue";
|
|
2
2
|
import type {UserSystem} from "@drax/identity-front";
|
|
3
|
-
import
|
|
3
|
+
import {UserSystemFactory} from "@drax/identity-front";
|
|
4
4
|
import type {IClientInputError} from "@drax/common-front";
|
|
5
5
|
import {ClientError} from "@drax/common-front";
|
|
6
6
|
import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
|
|
@@ -15,32 +15,38 @@ export function useUser() {
|
|
|
15
15
|
let inputErrors = ref<IClientInputError>()
|
|
16
16
|
let loading = ref(false);
|
|
17
17
|
|
|
18
|
-
async function paginateUser({page= 1, limit= 5, orderBy="", order = "asc", search = ""}:IDraxPaginateOptions) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
async function paginateUser({page = 1, limit = 5, orderBy = "", order = "asc", search = ""}: IDraxPaginateOptions) {
|
|
19
|
+
try {
|
|
20
|
+
loading.value = true
|
|
21
|
+
let paginatedUser = await userSystem.paginate({page, limit, orderBy, order, search})
|
|
22
|
+
return paginatedUser
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(e)
|
|
25
|
+
} finally {
|
|
26
|
+
loading.value = false
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
async function createUser(userData: IUserCreate) {
|
|
26
31
|
try {
|
|
27
32
|
loading.value = true
|
|
28
|
-
let user: IUser =
|
|
33
|
+
let user: IUser = await userSystem.create(userData)
|
|
29
34
|
return user
|
|
30
35
|
} catch (err) {
|
|
31
36
|
if (err instanceof ClientError) {
|
|
32
37
|
inputErrors.value = err.inputErrors
|
|
33
|
-
}
|
|
38
|
+
}
|
|
39
|
+
if (err instanceof Error) {
|
|
34
40
|
userError.value = err.message
|
|
35
41
|
}
|
|
36
42
|
throw err
|
|
37
|
-
}finally {
|
|
43
|
+
} finally {
|
|
38
44
|
loading.value = false
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
async function changeUserPassword(id: string, newPassword: string){
|
|
49
|
+
async function changeUserPassword(id: string, newPassword: string) {
|
|
44
50
|
try {
|
|
45
51
|
loading.value = true
|
|
46
52
|
return await userSystem.changeUserPassword(id, newPassword)
|
|
@@ -48,11 +54,11 @@ export function useUser() {
|
|
|
48
54
|
if (err instanceof ClientError) {
|
|
49
55
|
inputErrors.value = err.inputErrors
|
|
50
56
|
}
|
|
51
|
-
if(err instanceof Error) {
|
|
57
|
+
if (err instanceof Error) {
|
|
52
58
|
userError.value = err.message
|
|
53
59
|
}
|
|
54
60
|
throw err
|
|
55
|
-
}finally {
|
|
61
|
+
} finally {
|
|
56
62
|
loading.value = false
|
|
57
63
|
}
|
|
58
64
|
}
|
|
@@ -66,11 +72,11 @@ export function useUser() {
|
|
|
66
72
|
if (err instanceof ClientError) {
|
|
67
73
|
inputErrors.value = err.inputErrors
|
|
68
74
|
}
|
|
69
|
-
if(err instanceof Error) {
|
|
75
|
+
if (err instanceof Error) {
|
|
70
76
|
userError.value = err.message
|
|
71
77
|
}
|
|
72
78
|
throw err
|
|
73
|
-
}finally {
|
|
79
|
+
} finally {
|
|
74
80
|
loading.value = false
|
|
75
81
|
}
|
|
76
82
|
}
|
|
@@ -80,15 +86,15 @@ export function useUser() {
|
|
|
80
86
|
loading.value = true
|
|
81
87
|
await userSystem.delete(id)
|
|
82
88
|
} catch (err) {
|
|
83
|
-
console.log("composable delete error: ", err,
|
|
89
|
+
console.log("composable delete error: ", err,)
|
|
84
90
|
if (err instanceof ClientError) {
|
|
85
91
|
inputErrors.value = err.inputErrors
|
|
86
92
|
}
|
|
87
|
-
if(err instanceof Error) {
|
|
93
|
+
if (err instanceof Error) {
|
|
88
94
|
userError.value = err.message
|
|
89
95
|
}
|
|
90
96
|
throw err
|
|
91
|
-
}finally {
|
|
97
|
+
} finally {
|
|
92
98
|
loading.value = false
|
|
93
99
|
}
|
|
94
100
|
}
|