Skip to content

Commit a9836f9

Browse files
committed
refactor: api key
1 parent 376bf0e commit a9836f9

File tree

4 files changed

+31
-165
lines changed

4 files changed

+31
-165
lines changed

ui/src/layout/components/top-bar/avatar/APIKeyDialog.vue

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</el-card>
2222

2323
<el-button type="primary" class="mb-16" @click="createApiKey">
24-
{{ $t('views.applicationOverview.appInfo.APIKeyDialog.creatApiKey') }}
24+
{{ $t('common.create') }}
2525
</el-button>
2626
<el-table :data="apiKey" class="mb-16" :loading="loading">
2727
<el-table-column prop="secret_key" label="API Key">
@@ -34,47 +34,28 @@
3434
</el-button>
3535
</template>
3636
</el-table-column>
37-
<el-table-column
38-
:label="$t('views.applicationOverview.appInfo.APIKeyDialog.status')"
39-
width="60"
40-
>
37+
<el-table-column :label="$t('common.status')" width="80">
4138
<template #default="{ row }">
4239
<div @click.stop>
4340
<el-switch size="small" v-model="row.is_active" @change="changeState($event, row)" />
4441
</div>
4542
</template>
4643
</el-table-column>
47-
<el-table-column
48-
prop="name"
49-
:label="$t('views.applicationOverview.appInfo.APIKeyDialog.creationDate')"
50-
width="170"
51-
>
44+
<el-table-column prop="name" :label="$t('common.createDate')" width="170">
5245
<template #default="{ row }">
5346
{{ datetimeFormat(row.create_time) }}
5447
</template>
5548
</el-table-column>
56-
<el-table-column
57-
:label="$t('views.applicationOverview.appInfo.APIKeyDialog.operations')"
58-
align="left"
59-
width="80"
60-
>
49+
<el-table-column :label="$t('common.setting')" align="left" width="80">
6150
<template #default="{ row }">
6251
<span class="mr-4">
63-
<el-tooltip
64-
effect="dark"
65-
:content="$t('views.applicationOverview.appInfo.APIKeyDialog.settings')"
66-
placement="top"
67-
>
52+
<el-tooltip effect="dark" :content="$t('common.settings')" placement="top">
6853
<el-button type="primary" text @click.stop="settingApiKey(row)">
6954
<el-icon><Setting /></el-icon>
7055
</el-button>
7156
</el-tooltip>
7257
</span>
73-
<el-tooltip
74-
effect="dark"
75-
:content="$t('views.applicationOverview.appInfo.APIKeyDialog.delete')"
76-
placement="top"
77-
>
58+
<el-tooltip effect="dark" :content="$t('common.delete')" placement="top">
7859
<el-button type="primary" text @click="deleteApiKey(row)">
7960
<el-icon>
8061
<Delete />
@@ -95,7 +76,7 @@ import systemKeyApi from '@/api/system-api-key'
9576
import { datetimeFormat } from '@/utils/time'
9677
import { MsgSuccess, MsgConfirm } from '@/utils/message'
9778
import { t } from '@/locales'
98-
import SettingAPIKeyDialog from './SettingAPIKeyDialog.vue'
79+
import SettingAPIKeyDialog from '@/views/application-overview/component/SettingAPIKeyDialog.vue'
9980
10081
const route = useRoute()
10182
const {
@@ -123,23 +104,23 @@ watch(dialogVisible, (bool) => {
123104
})
124105
125106
function settingApiKey(row: any) {
126-
SettingAPIKeyDialogRef.value.open(row)
107+
SettingAPIKeyDialogRef.value.open(row, 'USER')
127108
}
128109
129110
function deleteApiKey(row: any) {
130111
MsgConfirm(
131112
// @ts-ignore
132-
`${t('views.applicationOverview.appInfo.APIKeyDialog.msgConfirm1')}: ${row.secret_key}?`,
133-
t('views.applicationOverview.appInfo.APIKeyDialog.msgConfirm2'),
113+
`${t('common.msgConfirm1')}: ${row.secret_key}?`,
114+
t('common.msgConfirm2'),
134115
{
135-
confirmButtonText: t('views.applicationOverview.appInfo.APIKeyDialog.confirmDelete'),
136-
cancelButtonText: t('views.applicationOverview.appInfo.APIKeyDialog.cancel'),
116+
confirmButtonText: t('common.delete'),
117+
cancelButtonText: t('common.cancel'),
137118
confirmButtonClass: 'danger'
138119
}
139120
)
140121
.then(() => {
141122
systemKeyApi.delAPIKey(row.id, loading).then(() => {
142-
MsgSuccess(t('views.applicationOverview.appInfo.APIKeyDialog.deleteSuccess'))
123+
MsgSuccess(t('common.deleteSuccess'))
143124
getApiKeyList()
144125
})
145126
})

ui/src/layout/components/top-bar/avatar/SettingAPIKeyDialog.vue

Lines changed: 0 additions & 106 deletions
This file was deleted.

ui/src/views/application-overview/component/APIKeyDialog.vue

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,28 @@
2121
</el-button>
2222
</template>
2323
</el-table-column>
24-
<el-table-column
25-
:label="$t('common.status')"
26-
width="70"
27-
>
24+
<el-table-column :label="$t('common.status')" width="70">
2825
<template #default="{ row }">
2926
<div @click.stop>
3027
<el-switch size="small" v-model="row.is_active" @change="changeState($event, row)" />
3128
</div>
3229
</template>
3330
</el-table-column>
34-
<el-table-column
35-
prop="name"
36-
:label="$t('common.createDate')"
37-
width="170"
38-
>
31+
<el-table-column prop="name" :label="$t('common.createDate')" width="170">
3932
<template #default="{ row }">
4033
{{ datetimeFormat(row.create_time) }}
4134
</template>
4235
</el-table-column>
43-
<el-table-column
44-
:label="$t('common.operation')"
45-
align="left"
46-
width="90"
47-
>
36+
<el-table-column :label="$t('common.operation')" align="left" width="90">
4837
<template #default="{ row }">
4938
<span class="mr-4">
50-
<el-tooltip
51-
effect="dark"
52-
:content="$t('common.setting')"
53-
placement="top"
54-
>
39+
<el-tooltip effect="dark" :content="$t('common.setting')" placement="top">
5540
<el-button type="primary" text @click.stop="settingApiKey(row)">
5641
<el-icon><Setting /></el-icon>
5742
</el-button>
5843
</el-tooltip>
5944
</span>
60-
<el-tooltip
61-
effect="dark"
62-
:content="$t('common.delete')"
63-
placement="top"
64-
>
45+
<el-tooltip effect="dark" :content="$t('common.delete')" placement="top">
6546
<el-button type="primary" text @click="deleteApiKey(row)">
6647
<el-icon><Delete /></el-icon>
6748
</el-button>
@@ -100,7 +81,7 @@ watch(dialogVisible, (bool) => {
10081
})
10182
10283
function settingApiKey(row: any) {
103-
SettingAPIKeyDialogRef.value.open(row)
84+
SettingAPIKeyDialogRef.value.open(row, 'APPLICATION')
10485
}
10586
10687
function deleteApiKey(row: any) {

ui/src/views/application-overview/component/SettingAPIKeyDialog.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ import { ref, watch } from 'vue'
3838
import { useRoute } from 'vue-router'
3939
import type { FormInstance, FormRules } from 'element-plus'
4040
import overviewApi from '@/api/application-overview'
41+
import overviewSystemApi from '@/api/system-api-key'
4142
import { MsgSuccess, MsgConfirm } from '@/utils/message'
4243
import { t } from '@/locales'
44+
4345
const route = useRoute()
4446
const {
4547
params: { id }
@@ -57,6 +59,7 @@ const dialogVisible = ref<boolean>(false)
5759
const loading = ref(false)
5860
5961
const APIKeyId = ref('')
62+
const APIType = ref('APPLICATION')
6063
6164
watch(dialogVisible, (bool) => {
6265
if (!bool) {
@@ -67,8 +70,9 @@ watch(dialogVisible, (bool) => {
6770
}
6871
})
6972
70-
const open = (data: any) => {
73+
const open = (data: any, type: string) => {
7174
APIKeyId.value = data.id
75+
APIType.value = type
7276
form.value.allow_cross_domain = data.allow_cross_domain
7377
form.value.cross_domain_list = data.cross_domain_list?.length
7478
? data.cross_domain_list?.join('\n')
@@ -88,7 +92,13 @@ const submit = async (formEl: FormInstance | undefined) => {
8892
})
8993
: []
9094
}
91-
overviewApi.putAPIKey(id as string, APIKeyId.value, obj, loading).then((res) => {
95+
96+
const apiCall =
97+
APIType.value === 'APPLICATION'
98+
? overviewApi.putAPIKey(id as string, APIKeyId.value, obj, loading)
99+
: overviewSystemApi.putAPIKey(APIKeyId.value, obj, loading)
100+
101+
apiCall.then((res) => {
92102
emit('refresh')
93103
//@ts-ignore
94104
MsgSuccess(t('views.applicationOverview.appInfo.SettingAPIKeyDialog.successMessage'))

0 commit comments

Comments
 (0)