From 8f56cdaa0dd186720df5ff4aec389c39f7441fb2 Mon Sep 17 00:00:00 2001 From: zzyangh Date: Thu, 7 Dec 2023 13:09:17 +0800 Subject: [PATCH 1/2] feat: endpoint information adjustment --- src/api/SqlManage/index.d.ts | 43 ++++++++++++++++++- src/api/SqlManage/index.enum.ts | 40 +++++++++++++++++ src/api/SqlManage/index.ts | 19 +++++++- src/api/common.d.ts | 10 ++--- .../SQLManagement/SQLPanel/FilterForm.tsx | 4 +- src/page/SQLManagement/SQLPanel/column.tsx | 33 +++++++++++--- src/page/SQLManagement/SQLPanel/index.tsx | 16 +++---- src/page/SQLManagement/SQLPanel/index.type.ts | 12 +++--- 8 files changed, 149 insertions(+), 28 deletions(-) diff --git a/src/api/SqlManage/index.d.ts b/src/api/SqlManage/index.d.ts index f7d817c4..7afecece 100644 --- a/src/api/SqlManage/index.d.ts +++ b/src/api/SqlManage/index.d.ts @@ -8,7 +8,12 @@ import { exportSqlManageV1FilterAuditLevelEnum, exportSqlManageV1FilterStatusEnum, exportSqlManageV1SortFieldEnum, - exportSqlManageV1SortOrderEnum + exportSqlManageV1SortOrderEnum, + GetSqlManageListV2FilterSourceEnum, + GetSqlManageListV2FilterAuditLevelEnum, + GetSqlManageListV2FilterStatusEnum, + GetSqlManageListV2SortFieldEnum, + GetSqlManageListV2SortOrderEnum } from './index.enum'; import { @@ -96,3 +101,39 @@ export interface IGetSqlManageRuleTipsParams { export interface IGetSqlManageRuleTipsReturn extends IGetSqlManageRuleTipsResp {} + +export interface IGetSqlManageListV2Params { + project_name: string; + + fuzzy_search_sql_fingerprint?: string; + + filter_assignee?: string; + + filter_instance_name?: string; + + filter_source?: GetSqlManageListV2FilterSourceEnum; + + filter_audit_level?: GetSqlManageListV2FilterAuditLevelEnum; + + filter_last_audit_start_time_from?: string; + + filter_last_audit_start_time_to?: string; + + filter_status?: GetSqlManageListV2FilterStatusEnum; + + filter_rule_name?: string; + + filter_db_type?: string; + + fuzzy_search_endpoint?: string; + + sort_field?: GetSqlManageListV2SortFieldEnum; + + sort_order?: GetSqlManageListV2SortOrderEnum; + + page_index: number; + + page_size: number; +} + +export interface IGetSqlManageListV2Return extends IGetSqlManageListResp {} diff --git a/src/api/SqlManage/index.enum.ts b/src/api/SqlManage/index.enum.ts index e13ea208..82bee182 100644 --- a/src/api/SqlManage/index.enum.ts +++ b/src/api/SqlManage/index.enum.ts @@ -79,3 +79,43 @@ export enum exportSqlManageV1SortOrderEnum { 'desc' = 'desc' } + +export enum GetSqlManageListV2FilterSourceEnum { + 'audit_plan' = 'audit_plan', + + 'sql_audit_record' = 'sql_audit_record' +} + +export enum GetSqlManageListV2FilterAuditLevelEnum { + 'normal' = 'normal', + + 'notice' = 'notice', + + 'warn' = 'warn', + + 'error' = 'error' +} + +export enum GetSqlManageListV2FilterStatusEnum { + 'unhandled' = 'unhandled', + + 'solved' = 'solved', + + 'ignored' = 'ignored', + + 'manual_audited' = 'manual_audited' +} + +export enum GetSqlManageListV2SortFieldEnum { + 'first_appear_timestamp' = 'first_appear_timestamp', + + 'last_receive_timestamp' = 'last_receive_timestamp', + + 'fp_count' = 'fp_count' +} + +export enum GetSqlManageListV2SortOrderEnum { + 'asc' = 'asc', + + 'desc' = 'desc' +} diff --git a/src/api/SqlManage/index.ts b/src/api/SqlManage/index.ts index f309ac30..dde1db11 100644 --- a/src/api/SqlManage/index.ts +++ b/src/api/SqlManage/index.ts @@ -13,7 +13,9 @@ import { IBatchUpdateSqlManageReturn, IExportSqlManageV1Params, IGetSqlManageRuleTipsParams, - IGetSqlManageRuleTipsReturn + IGetSqlManageRuleTipsReturn, + IGetSqlManageListV2Params, + IGetSqlManageListV2Return, } from './index.d'; class SqlManageService extends ServiceBase { @@ -76,6 +78,21 @@ class SqlManageService extends ServiceBase { options ); } + + public GetSqlManageListV2( + params: IGetSqlManageListV2Params, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const project_name = paramsData.project_name; + delete paramsData.project_name; + + return this.get( + `/v2/projects/${project_name}/sql_manages`, + paramsData, + options + ); + } } export default new SqlManageService(); diff --git a/src/api/common.d.ts b/src/api/common.d.ts index 2a4e2e64..8bca9027 100644 --- a/src/api/common.d.ts +++ b/src/api/common.d.ts @@ -2312,21 +2312,21 @@ export interface ISqlExecutionFailPercent { } export interface ISqlManage { - appear_num?: number; - assignees?: string[]; audit_result?: IAuditResult[]; - endpoint?: string; + endpoints?: string[]; + + first_appear_timestamp?: string; - first_appear_time?: string; + fp_count?: number; id?: number; instance_name?: string; - last_appear_time?: string; + last_receive_timestamp?: string; remark?: string; diff --git a/src/page/SQLManagement/SQLPanel/FilterForm.tsx b/src/page/SQLManagement/SQLPanel/FilterForm.tsx index 0728b15f..802c6511 100644 --- a/src/page/SQLManagement/SQLPanel/FilterForm.tsx +++ b/src/page/SQLManagement/SQLPanel/FilterForm.tsx @@ -21,7 +21,7 @@ import { useEffect } from 'react'; import moment from 'moment'; import useStaticStatus from './hooks/useStaticStatus'; import { getInstanceTipListV1FunctionalModuleEnum } from '../../../api/instance/index.enum'; -import { GetSqlManageListFilterStatusEnum } from '../../../api/SqlManage/index.enum'; +import { GetSqlManageListV2FilterStatusEnum } from '../../../api/SqlManage/index.enum'; import useRuleTips from './hooks/useRuleTips'; import { extractTextFromReactNode } from '../../../utils/Common'; @@ -62,7 +62,7 @@ const FilterForm: React.FC = ({ useEffect(() => { form.setFieldValue( 'filter_status', - GetSqlManageListFilterStatusEnum.unhandled + GetSqlManageListV2FilterStatusEnum.unhandled ); updateInstanceList({ project_name: projectName, diff --git a/src/page/SQLManagement/SQLPanel/column.tsx b/src/page/SQLManagement/SQLPanel/column.tsx index a71dec98..ca5f5d88 100644 --- a/src/page/SQLManagement/SQLPanel/column.tsx +++ b/src/page/SQLManagement/SQLPanel/column.tsx @@ -1,4 +1,4 @@ -import { Space, Table, Tag, TagProps, Typography } from 'antd'; +import { Space, Table, Tag, TagProps, Typography, Popover } from 'antd'; import { GetSqlManageListFilterStatusEnum } from '../../../api/SqlManage/index.enum'; import { IAuditResult, ISource, ISqlManage } from '../../../api/common'; import { t } from '../../../locale'; @@ -125,7 +125,7 @@ export const SQLPanelColumns: (params: { }, Table.EXPAND_COLUMN, { - dataIndex: 'first_appear_time', + dataIndex: 'first_appear_timestamp', title: () => t('sqlManagement.table.firstOccurrence'), render: (time: string) => { return formatTime(time, '--'); @@ -134,7 +134,7 @@ export const SQLPanelColumns: (params: { sortDirections: ['descend', 'ascend'], }, { - dataIndex: 'last_appear_time', + dataIndex: 'last_receive_timestamp', title: () => t('sqlManagement.table.lastOccurrence'), render: (time: string) => { return formatTime(time, '--'); @@ -143,7 +143,7 @@ export const SQLPanelColumns: (params: { sortDirections: ['descend', 'ascend'], }, { - dataIndex: 'appear_num', + dataIndex: 'fp_count', title: () => t('sqlManagement.table.occurrenceCount'), sorter: true, sortDirections: ['descend', 'ascend'], @@ -160,8 +160,31 @@ export const SQLPanelColumns: (params: { }, }, { - dataIndex: 'endpoint', + dataIndex: 'endpoints', title: () => t('sqlManagement.table.endpoint'), + render: (endpoints: string[]) => { + if (!Array.isArray(endpoints) || endpoints.length === 0) { + return '--'; + } + if (endpoints.length === 1) { + return {endpoints[0]}; + + } + return ( + + { + endpoints.map((v) => ( + {v} + )) + } + + }> + {endpoints[0]} + {endpoints.length > 1 ? '...' : null} + + ) + } }, { dataIndex: 'status', diff --git a/src/page/SQLManagement/SQLPanel/index.tsx b/src/page/SQLManagement/SQLPanel/index.tsx index 0284f18e..e0a809d0 100644 --- a/src/page/SQLManagement/SQLPanel/index.tsx +++ b/src/page/SQLManagement/SQLPanel/index.tsx @@ -24,8 +24,8 @@ import { ResponseCode } from '../../../data/common'; import AssignMember from './AssignMember'; import { GetSqlManageListFilterStatusEnum, - GetSqlManageListSortFieldEnum, - GetSqlManageListSortOrderEnum, + GetSqlManageListV2SortFieldEnum, + GetSqlManageListV2SortOrderEnum, exportSqlManageV1FilterAuditLevelEnum, exportSqlManageV1FilterSourceEnum, exportSqlManageV1FilterStatusEnum, @@ -86,13 +86,13 @@ const SQLPanel: React.FC = () => { } if (sorterInfo?.field === 'first_appear_time') { - return GetSqlManageListSortFieldEnum.first_appear_timestamp; + return GetSqlManageListV2SortFieldEnum.first_appear_timestamp; } if (sorterInfo?.field === 'last_appear_time') { - return GetSqlManageListSortFieldEnum.last_receive_timestamp; + return GetSqlManageListV2SortFieldEnum.last_receive_timestamp; } if (sorterInfo?.field === 'appear_num') { - return GetSqlManageListSortFieldEnum.fp_count; + return GetSqlManageListV2SortFieldEnum.fp_count; } }; const getSortOrder = () => { @@ -101,14 +101,14 @@ const SQLPanel: React.FC = () => { } if (sorterInfo?.order === 'ascend') { - return GetSqlManageListSortOrderEnum.asc; + return GetSqlManageListV2SortOrderEnum.asc; } if (sorterInfo?.order === 'descend') { - return GetSqlManageListSortOrderEnum.desc; + return GetSqlManageListV2SortOrderEnum.desc; } }; - return SqlManage.GetSqlManageList({ + return SqlManage.GetSqlManageListV2({ project_name: projectName, page_index: pagination.pageIndex, page_size: pagination.pageSize, diff --git a/src/page/SQLManagement/SQLPanel/index.type.ts b/src/page/SQLManagement/SQLPanel/index.type.ts index a76406eb..7332f86e 100644 --- a/src/page/SQLManagement/SQLPanel/index.type.ts +++ b/src/page/SQLManagement/SQLPanel/index.type.ts @@ -1,8 +1,8 @@ import { FormInstance } from 'antd'; import { - GetSqlManageListFilterAuditLevelEnum, - GetSqlManageListFilterSourceEnum, - GetSqlManageListFilterStatusEnum, + GetSqlManageListV2FilterSourceEnum, + GetSqlManageListV2FilterAuditLevelEnum, + GetSqlManageListV2FilterStatusEnum, } from '../../../api/SqlManage/index.enum'; export type SQLPanelFilterFormFields = { @@ -12,13 +12,13 @@ export type SQLPanelFilterFormFields = { filter_instance_name?: string; - filter_source?: GetSqlManageListFilterSourceEnum; + filter_source?: GetSqlManageListV2FilterSourceEnum; - filter_audit_level?: GetSqlManageListFilterAuditLevelEnum; + filter_audit_level?: GetSqlManageListV2FilterAuditLevelEnum; filter_last_audit_time?: moment.Moment[]; - filter_status?: GetSqlManageListFilterStatusEnum; + filter_status?: GetSqlManageListV2FilterStatusEnum; filter_rule?: string; From cfe50362bc3e3172e706b2224c09dcb445ca3861 Mon Sep 17 00:00:00 2001 From: zzyangh Date: Thu, 7 Dec 2023 14:03:02 +0800 Subject: [PATCH 2/2] style: max width --- src/page/SQLManagement/SQLPanel/column.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/page/SQLManagement/SQLPanel/column.tsx b/src/page/SQLManagement/SQLPanel/column.tsx index ca5f5d88..ec43fa23 100644 --- a/src/page/SQLManagement/SQLPanel/column.tsx +++ b/src/page/SQLManagement/SQLPanel/column.tsx @@ -172,7 +172,7 @@ export const SQLPanelColumns: (params: { } return ( +
{ endpoints.map((v) => ( {v}