Skip to content

Commit

Permalink
Merge pull request #349 from actiontech/feature/DMS-701
Browse files Browse the repository at this point in the history
feat: endpoint information adjustment
  • Loading branch information
LZS911 authored Dec 8, 2023
2 parents ad12569 + 9eaefb2 commit 5d25305
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 34 deletions.
43 changes: 42 additions & 1 deletion src/api/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
exportSqlManageV1FilterAuditLevelEnum,
exportSqlManageV1FilterStatusEnum,
exportSqlManageV1SortFieldEnum,
exportSqlManageV1SortOrderEnum
exportSqlManageV1SortOrderEnum,
GetSqlManageListV2FilterSourceEnum,
GetSqlManageListV2FilterAuditLevelEnum,
GetSqlManageListV2FilterStatusEnum,
GetSqlManageListV2SortFieldEnum,
GetSqlManageListV2SortOrderEnum
} from './index.enum';

import {
Expand Down Expand Up @@ -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 {}
40 changes: 40 additions & 0 deletions src/api/SqlManage/index.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
19 changes: 18 additions & 1 deletion src/api/SqlManage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
IBatchUpdateSqlManageReturn,
IExportSqlManageV1Params,
IGetSqlManageRuleTipsParams,
IGetSqlManageRuleTipsReturn
IGetSqlManageRuleTipsReturn,
IGetSqlManageListV2Params,
IGetSqlManageListV2Return,
} from './index.d';

class SqlManageService extends ServiceBase {
Expand Down Expand Up @@ -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<IGetSqlManageListV2Return>(
`/v2/projects/${project_name}/sql_manages`,
paramsData,
options
);
}
}

export default new SqlManageService();
10 changes: 5 additions & 5 deletions src/api/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/page/SQLManagement/SQLPanel/FilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -62,7 +62,7 @@ const FilterForm: React.FC<SQLPanelFilterFormProps> = ({
useEffect(() => {
form.setFieldValue(
'filter_status',
GetSqlManageListFilterStatusEnum.unhandled
GetSqlManageListV2FilterStatusEnum.unhandled
);
updateInstanceList({
project_name: projectName,
Expand Down
33 changes: 28 additions & 5 deletions src/page/SQLManagement/SQLPanel/column.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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, '--');
Expand All @@ -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, '--');
Expand All @@ -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'],
Expand All @@ -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 <Tag>{endpoints[0]}</Tag>;

}
return (
<Popover content={
<div style={{ maxWidth: '600px' }}>
<Space wrap>{
endpoints.map((v) => (
<Tag key={v}>{v}</Tag>
))
}</Space>
</div>
}>
<Tag>{endpoints[0]}</Tag>
{endpoints.length > 1 ? '...' : null}
</Popover >
)
}
},
{
dataIndex: 'status',
Expand Down
20 changes: 6 additions & 14 deletions src/page/SQLManagement/SQLPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { ResponseCode } from '../../../data/common';
import AssignMember from './AssignMember';
import {
GetSqlManageListFilterStatusEnum,
GetSqlManageListSortFieldEnum,
GetSqlManageListSortOrderEnum,
GetSqlManageListV2SortFieldEnum,
GetSqlManageListV2SortOrderEnum,
exportSqlManageV1FilterAuditLevelEnum,
exportSqlManageV1FilterSourceEnum,
exportSqlManageV1FilterStatusEnum,
Expand Down Expand Up @@ -85,30 +85,22 @@ const SQLPanel: React.FC = () => {
return undefined;
}

if (sorterInfo?.field === 'first_appear_time') {
return GetSqlManageListSortFieldEnum.first_appear_timestamp;
}
if (sorterInfo?.field === 'last_appear_time') {
return GetSqlManageListSortFieldEnum.last_receive_timestamp;
}
if (sorterInfo?.field === 'appear_num') {
return GetSqlManageListSortFieldEnum.fp_count;
}
return sorterInfo?.field as GetSqlManageListV2SortFieldEnum;
};
const getSortOrder = () => {
if (Array.isArray(sorterInfo)) {
return undefined;
}

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,
Expand Down
12 changes: 6 additions & 6 deletions src/page/SQLManagement/SQLPanel/index.type.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FormInstance } from 'antd';
import {
GetSqlManageListFilterAuditLevelEnum,
GetSqlManageListFilterSourceEnum,
GetSqlManageListFilterStatusEnum,
GetSqlManageListV2FilterSourceEnum,
GetSqlManageListV2FilterAuditLevelEnum,
GetSqlManageListV2FilterStatusEnum,
} from '../../../api/SqlManage/index.enum';

export type SQLPanelFilterFormFields = {
Expand All @@ -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;

Expand Down

0 comments on commit 5d25305

Please sign in to comment.