@liujitcn/kratos-admin-system 0.0.28 → 0.0.31
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/README.md +19 -2
- package/dist/package/declarations/src/api/base/notification.d.ts +24 -0
- package/dist/package/declarations/src/api/system/base_audit_log.d.ts +55 -0
- package/dist/package/declarations/src/api/system/base_dashboard.d.ts +14 -0
- package/dist/package/declarations/src/api/system/base_file.d.ts +13 -0
- package/dist/package/declarations/src/api/system/base_i18n.d.ts +5 -5
- package/dist/package/declarations/src/api/system/base_login_policy.d.ts +10 -0
- package/dist/package/declarations/src/api/system/base_message.d.ts +24 -0
- package/dist/package/declarations/src/api/system/base_message_category.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_session.d.ts +11 -0
- package/dist/package/declarations/src/api/system/oauth_client.d.ts +24 -0
- package/dist/package/declarations/src/components/AuditLogTable.vue.d.ts +45 -0
- package/dist/package/declarations/src/components/DynamicI18nCell.vue.d.ts +16 -0
- package/dist/package/declarations/src/components/DynamicI18nEditor.vue.d.ts +20 -0
- package/dist/package/declarations/src/components/auditLog.d.ts +9 -0
- package/dist/package/declarations/src/components/dynamicI18n.d.ts +38 -0
- package/dist/package/declarations/src/locales/generated.d.ts +1364 -68
- package/dist/package/declarations/src/rpc/base/v1/login.d.ts +149 -0
- package/dist/package/declarations/src/rpc/base/v1/notification.d.ts +281 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +25 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth_client.d.ts +23 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_audit_log.d.ts +640 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +3 -3
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dashboard.d.ts +60 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +4 -4
- package/dist/package/declarations/src/rpc/system/admin/v1/base_file.d.ts +73 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_i18n.d.ts +27 -23
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +5 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_login_policy.d.ts +51 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +2 -2
- package/dist/package/declarations/src/rpc/system/admin/v1/base_message.d.ts +193 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_message_category.d.ts +125 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_session.d.ts +33 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +3 -3
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +1 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/oauth_client.d.ts +145 -0
- package/dist/package/declarations/src/views/base/api-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dashboard/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/data-access-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/file/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/login-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/login-policy/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/message/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/message-category/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/oauth-client/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/operation-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/permission-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/policy-evaluation-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/message/inbox/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/session.vue.d.ts +3 -0
- package/dist/package/src/api/base/notification.ts +69 -0
- package/dist/package/src/api/base/sse.ts +4 -4
- package/dist/package/src/api/system/auth.ts +1 -0
- package/dist/package/src/api/system/base_audit_log.ts +168 -0
- package/dist/package/src/api/system/base_dashboard.ts +55 -0
- package/dist/package/src/api/system/base_file.ts +43 -0
- package/dist/package/src/api/system/base_i18n.ts +12 -12
- package/dist/package/src/api/system/base_login_policy.ts +32 -0
- package/dist/package/src/api/system/base_message.ts +70 -0
- package/dist/package/src/api/system/base_message_category.ts +57 -0
- package/dist/package/src/api/system/base_session.ts +33 -0
- package/dist/package/src/api/system/oauth_client.ts +102 -0
- package/dist/package/src/components/AuditLogTable.vue +105 -0
- package/dist/package/src/components/{DynamicTranslationCell.vue → DynamicI18nCell.vue} +50 -50
- package/dist/package/src/components/{DynamicTranslationEditor.vue → DynamicI18nEditor.vue} +45 -45
- package/dist/package/src/components/Notification.vue +196 -0
- package/dist/package/src/components/auditLog.ts +46 -0
- package/dist/package/src/components/{dynamicTranslation.ts → dynamicI18n.ts} +15 -15
- package/dist/package/src/locales/README.md +5 -3
- package/dist/package/src/locales/en-US.json +345 -21
- package/dist/package/src/locales/ja-JP.json +347 -23
- package/dist/package/src/locales/zh-CN.json +343 -19
- package/dist/package/src/locales/zh-TW.json +346 -22
- package/dist/package/src/module.ts +5 -2
- package/dist/package/src/rpc/base/v1/login.ts +172 -0
- package/dist/package/src/rpc/base/v1/notification.ts +315 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +25 -0
- package/dist/package/src/rpc/base/v1/oauth_client.ts +33 -0
- package/dist/package/src/rpc/system/admin/v1/base_audit_log.ts +737 -0
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +3 -3
- package/dist/package/src/rpc/system/admin/v1/base_dashboard.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +4 -4
- package/dist/package/src/rpc/system/admin/v1/base_file.ts +88 -0
- package/dist/package/src/rpc/system/admin/v1/base_i18n.ts +27 -23
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +5 -0
- package/dist/package/src/rpc/system/admin/v1/base_login_policy.ts +63 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +2 -2
- package/dist/package/src/rpc/system/admin/v1/base_message.ts +236 -0
- package/dist/package/src/rpc/system/admin/v1/base_message_category.ts +149 -0
- package/dist/package/src/rpc/system/admin/v1/base_session.ts +44 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +3 -3
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +1 -1
- package/dist/package/src/rpc/system/admin/v1/oauth_client.ts +174 -0
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +2 -2
- package/dist/package/src/views/ai/chat/message.ts +7 -3
- package/dist/package/src/views/base/api-log/index.vue +83 -0
- package/dist/package/src/views/base/config/index.vue +41 -41
- package/dist/package/src/views/base/dashboard/index.vue +200 -0
- package/dist/package/src/views/base/data-access-log/index.vue +84 -0
- package/dist/package/src/views/base/dict/index.vue +23 -23
- package/dist/package/src/views/base/dict/item.vue +25 -25
- package/dist/package/src/views/base/file/index.vue +119 -0
- package/dist/package/src/views/base/job/index.vue +62 -7
- package/dist/package/src/views/base/language/index.vue +2 -1
- package/dist/package/src/views/base/login-log/index.vue +92 -0
- package/dist/package/src/views/base/login-policy/index.vue +219 -0
- package/dist/package/src/views/base/menu/index.vue +23 -23
- package/dist/package/src/views/base/message/index.vue +582 -0
- package/dist/package/src/views/base/message-category/index.vue +356 -0
- package/dist/package/src/views/base/oauth-client/index.vue +411 -0
- package/dist/package/src/views/base/operation-log/index.vue +82 -0
- package/dist/package/src/views/base/permission-log/index.vue +85 -0
- package/dist/package/src/views/base/policy-evaluation-log/index.vue +82 -0
- package/dist/package/src/views/message/inbox/index.vue +249 -0
- package/dist/package/src/views/profile/components/base.vue +6 -5
- package/dist/package/src/views/profile/components/password.vue +2 -2
- package/dist/package/src/views/profile/components/security.vue +475 -62
- package/dist/package/src/views/profile/components/session.vue +153 -0
- package/dist/package/src/views/profile/index.vue +35 -22
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +9 -9
- package/dist/package/src/views/tool/code-gen/columns/index.vue +1 -1
- package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +8 -8
- package/dist/package/src/views/tool/code-gen/config.ts +1 -0
- package/dist/package/src/views/tool/code-gen/table/index.vue +7 -7
- package/dist/package/src/views/tool/ops-monitoring/index.vue +25 -21
- package/package.json +2 -2
- package/dist/package/declarations/src/api/system/base_log.d.ts +0 -9
- package/dist/package/declarations/src/components/DynamicTranslationCell.vue.d.ts +0 -16
- package/dist/package/declarations/src/components/DynamicTranslationEditor.vue.d.ts +0 -20
- package/dist/package/declarations/src/components/dynamicTranslation.d.ts +0 -38
- package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +0 -87
- package/dist/package/src/api/system/base_log.ts +0 -32
- package/dist/package/src/rpc/system/admin/v1/base_log.ts +0 -101
- package/dist/package/src/views/base/log/index.vue +0 -339
- /package/dist/package/declarations/src/{views/base/log/index.vue.d.ts → components/Notification.vue.d.ts} +0 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
<!-- 开放授权客户端管理 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="table-box">
|
|
4
|
+
<ProTable
|
|
5
|
+
ref="proTable"
|
|
6
|
+
row-key="id"
|
|
7
|
+
:columns="columns"
|
|
8
|
+
:header-actions="headerActions"
|
|
9
|
+
:request-api="requestOauthClientTable"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<FormDialog
|
|
13
|
+
v-model="dialog.visible"
|
|
14
|
+
ref="formDialogRef"
|
|
15
|
+
:title="t(dialog.titleKey)"
|
|
16
|
+
width="960px"
|
|
17
|
+
:model="formData"
|
|
18
|
+
:fields="formFields"
|
|
19
|
+
:rules="rules"
|
|
20
|
+
@confirm="handleSubmit"
|
|
21
|
+
@close="handleCloseDialog"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { computed, onMounted, reactive, ref } from "vue";
|
|
28
|
+
import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
29
|
+
import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
|
|
30
|
+
import FormDialog from "@liujitcn/kratos-admin-core/components/Dialog/FormDialog.vue";
|
|
31
|
+
import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
32
|
+
import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
|
|
33
|
+
import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
34
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
35
|
+
import { copyText } from "@liujitcn/kratos-admin-core/security";
|
|
36
|
+
import { defOauthClientService } from "@liujitcn/kratos-admin-system/api/system/oauth_client";
|
|
37
|
+
import { defBaseTenantService } from "@liujitcn/kratos-admin-system/api/system/base_tenant";
|
|
38
|
+
import type { BaseApi } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_api";
|
|
39
|
+
import {
|
|
40
|
+
OauthClientCryptoType,
|
|
41
|
+
type OauthClient,
|
|
42
|
+
type OauthClientForm,
|
|
43
|
+
type PageOauthClientRequest
|
|
44
|
+
} from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/oauth_client";
|
|
45
|
+
import type { SelectOptionResponse_Option } from "@liujitcn/kratos-admin-system/rpc/common/v1/common";
|
|
46
|
+
import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
47
|
+
import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
|
|
48
|
+
import { DEFAULT_TENANT_CODE, requestTenantOptions } from "@liujitcn/kratos-admin-core/tenant";
|
|
49
|
+
|
|
50
|
+
defineOptions({
|
|
51
|
+
name: "OauthClient",
|
|
52
|
+
inheritAttrs: false
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const { BUTTONS } = useAuthButtons();
|
|
56
|
+
const userStore = useUserStore();
|
|
57
|
+
const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
|
|
58
|
+
const proTable = ref<ProTableInstance>();
|
|
59
|
+
const formDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
60
|
+
const apiOptions = ref<BaseApi[]>([]);
|
|
61
|
+
const tenantOptions = ref<SelectOptionResponse_Option[]>([]);
|
|
62
|
+
|
|
63
|
+
const dialog = reactive({
|
|
64
|
+
titleKey: "common.action.create",
|
|
65
|
+
visible: false
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const formData = reactive<OauthClientForm>({
|
|
69
|
+
id: 0,
|
|
70
|
+
tenant_id: 0,
|
|
71
|
+
client_name: "",
|
|
72
|
+
crypto_type: OauthClientCryptoType.OAUTH_CLIENT_CRYPTO_TYPE_SM4,
|
|
73
|
+
ip_whitelist: "",
|
|
74
|
+
api: [],
|
|
75
|
+
status: Status.STATUS_ENABLE
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
void loadTenantOptions();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const cryptoOptions = computed<ProFormOption[]>(() => [
|
|
83
|
+
{ label: "SM4-GCM", value: OauthClientCryptoType.OAUTH_CLIENT_CRYPTO_TYPE_SM4 },
|
|
84
|
+
{ label: "AES-GCM", value: OauthClientCryptoType.OAUTH_CLIENT_CRYPTO_TYPE_AES }
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
const statusOptions = computed<ProFormOption[]>(() => [
|
|
88
|
+
{ label: t("common.status.enabled"), value: Status.STATUS_ENABLE },
|
|
89
|
+
{ label: t("common.status.disabled"), value: Status.STATUS_DISABLE }
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
const transferOptions = computed<ProFormOption[]>(() =>
|
|
93
|
+
apiOptions.value.map(item => ({
|
|
94
|
+
value: item.operation,
|
|
95
|
+
label: item.operation
|
|
96
|
+
}))
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const tenantNameMap = computed(() => new Map(tenantOptions.value.map(item => [item.value, item.label])));
|
|
100
|
+
|
|
101
|
+
const rules = computed(() => ({
|
|
102
|
+
tenant_id: [
|
|
103
|
+
{
|
|
104
|
+
required: isDefaultTenant.value,
|
|
105
|
+
message: t("common.validation.required_select", { field: t("system.base.oauth_client.field.tenant") }),
|
|
106
|
+
trigger: "change"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
client_name: [
|
|
110
|
+
{
|
|
111
|
+
required: true,
|
|
112
|
+
message: t("common.validation.required_input", { field: t("system.base.oauth_client.field.client_name") }),
|
|
113
|
+
trigger: "blur"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
max: 100,
|
|
117
|
+
message: t("common.validation.max_length", { field: t("system.base.oauth_client.field.client_name"), max: 100 }),
|
|
118
|
+
trigger: "blur"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
crypto_type: [
|
|
122
|
+
{
|
|
123
|
+
required: true,
|
|
124
|
+
message: t("common.validation.required_select", { field: t("system.base.oauth_client.field.crypto_type") }),
|
|
125
|
+
trigger: "change"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
status: [
|
|
129
|
+
{ required: true, message: t("common.validation.required_select", { field: t("common.field.status") }), trigger: "change" }
|
|
130
|
+
]
|
|
131
|
+
}));
|
|
132
|
+
|
|
133
|
+
const formFields = computed<ProFormField[]>(() => [
|
|
134
|
+
{
|
|
135
|
+
prop: "tenant_id",
|
|
136
|
+
label: t("system.base.oauth_client.field.tenant"),
|
|
137
|
+
component: "select",
|
|
138
|
+
props: { filterable: true, disabled: Boolean(formData.id) },
|
|
139
|
+
options: tenantOptions.value,
|
|
140
|
+
visible: () => isDefaultTenant.value
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
prop: "client_name",
|
|
144
|
+
label: t("system.base.oauth_client.field.client_name"),
|
|
145
|
+
component: "input"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
prop: "crypto_type",
|
|
149
|
+
label: t("system.base.oauth_client.field.crypto_type"),
|
|
150
|
+
component: "select",
|
|
151
|
+
options: cryptoOptions.value
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
prop: "ip_whitelist",
|
|
155
|
+
label: t("system.base.oauth_client.field.ip_whitelist"),
|
|
156
|
+
component: "textarea",
|
|
157
|
+
props: { rows: 2 },
|
|
158
|
+
colSpan: 24
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
prop: "api",
|
|
162
|
+
label: t("system.base.oauth_client.field.api"),
|
|
163
|
+
component: "transfer",
|
|
164
|
+
options: transferOptions.value,
|
|
165
|
+
props: {
|
|
166
|
+
filterable: true,
|
|
167
|
+
titles: [t("system.base.oauth_client.value.available_api"), t("system.base.oauth_client.value.selected_api")],
|
|
168
|
+
style: { width: "100%" }
|
|
169
|
+
},
|
|
170
|
+
colSpan: 24
|
|
171
|
+
},
|
|
172
|
+
{ prop: "status", label: t("common.field.status"), component: "radio-group", options: statusOptions.value }
|
|
173
|
+
]);
|
|
174
|
+
|
|
175
|
+
const columns = computed<ColumnProps[]>(() => [
|
|
176
|
+
{ type: "selection", width: 55 },
|
|
177
|
+
...(isDefaultTenant.value
|
|
178
|
+
? ([
|
|
179
|
+
{
|
|
180
|
+
prop: "tenant_id",
|
|
181
|
+
label: t("system.base.oauth_client.field.tenant"),
|
|
182
|
+
minWidth: 130,
|
|
183
|
+
search: { el: "select", key: "tenant_id", props: { filterable: true }, order: 1 },
|
|
184
|
+
enum: requestTenantOptions,
|
|
185
|
+
render: scope =>
|
|
186
|
+
tenantNameMap.value.get((scope.row as OauthClient).tenant_id) ?? String((scope.row as OauthClient).tenant_id)
|
|
187
|
+
}
|
|
188
|
+
] satisfies ColumnProps[])
|
|
189
|
+
: []),
|
|
190
|
+
{ prop: "client_id", label: t("system.base.oauth_client.field.client_id"), minWidth: 220 },
|
|
191
|
+
{ prop: "client_name", label: t("system.base.oauth_client.field.client_name"), minWidth: 160, search: { el: "input" } },
|
|
192
|
+
{
|
|
193
|
+
prop: "crypto_type",
|
|
194
|
+
label: t("system.base.oauth_client.field.crypto_type"),
|
|
195
|
+
width: 110,
|
|
196
|
+
render: scope => formatCrypto((scope.row as OauthClient).crypto_type)
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
prop: "ip_whitelist",
|
|
200
|
+
label: t("system.base.oauth_client.field.ip_whitelist"),
|
|
201
|
+
minWidth: 180,
|
|
202
|
+
render: scope => (scope.row as OauthClient).ip_whitelist || t("common.value.none")
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
prop: "api",
|
|
206
|
+
label: t("system.base.oauth_client.field.api"),
|
|
207
|
+
width: 90,
|
|
208
|
+
render: scope => String((scope.row as OauthClient).api?.length ?? 0)
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
prop: "status",
|
|
212
|
+
label: t("common.field.status"),
|
|
213
|
+
width: 110,
|
|
214
|
+
search: { el: "select", enum: statusOptions.value },
|
|
215
|
+
cellType: "status",
|
|
216
|
+
statusProps: {
|
|
217
|
+
activeValue: Status.STATUS_ENABLE,
|
|
218
|
+
inactiveValue: Status.STATUS_DISABLE,
|
|
219
|
+
activeText: t("common.status.enabled"),
|
|
220
|
+
inactiveText: t("common.status.disabled"),
|
|
221
|
+
disabled: () => !BUTTONS.value["base:oauth-client:status"],
|
|
222
|
+
beforeChange: scope => handleSetStatus(scope.row as OauthClient)
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
prop: "operation",
|
|
227
|
+
label: t("common.field.operation"),
|
|
228
|
+
width: 280,
|
|
229
|
+
fixed: "right",
|
|
230
|
+
cellType: "actions",
|
|
231
|
+
actions: [
|
|
232
|
+
{
|
|
233
|
+
label: t("system.base.oauth_client.action.copy_credentials"),
|
|
234
|
+
type: "primary",
|
|
235
|
+
link: true,
|
|
236
|
+
icon: CopyDocument,
|
|
237
|
+
hidden: () => !BUTTONS.value["base:oauth-client:credentials"],
|
|
238
|
+
onClick: scope => handleCopyCredentials(scope.row as OauthClient)
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
label: t("common.action.edit"),
|
|
242
|
+
link: true,
|
|
243
|
+
icon: EditPen,
|
|
244
|
+
hidden: () => !BUTTONS.value["base:oauth-client:update"],
|
|
245
|
+
onClick: scope => handleOpenDialog((scope.row as OauthClient).id)
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
label: t("common.action.delete"),
|
|
249
|
+
type: "danger",
|
|
250
|
+
link: true,
|
|
251
|
+
icon: Delete,
|
|
252
|
+
hidden: () => !BUTTONS.value["base:oauth-client:delete"],
|
|
253
|
+
onClick: scope => handleDelete(scope.row as OauthClient)
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
]);
|
|
258
|
+
|
|
259
|
+
const headerActions = computed<HeaderActionProps[]>(() => [
|
|
260
|
+
{
|
|
261
|
+
label: t("common.action.create"),
|
|
262
|
+
type: "success",
|
|
263
|
+
icon: CirclePlus,
|
|
264
|
+
hidden: () => !BUTTONS.value["base:oauth-client:create"],
|
|
265
|
+
onClick: () => handleOpenDialog()
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
label: t("common.action.delete"),
|
|
269
|
+
type: "danger",
|
|
270
|
+
icon: Delete,
|
|
271
|
+
hidden: () => !BUTTONS.value["base:oauth-client:delete"],
|
|
272
|
+
disabled: scope => !scope.selectedList.length,
|
|
273
|
+
onClick: scope => handleDelete(scope.selectedList as OauthClient[])
|
|
274
|
+
}
|
|
275
|
+
]);
|
|
276
|
+
|
|
277
|
+
async function requestOauthClientTable(params: PageOauthClientRequest) {
|
|
278
|
+
const data = await defOauthClientService.PageOauthClient(buildPageRequest(params));
|
|
279
|
+
return { data: { list: data.oauth_clients ?? [], total: data.total } };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async function loadApiOptions() {
|
|
283
|
+
const data = await defOauthClientService.OptionOauthClientApi({});
|
|
284
|
+
apiOptions.value = data.base_apis ?? [];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function loadTenantOptions() {
|
|
288
|
+
if (userStore.userInfo.tenant_code !== DEFAULT_TENANT_CODE || tenantOptions.value.length) return;
|
|
289
|
+
const data = await defBaseTenantService.OptionBaseTenant({ keyword: "" });
|
|
290
|
+
tenantOptions.value = data.list ?? [];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async function handleOpenDialog(id?: number) {
|
|
294
|
+
await loadTenantOptions();
|
|
295
|
+
await loadApiOptions();
|
|
296
|
+
resetForm();
|
|
297
|
+
dialog.titleKey = id ? "common.action.edit" : "common.action.create";
|
|
298
|
+
dialog.visible = true;
|
|
299
|
+
if (id) Object.assign(formData, await defOauthClientService.GetOauthClient({ id }));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function resetForm() {
|
|
303
|
+
formDialogRef.value?.resetFields();
|
|
304
|
+
formDialogRef.value?.clearValidate();
|
|
305
|
+
Object.assign(formData, {
|
|
306
|
+
id: 0,
|
|
307
|
+
tenant_id: 0,
|
|
308
|
+
client_name: "",
|
|
309
|
+
crypto_type: OauthClientCryptoType.OAUTH_CLIENT_CRYPTO_TYPE_SM4,
|
|
310
|
+
ip_whitelist: "",
|
|
311
|
+
api: [],
|
|
312
|
+
status: Status.STATUS_ENABLE
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function handleCloseDialog() {
|
|
317
|
+
dialog.visible = false;
|
|
318
|
+
resetForm();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function handleSubmit() {
|
|
322
|
+
formDialogRef.value?.validate()?.then(valid => {
|
|
323
|
+
if (!valid) return;
|
|
324
|
+
const payload = JSON.parse(JSON.stringify(formData)) as OauthClientForm;
|
|
325
|
+
const request = payload.id
|
|
326
|
+
? defOauthClientService.UpdateOauthClient({ oauth_client: payload })
|
|
327
|
+
: defOauthClientService.CreateOauthClient({ oauth_client: payload });
|
|
328
|
+
request.then(() => {
|
|
329
|
+
ElMessage.success(
|
|
330
|
+
t(payload.id ? "common.message.update_success" : "common.message.create_success", {
|
|
331
|
+
resource: t("system.base.oauth_client.resource")
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
handleCloseDialog();
|
|
335
|
+
proTable.value?.getTableList();
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async function handleSetStatus(row: OauthClient) {
|
|
341
|
+
const nextStatus = row.status === Status.STATUS_ENABLE ? Status.STATUS_DISABLE : Status.STATUS_ENABLE;
|
|
342
|
+
try {
|
|
343
|
+
await ElMessageBox.confirm(
|
|
344
|
+
t("common.dialog.status_change", {
|
|
345
|
+
action: nextStatus === Status.STATUS_ENABLE ? t("common.action.enable") : t("common.action.disable"),
|
|
346
|
+
resource: t("system.base.oauth_client.resource"),
|
|
347
|
+
field: t("system.base.oauth_client.field.client_name"),
|
|
348
|
+
value: row.client_name
|
|
349
|
+
}),
|
|
350
|
+
t("common.title.warning"),
|
|
351
|
+
{ type: "warning", confirmButtonText: t("common.action.confirm"), cancelButtonText: t("common.action.cancel") }
|
|
352
|
+
);
|
|
353
|
+
await defOauthClientService.SetOauthClientStatus({ id: row.id, status: nextStatus });
|
|
354
|
+
ElMessage.success(t("common.message.update_success", { resource: t("system.base.oauth_client.resource") }));
|
|
355
|
+
proTable.value?.getTableList();
|
|
356
|
+
return true;
|
|
357
|
+
} catch {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function handleDelete(selected?: number | string | Array<number | string> | OauthClient | OauthClient[]) {
|
|
363
|
+
const rowList = Array.isArray(selected)
|
|
364
|
+
? (selected.filter(item => typeof item === "object") as OauthClient[])
|
|
365
|
+
: selected && typeof selected === "object"
|
|
366
|
+
? [selected as OauthClient]
|
|
367
|
+
: [];
|
|
368
|
+
const ids = rowList.length
|
|
369
|
+
? rowList.map(item => item.id)
|
|
370
|
+
: normalizeSelectedIds(selected as number | string | Array<number | string>);
|
|
371
|
+
const value = ids.filter(Boolean).join(",");
|
|
372
|
+
if (!value) {
|
|
373
|
+
ElMessage.warning(t("common.message.select_delete_item"));
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const resource = rowList.length
|
|
377
|
+
? `${t("system.base.oauth_client.resource")}:${rowList
|
|
378
|
+
.map(item => item.client_name)
|
|
379
|
+
.filter(Boolean)
|
|
380
|
+
.join("、")}`
|
|
381
|
+
: t("system.base.oauth_client.resource");
|
|
382
|
+
ElMessageBox.confirm(t("common.dialog.delete_selected", { resource }), t("common.title.warning"), {
|
|
383
|
+
type: "warning",
|
|
384
|
+
confirmButtonText: t("common.action.confirm"),
|
|
385
|
+
cancelButtonText: t("common.action.cancel")
|
|
386
|
+
})
|
|
387
|
+
.then(() => {
|
|
388
|
+
return defOauthClientService.DeleteOauthClient({ id: value });
|
|
389
|
+
})
|
|
390
|
+
.then(() => {
|
|
391
|
+
ElMessage.success(t("common.message.delete_success", { resource: t("system.base.oauth_client.resource") }));
|
|
392
|
+
proTable.value?.getTableList();
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
async function handleCopyCredentials(row: OauthClient) {
|
|
397
|
+
const credentials = await defOauthClientService.RotateOauthClientCredentials({ id: row.id });
|
|
398
|
+
const content = [
|
|
399
|
+
`${t("system.base.oauth_client.field.client_id")}:${credentials.client_id}`,
|
|
400
|
+
`${t("system.base.oauth_client.field.client_secret")}:${credentials.client_secret}`,
|
|
401
|
+
`${t("system.base.oauth_client.field.crypto_type")}:${formatCrypto(credentials.crypto_type)}`,
|
|
402
|
+
`${t("system.base.oauth_client.field.crypto_key")}:${credentials.crypto_key}`
|
|
403
|
+
].join("\n");
|
|
404
|
+
await copyText(content);
|
|
405
|
+
ElMessage.success(t("core.clipboard.success"));
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function formatCrypto(value: OauthClientCryptoType) {
|
|
409
|
+
return cryptoOptions.value.find(item => item.value === value)?.label ?? String(value);
|
|
410
|
+
}
|
|
411
|
+
</script>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AuditLogTable ref="page" :config="config" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, ref } from "vue";
|
|
7
|
+
import type { ColumnProps } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
8
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
9
|
+
import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
|
|
10
|
+
import AuditLogTable, { type AuditLogTableConfig } from "@liujitcn/kratos-admin-system/components/AuditLogTable.vue";
|
|
11
|
+
import { auditDateSearch, auditDetailColumn, auditEnumLabel, createAuditEnumOptions } from "@liujitcn/kratos-admin-system/components/auditLog";
|
|
12
|
+
import { defBaseOperationLogService } from "@liujitcn/kratos-admin-system/api/system/base_audit_log";
|
|
13
|
+
import { BaseAuditResult, BaseOperationAction } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_audit_log";
|
|
14
|
+
import type { BaseOperationLog, PageBaseOperationLogRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_audit_log";
|
|
15
|
+
|
|
16
|
+
defineOptions({ name: "BaseOperationLog", inheritAttrs: false });
|
|
17
|
+
|
|
18
|
+
const page = ref<InstanceType<typeof AuditLogTable>>();
|
|
19
|
+
const resultOptions = computed(() => createAuditEnumOptions([
|
|
20
|
+
[BaseAuditResult.BASE_AUDIT_RESULT_SUCCESS, t("system.base.audit.result.success")],
|
|
21
|
+
[BaseAuditResult.BASE_AUDIT_RESULT_FAILURE, t("system.base.audit.result.failure")],
|
|
22
|
+
[BaseAuditResult.BASE_AUDIT_RESULT_ERROR, t("system.base.audit.result.error")]
|
|
23
|
+
]));
|
|
24
|
+
const actionOptions = computed(() => createAuditEnumOptions([
|
|
25
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_CREATE, t("system.base.audit.operation_action.create")],
|
|
26
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_UPDATE, t("system.base.audit.operation_action.update")],
|
|
27
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_DELETE, t("system.base.audit.operation_action.delete")],
|
|
28
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_PUBLISH, t("system.base.audit.operation_action.publish")],
|
|
29
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_REVOKE, t("system.base.audit.operation_action.revoke")],
|
|
30
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_IMPORT, t("system.base.audit.operation_action.import")],
|
|
31
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_EXPORT, t("system.base.audit.operation_action.export")],
|
|
32
|
+
[BaseOperationAction.BASE_OPERATION_ACTION_OTHER, t("system.base.audit.operation_action.other")]
|
|
33
|
+
]));
|
|
34
|
+
const columns = computed<ColumnProps[]>(() => [
|
|
35
|
+
{ prop: "resource_type", label: t("system.base.audit.field.resource_type"), minWidth: 150, search: { el: "input" } },
|
|
36
|
+
{ prop: "resource_id", label: t("system.base.audit.field.resource_id"), minWidth: 120 },
|
|
37
|
+
{ prop: "resource_name", label: t("system.base.audit.field.resource_name"), minWidth: 160 },
|
|
38
|
+
{ prop: "action", label: t("system.base.audit.field.action"), minWidth: 110, search: { el: "select", enum: actionOptions.value }, render: scope => auditEnumLabel(actionOptions.value, (scope.row as BaseOperationLog).action) },
|
|
39
|
+
{ prop: "result", label: t("system.base.audit.field.result"), minWidth: 110, search: { el: "select", enum: resultOptions.value }, render: scope => auditEnumLabel(resultOptions.value, (scope.row as BaseOperationLog).result) },
|
|
40
|
+
{ prop: "user_name", label: t("system.base.audit.field.user_name"), minWidth: 130 },
|
|
41
|
+
{ prop: "occurred_at", label: t("system.base.audit.field.occurred_at"), minWidth: 190, search: auditDateSearch(t) },
|
|
42
|
+
auditDetailColumn(t("common.action.view"), id => page.value?.handleOpenDialog(id))
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const config = computed<AuditLogTableConfig>(() => ({
|
|
46
|
+
columns: columns.value,
|
|
47
|
+
detailTitle: t("system.base.audit.operation.title.detail"),
|
|
48
|
+
closeText: t("common.action.close"),
|
|
49
|
+
detailFields: [
|
|
50
|
+
{ key: "id", label: t("system.base.audit.field.id") },
|
|
51
|
+
{ key: "tenant_id", label: t("system.base.audit.field.tenant_id") },
|
|
52
|
+
{ key: "tenant_code", label: t("system.base.audit.field.tenant_code") },
|
|
53
|
+
{ key: "user_id", label: t("system.base.audit.field.user_id") },
|
|
54
|
+
{ key: "user_name", label: t("system.base.audit.field.user_name") },
|
|
55
|
+
{ key: "resource_type", label: t("system.base.audit.field.resource_type") },
|
|
56
|
+
{ key: "resource_id", label: t("system.base.audit.field.resource_id") },
|
|
57
|
+
{ key: "resource_name", label: t("system.base.audit.field.resource_name") },
|
|
58
|
+
{ key: "action", label: t("system.base.audit.field.action") },
|
|
59
|
+
{ key: "result", label: t("system.base.audit.field.result") },
|
|
60
|
+
{ key: "changed_fields", label: t("system.base.audit.field.changed_fields"), span: 2, code: true },
|
|
61
|
+
{ key: "before_data", label: t("system.base.audit.field.before_data"), span: 2, code: true },
|
|
62
|
+
{ key: "after_data", label: t("system.base.audit.field.after_data"), span: 2, code: true },
|
|
63
|
+
{ key: "reason_code", label: t("system.base.audit.field.reason_code") },
|
|
64
|
+
{ key: "reason", label: t("system.base.audit.field.reason"), span: 2 },
|
|
65
|
+
{ key: "request_id", label: t("system.base.audit.field.request_id") },
|
|
66
|
+
{ key: "trace_id", label: t("system.base.audit.field.trace_id") },
|
|
67
|
+
{ key: "occurred_at", label: t("system.base.audit.field.occurred_at") },
|
|
68
|
+
{ key: "created_at", label: t("system.base.audit.field.created_at") }
|
|
69
|
+
],
|
|
70
|
+
request: requestTable,
|
|
71
|
+
get: getDetail
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
async function requestTable(params: Record<string, unknown>) {
|
|
75
|
+
const response = await defBaseOperationLogService.PageBaseOperationLog(buildPageRequest(params as unknown as PageBaseOperationLogRequest));
|
|
76
|
+
return { list: response.base_operation_logs as unknown as Record<string, unknown>[], total: response.total };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function getDetail(id: number) {
|
|
80
|
+
return (await defBaseOperationLogService.GetBaseOperationLog({ id })) as unknown as Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AuditLogTable ref="page" :config="config" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, ref } from "vue";
|
|
7
|
+
import type { ColumnProps } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
8
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
9
|
+
import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
|
|
10
|
+
import AuditLogTable, { type AuditLogTableConfig } from "@liujitcn/kratos-admin-system/components/AuditLogTable.vue";
|
|
11
|
+
import { auditDateSearch, auditDetailColumn, auditEnumLabel, createAuditEnumOptions } from "@liujitcn/kratos-admin-system/components/auditLog";
|
|
12
|
+
import { defBasePermissionLogService } from "@liujitcn/kratos-admin-system/api/system/base_audit_log";
|
|
13
|
+
import { BaseAuditResult, BasePermissionAction, BasePermissionTargetType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_audit_log";
|
|
14
|
+
import type { BasePermissionLog, PageBasePermissionLogRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_audit_log";
|
|
15
|
+
|
|
16
|
+
defineOptions({ name: "BasePermissionLog", inheritAttrs: false });
|
|
17
|
+
|
|
18
|
+
const page = ref<InstanceType<typeof AuditLogTable>>();
|
|
19
|
+
const resultOptions = computed(() => createAuditEnumOptions([
|
|
20
|
+
[BaseAuditResult.BASE_AUDIT_RESULT_SUCCESS, t("system.base.audit.result.success")],
|
|
21
|
+
[BaseAuditResult.BASE_AUDIT_RESULT_FAILURE, t("system.base.audit.result.failure")],
|
|
22
|
+
[BaseAuditResult.BASE_AUDIT_RESULT_ERROR, t("system.base.audit.result.error")]
|
|
23
|
+
]));
|
|
24
|
+
const targetOptions = computed(() => createAuditEnumOptions([
|
|
25
|
+
[BasePermissionTargetType.BASE_PERMISSION_TARGET_TYPE_USER, t("system.base.audit.target_type.user")],
|
|
26
|
+
[BasePermissionTargetType.BASE_PERMISSION_TARGET_TYPE_ROLE, t("system.base.audit.target_type.role")],
|
|
27
|
+
[BasePermissionTargetType.BASE_PERMISSION_TARGET_TYPE_MENU, t("system.base.audit.target_type.menu")],
|
|
28
|
+
[BasePermissionTargetType.BASE_PERMISSION_TARGET_TYPE_API, t("system.base.audit.target_type.api")],
|
|
29
|
+
[BasePermissionTargetType.BASE_PERMISSION_TARGET_TYPE_TENANT, t("system.base.audit.target_type.tenant")]
|
|
30
|
+
]));
|
|
31
|
+
const actionOptions = computed(() => createAuditEnumOptions([
|
|
32
|
+
[BasePermissionAction.BASE_PERMISSION_ACTION_GRANT, t("system.base.audit.permission_action.grant")],
|
|
33
|
+
[BasePermissionAction.BASE_PERMISSION_ACTION_REVOKE, t("system.base.audit.permission_action.revoke")],
|
|
34
|
+
[BasePermissionAction.BASE_PERMISSION_ACTION_CREATE, t("system.base.audit.permission_action.create")],
|
|
35
|
+
[BasePermissionAction.BASE_PERMISSION_ACTION_UPDATE, t("system.base.audit.permission_action.update")],
|
|
36
|
+
[BasePermissionAction.BASE_PERMISSION_ACTION_DELETE, t("system.base.audit.permission_action.delete")],
|
|
37
|
+
[BasePermissionAction.BASE_PERMISSION_ACTION_ASSIGN, t("system.base.audit.permission_action.assign")]
|
|
38
|
+
]));
|
|
39
|
+
const columns = computed<ColumnProps[]>(() => [
|
|
40
|
+
{ prop: "target_type", label: t("system.base.audit.field.target_type"), minWidth: 120, search: { el: "select", enum: targetOptions.value }, render: scope => auditEnumLabel(targetOptions.value, (scope.row as BasePermissionLog).target_type) },
|
|
41
|
+
{ prop: "target_name", label: t("system.base.audit.field.target_name"), minWidth: 180, search: { el: "input" } },
|
|
42
|
+
{ prop: "action", label: t("system.base.audit.field.action"), minWidth: 110, search: { el: "select", enum: actionOptions.value }, render: scope => auditEnumLabel(actionOptions.value, (scope.row as BasePermissionLog).action) },
|
|
43
|
+
{ prop: "result", label: t("system.base.audit.field.result"), minWidth: 110, search: { el: "select", enum: resultOptions.value }, render: scope => auditEnumLabel(resultOptions.value, (scope.row as BasePermissionLog).result) },
|
|
44
|
+
{ prop: "user_name", label: t("system.base.audit.field.user_name"), minWidth: 130 },
|
|
45
|
+
{ prop: "occurred_at", label: t("system.base.audit.field.occurred_at"), minWidth: 190, search: auditDateSearch(t) },
|
|
46
|
+
auditDetailColumn(t("common.action.view"), id => page.value?.handleOpenDialog(id))
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
const config = computed<AuditLogTableConfig>(() => ({
|
|
50
|
+
columns: columns.value,
|
|
51
|
+
detailTitle: t("system.base.audit.permission.title.detail"),
|
|
52
|
+
closeText: t("common.action.close"),
|
|
53
|
+
detailFields: [
|
|
54
|
+
{ key: "id", label: t("system.base.audit.field.id") },
|
|
55
|
+
{ key: "tenant_id", label: t("system.base.audit.field.tenant_id") },
|
|
56
|
+
{ key: "tenant_code", label: t("system.base.audit.field.tenant_code") },
|
|
57
|
+
{ key: "user_id", label: t("system.base.audit.field.user_id") },
|
|
58
|
+
{ key: "user_name", label: t("system.base.audit.field.user_name") },
|
|
59
|
+
{ key: "target_type", label: t("system.base.audit.field.target_type") },
|
|
60
|
+
{ key: "target_id", label: t("system.base.audit.field.target_id") },
|
|
61
|
+
{ key: "target_name", label: t("system.base.audit.field.target_name") },
|
|
62
|
+
{ key: "action", label: t("system.base.audit.field.action") },
|
|
63
|
+
{ key: "old_value", label: t("system.base.audit.field.old_value"), span: 2, code: true },
|
|
64
|
+
{ key: "new_value", label: t("system.base.audit.field.new_value"), span: 2, code: true },
|
|
65
|
+
{ key: "result", label: t("system.base.audit.field.result") },
|
|
66
|
+
{ key: "reason_code", label: t("system.base.audit.field.reason_code") },
|
|
67
|
+
{ key: "reason", label: t("system.base.audit.field.reason"), span: 2 },
|
|
68
|
+
{ key: "request_id", label: t("system.base.audit.field.request_id") },
|
|
69
|
+
{ key: "trace_id", label: t("system.base.audit.field.trace_id") },
|
|
70
|
+
{ key: "occurred_at", label: t("system.base.audit.field.occurred_at") },
|
|
71
|
+
{ key: "created_at", label: t("system.base.audit.field.created_at") }
|
|
72
|
+
],
|
|
73
|
+
request: requestTable,
|
|
74
|
+
get: getDetail
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
async function requestTable(params: Record<string, unknown>) {
|
|
78
|
+
const response = await defBasePermissionLogService.PageBasePermissionLog(buildPageRequest(params as unknown as PageBasePermissionLogRequest));
|
|
79
|
+
return { list: response.base_permission_logs as unknown as Record<string, unknown>[], total: response.total };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function getDetail(id: number) {
|
|
83
|
+
return (await defBasePermissionLogService.GetBasePermissionLog({ id })) as unknown as Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AuditLogTable ref="page" :config="config" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, ref } from "vue";
|
|
7
|
+
import type { ColumnProps } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
8
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
9
|
+
import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
|
|
10
|
+
import AuditLogTable, { type AuditLogTableConfig } from "@liujitcn/kratos-admin-system/components/AuditLogTable.vue";
|
|
11
|
+
import { auditDateSearch, auditDetailColumn, auditEnumLabel, createAuditEnumOptions } from "@liujitcn/kratos-admin-system/components/auditLog";
|
|
12
|
+
import { defBasePolicyEvaluationLogService } from "@liujitcn/kratos-admin-system/api/system/base_audit_log";
|
|
13
|
+
import { BasePolicyDecision, BasePolicyEvaluationType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_audit_log";
|
|
14
|
+
import type { BasePolicyEvaluationLog, PageBasePolicyEvaluationLogRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_audit_log";
|
|
15
|
+
|
|
16
|
+
defineOptions({ name: "BasePolicyEvaluationLog", inheritAttrs: false });
|
|
17
|
+
|
|
18
|
+
const page = ref<InstanceType<typeof AuditLogTable>>();
|
|
19
|
+
const decisionOptions = computed(() => createAuditEnumOptions([
|
|
20
|
+
[BasePolicyDecision.BASE_POLICY_DECISION_ALLOW, t("system.base.audit.policy_decision.allow")],
|
|
21
|
+
[BasePolicyDecision.BASE_POLICY_DECISION_DENY, t("system.base.audit.policy_decision.deny")],
|
|
22
|
+
[BasePolicyDecision.BASE_POLICY_DECISION_ERROR, t("system.base.audit.policy_decision.error")]
|
|
23
|
+
]));
|
|
24
|
+
const evaluationTypeOptions = computed(() => createAuditEnumOptions([
|
|
25
|
+
[BasePolicyEvaluationType.BASE_POLICY_EVALUATION_TYPE_IS_AUTHORIZED, t("system.base.audit.evaluation_type.is_authorized")],
|
|
26
|
+
[BasePolicyEvaluationType.BASE_POLICY_EVALUATION_TYPE_FILTER_PAIRS, t("system.base.audit.evaluation_type.filter_pairs")],
|
|
27
|
+
[BasePolicyEvaluationType.BASE_POLICY_EVALUATION_TYPE_FILTER_PROJECTS, t("system.base.audit.evaluation_type.filter_projects")]
|
|
28
|
+
]));
|
|
29
|
+
const columns = computed<ColumnProps[]>(() => [
|
|
30
|
+
{ prop: "resource", label: t("system.base.audit.field.resource"), minWidth: 320, search: { el: "input" } },
|
|
31
|
+
{ prop: "action", label: t("system.base.audit.field.action"), minWidth: 100 },
|
|
32
|
+
{ prop: "engine", label: t("system.base.audit.field.engine"), minWidth: 100 },
|
|
33
|
+
{ prop: "evaluation_type", label: t("system.base.audit.field.evaluation_type"), minWidth: 160, search: { el: "select", enum: evaluationTypeOptions.value }, render: scope => auditEnumLabel(evaluationTypeOptions.value, (scope.row as BasePolicyEvaluationLog).evaluation_type) },
|
|
34
|
+
{ prop: "decision", label: t("system.base.audit.field.decision"), minWidth: 110, search: { el: "select", enum: decisionOptions.value }, render: scope => auditEnumLabel(decisionOptions.value, (scope.row as BasePolicyEvaluationLog).decision) },
|
|
35
|
+
{ prop: "duration_ms", label: t("system.base.audit.field.duration_ms"), minWidth: 110 },
|
|
36
|
+
{ prop: "occurred_at", label: t("system.base.audit.field.occurred_at"), minWidth: 190, search: auditDateSearch(t) },
|
|
37
|
+
auditDetailColumn(t("common.action.view"), id => page.value?.handleOpenDialog(id))
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
const config = computed<AuditLogTableConfig>(() => ({
|
|
41
|
+
columns: columns.value,
|
|
42
|
+
detailTitle: t("system.base.audit.policy.title.detail"),
|
|
43
|
+
closeText: t("common.action.close"),
|
|
44
|
+
detailFields: [
|
|
45
|
+
{ key: "id", label: t("system.base.audit.field.id") },
|
|
46
|
+
{ key: "tenant_id", label: t("system.base.audit.field.tenant_id") },
|
|
47
|
+
{ key: "tenant_code", label: t("system.base.audit.field.tenant_code") },
|
|
48
|
+
{ key: "user_id", label: t("system.base.audit.field.user_id") },
|
|
49
|
+
{ key: "user_name", label: t("system.base.audit.field.user_name") },
|
|
50
|
+
{ key: "role_id", label: t("system.base.audit.field.role_id") },
|
|
51
|
+
{ key: "role_code", label: t("system.base.audit.field.role_code") },
|
|
52
|
+
{ key: "engine", label: t("system.base.audit.field.engine") },
|
|
53
|
+
{ key: "evaluation_type", label: t("system.base.audit.field.evaluation_type") },
|
|
54
|
+
{ key: "resource", label: t("system.base.audit.field.resource"), span: 2 },
|
|
55
|
+
{ key: "action", label: t("system.base.audit.field.action") },
|
|
56
|
+
{ key: "project", label: t("system.base.audit.field.project") },
|
|
57
|
+
{ key: "decision", label: t("system.base.audit.field.decision") },
|
|
58
|
+
{ key: "reason_code", label: t("system.base.audit.field.reason_code") },
|
|
59
|
+
{ key: "reason", label: t("system.base.audit.field.reason"), span: 2 },
|
|
60
|
+
{ key: "duration_ms", label: t("system.base.audit.field.duration_ms") },
|
|
61
|
+
{ key: "candidate_count", label: t("system.base.audit.field.candidate_count") },
|
|
62
|
+
{ key: "matched_count", label: t("system.base.audit.field.matched_count") },
|
|
63
|
+
{ key: "input_hash", label: t("system.base.audit.field.input_hash") },
|
|
64
|
+
{ key: "client_ip", label: t("system.base.audit.field.client_ip") },
|
|
65
|
+
{ key: "request_id", label: t("system.base.audit.field.request_id") },
|
|
66
|
+
{ key: "trace_id", label: t("system.base.audit.field.trace_id") },
|
|
67
|
+
{ key: "occurred_at", label: t("system.base.audit.field.occurred_at") },
|
|
68
|
+
{ key: "created_at", label: t("system.base.audit.field.created_at") }
|
|
69
|
+
],
|
|
70
|
+
request: requestTable,
|
|
71
|
+
get: getDetail
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
async function requestTable(params: Record<string, unknown>) {
|
|
75
|
+
const response = await defBasePolicyEvaluationLogService.PageBasePolicyEvaluationLog(buildPageRequest(params as unknown as PageBasePolicyEvaluationLogRequest));
|
|
76
|
+
return { list: response.base_policy_evaluation_logs as unknown as Record<string, unknown>[], total: response.total };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function getDetail(id: number) {
|
|
80
|
+
return (await defBasePolicyEvaluationLogService.GetBasePolicyEvaluationLog({ id })) as unknown as Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
</script>
|