Skip to content

Commit e02d417

Browse files
authored
feat: application assess (#3312)
1 parent 046e1c7 commit e02d417

File tree

7 files changed

+110
-24
lines changed

7 files changed

+110
-24
lines changed

apps/application/serializers/application_access_token.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class AccessTokenEditSerializer(serializers.Serializer):
3333
label=_("Whitelist")),
3434
show_source = serializers.BooleanField(required=False,
3535
label=_("Whether to display knowledge sources"))
36+
show_exec = serializers.BooleanField(required=False,
37+
label=_("Display execution details"))
3638
language = serializers.CharField(required=False, allow_blank=True, allow_null=True,
3739
label=_("language"))
3840
authentication = serializers.BooleanField(default=False, label="Do you need authentication")
@@ -60,6 +62,8 @@ def edit(self, instance):
6062
application_access_token.white_list = instance.get('white_list')
6163
if 'show_source' in instance and instance.get('show_source') is not None:
6264
application_access_token.show_source = instance.get('show_source')
65+
if 'show_exec' in instance and instance.get('show_exec') is not None:
66+
application_access_token.show_exec = instance.get('show_exec')
6367
if 'language' in instance and instance.get('language') is not None:
6468
application_access_token.language = instance.get('language')
6569
if 'language' not in instance or instance.get('language') is None:

apps/locales/en_US/LC_MESSAGES/django.po

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8348,4 +8348,16 @@ msgid "Update appearance settings"
83488348
msgstr ""
83498349

83508350
msgid "Application Access"
8351-
msgstr ""
8351+
msgstr ""
8352+
8353+
msgid "Display execution details"
8354+
msgstr ""
8355+
8356+
msgid "LOCAL"
8357+
msgstr "Account login"
8358+
8359+
msgid "CAS"
8360+
msgstr "CAS"
8361+
8362+
msgid "LDAP"
8363+
msgstr "LDAP"

apps/locales/zh_CN/LC_MESSAGES/django.po

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8474,4 +8474,16 @@ msgid "Update appearance settings"
84748474
msgstr "更新外观设置"
84758475

84768476
msgid "Application Access"
8477-
msgstr "应用接入"
8477+
msgstr "应用接入"
8478+
8479+
msgid "Display execution details"
8480+
msgstr "是否显示执行详情"
8481+
8482+
msgid "LOCAL"
8483+
msgstr "账号登录"
8484+
8485+
msgid "CAS"
8486+
msgstr "CAS"
8487+
8488+
msgid "LDAP"
8489+
msgstr "LDAP"

apps/locales/zh_Hant/LC_MESSAGES/django.po

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8474,4 +8474,16 @@ msgid "Update appearance settings"
84748474
msgstr "更新外觀設置"
84758475

84768476
msgid "Application Access"
8477-
msgstr "應用介入"
8477+
msgstr "應用介入"
8478+
8479+
msgid "Display execution details"
8480+
msgstr "是否顯示執行詳情"
8481+
8482+
msgid "LOCAL"
8483+
msgstr "帳號登入"
8484+
8485+
msgid "CAS"
8486+
msgstr "CAS"
8487+
8488+
msgid "LDAP"
8489+
msgstr "LDAP"

ui/src/api/application/application.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ const getAccessToken: (application_id: string, loading?: Ref<boolean>) => Promis
9292
) => {
9393
return get(`${prefix.value}/${application_id}/access_token`, undefined, loading)
9494
}
95+
/**
96+
* 获取应用设置
97+
* @param application_id 应用id
98+
* @param loading 加载器
99+
* @returns
100+
*/
101+
const getApplicationSetting: (
102+
application_id: string,
103+
loading?: Ref<boolean>,
104+
) => Promise<Result<any>> = (application_id, loading) => {
105+
return get(`${prefix.value}/${application_id}/setting`, undefined, loading)
106+
}
95107

