Skip to content

Commit 7756d02

Browse files
feat: Resource management authorization
1 parent 2434acf commit 7756d02

File tree

18 files changed

+350
-188
lines changed

18 files changed

+350
-188
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { Result } from '@/request/Result'
2+
import { get, put, post, del } from '@/request/index'
3+
import type { Ref } from 'vue'
4+
import type { pageRequest } from '@/api/type/common'
5+
const prefix = 'system/workspace'
6+
7+
/**
8+
* 系统资源授权获取资源权限
9+
* @query 参数
10+
*/
11+
const getResourceAuthorization: (
12+
workspace_id: string,
13+
target: string,
14+
resource: string,
15+
page: pageRequest,
16+
params?: any,
17+
loading?: Ref<boolean>,
18+
) => Promise<Result<any>> = (workspace_id, target, resource, page, params, loading) => {
19+
return get(
20+
`${prefix}/${workspace_id}/resource_management/resource/${target}/resource/${resource}/${page.current_page}/${page.page_size}`,
21+
params,
22+
loading,
23+
)
24+
}
25+
/**
26+
* 系统资源授权修改成员权限
27+
* @param 参数 member_id
28+
* @param 参数 {
29+
[
30+
{
31+
"target_id": "string",
32+
"permission": "NOT_AUTH"
33+
}
34+
]
35+
}
36+
*/
37+
const putResourceAuthorization: (
38+
workspace_id: string,
39+
target: string,
40+
resource: string,
41+
body: any,
42+
loading?: Ref<boolean>,
43+
) => Promise<Result<any>> = (workspace_id, target, resource, body, loading) => {
44+
return put(
45+
`${prefix}/${workspace_id}/resource_management/resource/${target}/resource/${resource}`,
46+
body,
47+
{},
48+
loading,
49+
)
50+
}
51+
52+
export default {
53+
getResourceAuthorization,
54+
putResourceAuthorization,
55+
}

ui/src/api/system/resource-authorization.ts

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,6 @@ import type { Ref } from 'vue'
44
import type { pageRequest } from '@/api/type/common'
55
const prefix = '/workspace'
66

7-
/**
8-
* 工作空间下各资源获取资源权限
9-
* @query 参数
10-
*/
11-
const getWorkspaceResourceAuthorization: (
12-
workspace_id: string,
13-
target: string,
14-
resource: string,
15-
page: pageRequest,
16-
params?: any,
17-
loading?: Ref<boolean>,
18-
) => Promise<Result<any>> = (workspace_id, target, resource, page, params, loading) => {
19-
return get(
20-
`${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}/${page.current_page}/${page.page_size}`,
21-
params,
22-
loading,
23-
)
24-
}
25-
26-
/**
27-
* 工作空间下各资源修改成员权限
28-
* @param 参数 member_id
29-
* @param 参数 {
30-
[
31-
{
32-
"user_id": "string",
33-
"permission": "NOT_AUTH"
34-
}
35-
]
36-
}
37-
*/
38-
const putWorkspaceResourceAuthorization: (
39-
workspace_id: string,
40-
target: string,
41-
resource: string,
42-
body: any,
43-
loading?: Ref<boolean>,
44-
) => Promise<Result<any>> = (workspace_id, target, resource, body, loading) => {
45-
return put(
46-
`${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}`,
47-
body,
48-
{},
49-
loading,
50-
)
51-
}
52-
537
/**
548
* 系统资源授权获取资源权限
559
* @query 参数
@@ -148,6 +102,5 @@ export default {
148102
getUserList,
149103
getUserMember,
150104
getSystemFolder,
151-
getWorkspaceResourceAuthorization,
152-
putWorkspaceResourceAuthorization
105+
153106
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Result } from '@/request/Result'
2+
import { get, put, post, del } from '@/request/index'
3+
import type { Ref } from 'vue'
4+
import type { pageRequest } from '@/api/type/common'
5+
const prefix = '/workspace'
6+
7+
8+
/**
9+
* 工作空间下各资源获取资源权限
10+
* @query 参数
11+
*/
12+
const getResourceAuthorization: (
13+
workspace_id: string,
14+
target: string,
15+
resource: string,
16+
page: pageRequest,
17+
params?: any,
18+
loading?: Ref<boolean>,
19+
) => Promise<Result<any>> = (workspace_id, target, resource, page, params, loading) => {
20+
return get(
21+
`${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}/${page.current_page}/${page.page_size}`,
22+
params,
23+
loading,
24+
)
25+
}
26+
27+
/**
28+
* 工作空间下各资源修改成员权限
29+
* @param 参数 member_id
30+
* @param 参数 {
31+
[
32+
{
33+
"user_id": "string",
34+
"permission": "NOT_AUTH"
35+
}
36+
]
37+
}
38+
*/
39+
const putResourceAuthorization: (
40+
workspace_id: string,
41+
target: string,
42+
resource: string,
43+
body: any,
44+
loading?: Ref<boolean>,
45+
) => Promise<Result<any>> = (workspace_id, target, resource, body, loading) => {
46+
return put(
47+
`${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}`,
48+
body,
49+
{},
50+
loading,
51+
)
52+
}
53+
54+
export default {
55+
getResourceAuthorization,
56+
putResourceAuthorization
57+
}

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,10 @@ const uploadFile = async (file: any, fileList: any) => {
427427
fileList.splice(0, fileList.length, ...fileList.slice(0, maxFiles))
428428
return
429429
}
430-
console.log(fileList)
431430
if (fileList.filter((f: any) => f.size == 0).length > 0) {
432431
// MB
433-
MsgWarning(t('chat.uploadFile.sizeLimit2') + fileLimit + 'MB')
434-
// 只保留未超出大小限制的文件
432+
MsgWarning(t('chat.uploadFile.sizeLimit2'))
433+
// 空文件上传过滤
435434
fileList.splice(0, fileList.length, ...fileList.filter((f: any) => f.size > 0))
436435
return
437436
}

ui/src/components/generate-related-dialog/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ import { groupBy } from 'lodash'
7777
import { MsgSuccess } from '@/utils/message'
7878
import { t } from '@/locales'
7979
import type { FormInstance } from 'element-plus'
80-
import modelResourceApi from '@/api/system-resource-management/model'
8180
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
8281
8382
const props = defineProps<{

ui/src/components/resource-authorization-drawer/index.vue

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
>
2323
<el-option :label="$t('views.userManage.userForm.nick_name.label')" value="nick_name" />
2424
<el-option :label="$t('views.login.loginForm.username.label')" value="username" />
25-
<el-option
26-
:label="$t('views.model.modelForm.permissionType.label')"
27-
value="permission"
28-
/>
25+
<el-option :label="$t('views.model.modelForm.permissionType.label')" value="permission" />
2926
</el-select>
3027
<el-input
3128
v-if="searchType === 'nick_name'"
@@ -149,15 +146,26 @@
149146
</template>
150147
<script setup lang="ts">
151148
import { ref, onMounted, watch, computed, reactive } from 'vue'
149+
import { useRoute } from 'vue-router'
152150
import { getPermissionOptions } from '@/views/system/resource-authorization/constant'
153151
import AuthorizationApi from '@/api/system/resource-authorization'
154152
import { MsgSuccess, MsgConfirm } from '@/utils/message'
155153
import { t } from '@/locales'
154+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
155+
const route = useRoute()
156156
import useStore from '@/stores'
157157
const { user } = useStore()
158158
const props = defineProps<{
159159
type: string
160160
}>()
161+
162+
const apiType = computed(() => {
163+
if (route.path.includes('resource-management')) {
164+
return 'systemManage'
165+
} else {
166+
return 'workspace'
167+
}
168+
})
161169
const permissionOptions = computed(() => {
162170
return getPermissionOptions()
163171
})
@@ -250,34 +258,32 @@ function permissionsHandle(val: any, row: any) {
250258
251259
function submitPermissions(obj: any) {
252260
const workspaceId = user.getWorkspaceId() || 'default'
253-
AuthorizationApi.putWorkspaceResourceAuthorization(
254-
workspaceId,
255-
targetId.value,
256-
props.type,
257-
obj,
258-
loading,
259-
).then(() => {
260-
MsgSuccess(t('common.submitSuccess'))
261-
getPermissionList()
262-
})
261+
loadSharedApi({ type: 'resourceAuthorization', systemType: apiType.value })
262+
.putResourceAuthorization(workspaceId, targetId.value, props.type, obj, loading)
263+
.then(() => {
264+
MsgSuccess(t('common.submitSuccess'))
265+
getPermissionList()
266+
})
263267
}
264268
const getPermissionList = () => {
265269
const workspaceId = user.getWorkspaceId() || 'default'
266270
const params: any = {}
267271
if (searchForm.value[searchType.value]) {
268272
params[searchType.value] = searchForm.value[searchType.value]
269273
}
270-
AuthorizationApi.getWorkspaceResourceAuthorization(
271-
workspaceId,
272-
targetId.value,
273-
props.type,
274-
paginationConfig,
275-
params,
276-
loading,
277-
).then((res) => {
278-
permissionData.value = res.data.records || []
279-
paginationConfig.total = res.data.total || 0
280-
})
274+
loadSharedApi({ type: 'resourceAuthorization', systemType: apiType.value })
275+
.getResourceAuthorization(
276+
workspaceId,
277+
targetId.value,
278+
props.type,
279+
paginationConfig,
280+
params,
281+
loading,
282+
)
283+
.then((res: any) => {
284+
permissionData.value = res.data.records || []
285+
paginationConfig.total = res.data.total || 0
286+
})
281287
}
282288
283289
const open = (id: string) => {

ui/src/utils/dynamics-api/shared-api.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import applicationWorkspaceApi from '@/api/application/application'
99
import applicationKeyWorkspaceApi from '@/api/application/application-key'
1010
import workflowVersionWorkspaceApi from '@/api/application/workflow-version'
1111
import chatLogWorkspaceApi from '@/api/application/chat-log'
12+
import resourceAuthorizationWorkspaceApi from '@/api/workspace/resource-authorization'
1213
import sharedWorkspaceApi from '@/api/shared-workspace'
1314
import toolSystemShareApi from '@/api/system-shared/tool'
1415
import modelSystemShareApi from '@/api/system-shared/model'
@@ -29,7 +30,8 @@ import chatUserResourceApi from '@/api/system-resource-management/chat-user'
2930
import applicationResourceApi from '@/api/system-resource-management/application'
3031
import applicationKeyResourceApi from '@/api/system-resource-management/application-key'
3132
import workflowVersionResourceApi from '@/api/system-resource-management/workflow-version'
32-
import chatLogWResourceApi from '@/api/system-resource-management/chat-log'
33+
import chatLogResourceApi from '@/api/system-resource-management/chat-log'
34+
import resourceAuthorizationResourceApi from '@/api/system-resource-management/resource-authorization'
3335

3436
// 普通 API
3537
const workspaceApiMap = {
@@ -45,6 +47,7 @@ const workspaceApiMap = {
4547
applicationKey: applicationKeyWorkspaceApi,
4648
workflowVersion: workflowVersionWorkspaceApi,
4749
chatLog: chatLogWorkspaceApi,
50+
resourceAuthorization: resourceAuthorizationWorkspaceApi,
4851
} as any
4952

5053
// 系统分享 API
@@ -71,7 +74,8 @@ const systemManageApiMap = {
7174
application: applicationResourceApi,
7275
applicationKey: applicationKeyResourceApi,
7376
workflowVersion: workflowVersionResourceApi,
74-
chatLog: chatLogWResourceApi,
77+
chatLog: chatLogResourceApi,
78+
resourceAuthorization: resourceAuthorizationResourceApi,
7579
} as any
7680

7781
const data = {

ui/src/views/application-overview/xpack-component/XPackDisplaySettingDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ const xpackForm = ref<any>({
544544
language: '',
545545
icon: '',
546546
icon_url: '',
547-
show_history: false,
547+
show_history: true,
548548
draggable: false,
549549
show_guide: false,
550550
chat_background: '',

0 commit comments

Comments
 (0)