96108
/**
97109
* 修改AccessToken
@@ -167,7 +179,14 @@ const open: (application_id: string, loading?: Ref<boolean>) => Promise<Result<s
167179
const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
168180
return postStream(`/api/chat_message/${chat_id}`, data)
169181
}
170-
182+
/**
183+
* 获取对话用户认证类型
184+
* @param loading 加载器
185+
* @returns
186+
*/
187+
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
188+
return get(`/chat_user/auth/types`, {}, loading)
189+
}
171190
export default {
172191
getAllApplication,
173192
getApplication,
@@ -182,4 +201,6 @@ export default {
182201
getStatistics,
183202
open,
184203
chat,
204+
getChatUserAuthType,
205+
getApplicationSetting,
185206
}

ui/src/views/application-overview/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,13 @@ function openDisplaySettingDialog() {
331331
currentDisplaySettingDialog.value = DisplaySettingDialog
332332
}
333333
nextTick(() => {
334-
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
334+
if (currentDisplaySettingDialog.value == XPackDisplaySettingDialog) {
335+
applicationApi.getApplicationSetting(id).then((ok) => {
336+
DisplaySettingDialogRef.value?.open(ok.data, detail.value)
337+
})
338+
} else {
339+
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
340+
}
335341
})
336342
}
337343

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

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@
3030
<el-form-item :label="$t('views.applicationOverview.appInfo.LimitDialog.authentication')">
3131
<el-switch size="small" v-model="form.authentication" @change="firstGeneration"></el-switch>
3232
</el-form-item>
33-
<el-radio-group v-if="form.authentication" v-model="form.method" class="card__radio">
34-
<el-card shadow="never" class="mb-16" :class="form.method === 'replace' ? 'active' : ''">
33+
<el-radio-group
34+
v-if="form.authentication"
35+
v-model="form.authentication_value.type"
36+
class="card__radio"
37+
>
38+
<el-card
39+
shadow="never"
40+
class="mb-16"
41+
:class="form.authentication_value.type === 'password' ? 'active' : ''"
42+
>
3543
<el-radio value="replace" size="large">
3644
<p class="mb-4 lighter">
3745
{{ $t('views.applicationOverview.appInfo.LimitDialog.authenticationValue') }}
@@ -40,7 +48,7 @@
4048
<el-form-item class="ml-24">
4149
<el-input
4250
class="authentication-append-input"
43-
v-model="form.authentication_value"
51+
v-model="form.authentication_value.password_value"
4452
readonly
4553
style="width: 268px"
4654
>
@@ -69,9 +77,12 @@
6977
</el-input>
7078
</el-form-item>
7179
</el-card>
72-
73-
<el-card shadow="never" class="mb-16" :class="form.method === 'complete' ? 'active' : ''">
74-
<el-radio value="complete" size="large">
80+
<el-card
81+
shadow="never"
82+
class="mb-16"
83+
:class="form.authentication_value.type === 'login' ? 'active' : ''"
84+
>
85+
<el-radio value="login" size="large">
7586
<p class="mb-16 lighter">
7687
{{ $t('views.system.authentication.title') }}
7788
<el-button type="primary" link @click="router.push({ path: '' })">
@@ -88,18 +99,14 @@
8899
trigger: 'change',
89100
},
90101
]"
91-
prop="checkList"
102+
prop="authentication_value.login_value"
92103
class="ml-24 border-t"
93104
style="padding-top: 16px"
94105
>
95-
<el-checkbox-group v-model="form.checkList">
96-
<el-checkbox label="账号登录" value="账号登录" />
97-
<el-checkbox label="LDAP" value="LDAP" />
98-
<el-checkbox label="OIDC" value="OIDC" />
99-
<el-checkbox label="CAS" value="CAS" />
100-
<el-checkbox label="企业微信" value="企业微信" />
101-
<el-checkbox label="钉钉" value="钉钉" />
102-
<el-checkbox label="飞书" value="飞书" />
106+
<el-checkbox-group v-model="form.authentication_value.login_value">
107+
<template v-for="t in auth_list" :key="t.value">
108+
<el-checkbox :label="t.label" :value="t.value" />
109+
</template>
103110
</el-checkbox-group>
104111
</el-form-item>
105112
</el-card>
@@ -146,13 +153,13 @@ const {
146153
} = route
147154
148155
const emit = defineEmits(['refresh'])
149-
156+
const auth_list = ref<Array<{ label: string; value: string }>>([])
150157
const limitFormRef = ref()
151158
const form = ref<any>({
152159
access_num: 0,
153160
white_active: true,
154161
white_list: '',
155-
authentication_value: '',
162+
authentication_value: {},
156163
authentication: false,
157164
})
158165
@@ -168,14 +175,26 @@ watch(dialogVisible, (bool) => {
168175
}
169176
}
170177
})
171-
178+
watch(
179+
() => form.authentication,
180+
(b) => {
181+
if (b) {
182+
applicationApi.getChatUserAuthType().then((ok) => {
183+
auth_list.value = ok.data
184+
})
185+
}
186+
},
187+
)
172188
const open = (data: any) => {
173189
form.value.access_num = data.access_num
174190
form.value.white_active = data.white_active
175191
form.value.white_list = data.white_list?.length ? data.white_list?.join('\n') : ''
176192
form.value.authentication_value = data.authentication_value
177193
form.value.authentication = data.authentication
178194
dialogVisible.value = true
195+
applicationApi.getChatUserAuthType().then((ok) => {
196+
auth_list.value = ok.data
197+
})
179198
}
180199
181200
const submit = async (formEl: FormInstance | undefined) => {
@@ -207,7 +226,7 @@ function generateAuthenticationValue(length: number = 10) {
207226
.join('')
208227
}
209228
function refreshAuthentication() {
210-
form.value.authentication_value = generateAuthenticationValue()
229+
form.value.authentication_value.password_value = generateAuthenticationValue()
211230
}
212231
213232
function firstGeneration() {

0 commit comments

Comments
 (0)