From 0ac1167a7d7b1feaac55e9ded6d159dee4280aa1 Mon Sep 17 00:00:00 2001 From: lizhensheng Date: Wed, 13 Dec 2023 14:29:09 +0800 Subject: [PATCH 1/2] [feature]:(SQLManagement) build api and add schema column for list --- src/api/SqlManage/index.d.ts | 6 +++ src/api/SqlManage/index.ts | 2 +- src/api/audit_plan/index.d.ts | 22 +++++++++- src/api/audit_plan/index.ts | 42 ++++++++++++++++++- src/api/common.d.ts | 30 ++++++++++++++ src/page/SQLManagement/SQLPanel/column.tsx | 48 +++++++++++++++------- 6 files changed, 133 insertions(+), 17 deletions(-) diff --git a/src/api/SqlManage/index.d.ts b/src/api/SqlManage/index.d.ts index 7afecece..ab6606d5 100644 --- a/src/api/SqlManage/index.d.ts +++ b/src/api/SqlManage/index.d.ts @@ -48,6 +48,8 @@ export interface IGetSqlManageListParams { fuzzy_search_endpoint?: string; + fuzzy_search_schema_name?: string; + sort_field?: GetSqlManageListSortFieldEnum; sort_order?: GetSqlManageListSortOrderEnum; @@ -90,6 +92,8 @@ export interface IExportSqlManageV1Params { fuzzy_search_endpoint?: string; + fuzzy_search_schema_name?: string; + sort_field?: exportSqlManageV1SortFieldEnum; sort_order?: exportSqlManageV1SortOrderEnum; @@ -127,6 +131,8 @@ export interface IGetSqlManageListV2Params { fuzzy_search_endpoint?: string; + fuzzy_search_schema_name?: string; + sort_field?: GetSqlManageListV2SortFieldEnum; sort_order?: GetSqlManageListV2SortOrderEnum; diff --git a/src/api/SqlManage/index.ts b/src/api/SqlManage/index.ts index dde1db11..5ea417b2 100644 --- a/src/api/SqlManage/index.ts +++ b/src/api/SqlManage/index.ts @@ -15,7 +15,7 @@ import { IGetSqlManageRuleTipsParams, IGetSqlManageRuleTipsReturn, IGetSqlManageListV2Params, - IGetSqlManageListV2Return, + IGetSqlManageListV2Return } from './index.d'; class SqlManageService extends ServiceBase { diff --git a/src/api/audit_plan/index.d.ts b/src/api/audit_plan/index.d.ts index 27ddd430..20b2e627 100644 --- a/src/api/audit_plan/index.d.ts +++ b/src/api/audit_plan/index.d.ts @@ -19,7 +19,9 @@ import { ITriggerAuditPlanResV1, IGetAuditPlansResV2, IGetAuditPlanReportSQLsResV2, - IGetAuditPlanAnalysisDataResV2 + IGetAuditPlanAnalysisDataResV2, + IFullSyncAuditPlanSQLsReqV2, + IPartialSyncAuditPlanSQLsReqV2 } from '../common.d'; export interface IGetAuditPlanMetasV1Params { @@ -247,3 +249,21 @@ export interface IGetAuditPlantAnalysisDataV2Params { export interface IGetAuditPlantAnalysisDataV2Return extends IGetAuditPlanAnalysisDataResV2 {} + +export interface IFullSyncAuditPlanSQLsV2Params + extends IFullSyncAuditPlanSQLsReqV2 { + project_name: string; + + audit_plan_name: string; +} + +export interface IFullSyncAuditPlanSQLsV2Return extends IBaseRes {} + +export interface IPartialSyncAuditPlanSQLsV2Params + extends IPartialSyncAuditPlanSQLsReqV2 { + project_name: string; + + audit_plan_name: string; +} + +export interface IPartialSyncAuditPlanSQLsV2Return extends IBaseRes {} diff --git a/src/api/audit_plan/index.ts b/src/api/audit_plan/index.ts index 82d0d446..67d938ee 100644 --- a/src/api/audit_plan/index.ts +++ b/src/api/audit_plan/index.ts @@ -48,7 +48,11 @@ import { IGetAuditPlanReportsSQLsParams, IGetAuditPlanReportsSQLsReturn, IGetAuditPlantAnalysisDataV2Params, - IGetAuditPlantAnalysisDataV2Return + IGetAuditPlantAnalysisDataV2Return, + IFullSyncAuditPlanSQLsV2Params, + IFullSyncAuditPlanSQLsV2Return, + IPartialSyncAuditPlanSQLsV2Params, + IPartialSyncAuditPlanSQLsV2Return } from './index.d'; class AuditPlanService extends ServiceBase { @@ -446,6 +450,42 @@ class AuditPlanService extends ServiceBase { options ); } + + public fullSyncAuditPlanSQLsV2( + params: IFullSyncAuditPlanSQLsV2Params, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const project_name = paramsData.project_name; + delete paramsData.project_name; + + const audit_plan_name = paramsData.audit_plan_name; + delete paramsData.audit_plan_name; + + return this.post( + `/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/full`, + paramsData, + options + ); + } + + public partialSyncAuditPlanSQLsV2( + params: IPartialSyncAuditPlanSQLsV2Params, + options?: AxiosRequestConfig + ) { + const paramsData = this.cloneDeep(params); + const project_name = paramsData.project_name; + delete paramsData.project_name; + + const audit_plan_name = paramsData.audit_plan_name; + delete paramsData.audit_plan_name; + + return this.post( + `/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/partial`, + paramsData, + options + ); + } } export default new AuditPlanService(); diff --git a/src/api/common.d.ts b/src/api/common.d.ts index 8bca9027..fa7bb04c 100644 --- a/src/api/common.d.ts +++ b/src/api/common.d.ts @@ -3125,6 +3125,28 @@ export interface IAuditPlanResV2 { rule_template?: IRuleTemplateV2; } +export interface IAuditPlanSQLReqV2 { + audit_plan_sql_counter?: string; + + audit_plan_sql_fingerprint?: string; + + audit_plan_sql_last_receive_text?: string; + + audit_plan_sql_last_receive_timestamp?: string; + + audit_plan_sql_schema?: string; + + db_user?: string; + + endpoints?: string[]; + + first_query_at?: string; + + query_time_avg?: number; + + query_time_max?: number; +} + export interface IAuditResDataV2 { audit_level?: AuditResDataV2AuditLevelEnum; @@ -3255,6 +3277,10 @@ export interface IDriverMeta { logo_url?: string; } +export interface IFullSyncAuditPlanSQLsReqV2 { + audit_plan_sql_list?: IAuditPlanSQLReqV2[]; +} + export interface IGetAuditPlanAnalysisDataResV2 { code?: number; @@ -3391,6 +3417,10 @@ export interface IInstanceResV2 { sql_query_config?: ISQLQueryConfigResV1; } +export interface IPartialSyncAuditPlanSQLsReqV2 { + audit_plan_sql_list?: IAuditPlanSQLReqV2[]; +} + export interface IPerformanceStatistics { affect_rows?: IAffectRows; } diff --git a/src/page/SQLManagement/SQLPanel/column.tsx b/src/page/SQLManagement/SQLPanel/column.tsx index ec43fa23..3a4be702 100644 --- a/src/page/SQLManagement/SQLPanel/column.tsx +++ b/src/page/SQLManagement/SQLPanel/column.tsx @@ -115,6 +115,22 @@ export const SQLPanelColumns: (params: { { dataIndex: 'instance_name', title: () => t('sqlManagement.table.instanceName'), + render: (name) => { + if (!name) { + return '--'; + } + return name; + }, + }, + { + dataIndex: 'schema_name', + title: () => 'Schema', + render: (schema) => { + if (!schema) { + return '--'; + } + return schema; + }, }, { dataIndex: 'audit_result', @@ -168,23 +184,24 @@ export const SQLPanelColumns: (params: { } if (endpoints.length === 1) { return {endpoints[0]}; - } return ( - - { - endpoints.map((v) => ( - {v} - )) - } - - }> + + + {endpoints.map((v) => ( + {v} + ))} + + + } + > {endpoints[0]} {endpoints.length > 1 ? '...' : null} - - ) - } + + ); + }, }, { dataIndex: 'status', @@ -215,7 +232,10 @@ export const SQLPanelColumns: (params: { width: 200, render: (remark: string, record) => { return ( - {renderRemark(remark) ?? '--'}}> + {renderRemark(remark) ?? '--'}} + > Date: Wed, 13 Dec 2023 14:41:41 +0800 Subject: [PATCH 2/2] [feature]:(SQLManagement) Add Schema column filter --- .../SQLManagement/SQLPanel/FilterForm.tsx | 15 ++++++++++--- src/page/SQLManagement/SQLPanel/index.tsx | 22 ++++++++++--------- src/page/SQLManagement/SQLPanel/index.type.ts | 2 ++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/page/SQLManagement/SQLPanel/FilterForm.tsx b/src/page/SQLManagement/SQLPanel/FilterForm.tsx index 802c6511..b72735bb 100644 --- a/src/page/SQLManagement/SQLPanel/FilterForm.tsx +++ b/src/page/SQLManagement/SQLPanel/FilterForm.tsx @@ -113,6 +113,15 @@ const FilterForm: React.FC = ({ + + + + + = ({ {...{ xs: 24, sm: { - span: 24, + span: 12, offset: 0, }, xl: { - span: 8, + span: 24, offset: 0, }, xxl: { - span: 24, + span: 18, offset: 0, }, }} diff --git a/src/page/SQLManagement/SQLPanel/index.tsx b/src/page/SQLManagement/SQLPanel/index.tsx index 79397729..0e68e5d2 100644 --- a/src/page/SQLManagement/SQLPanel/index.tsx +++ b/src/page/SQLManagement/SQLPanel/index.tsx @@ -114,6 +114,7 @@ const SQLPanel: React.FC = () => { fuzzy_search_sql_fingerprint: filterInfo.fuzzy_search_sql_fingerprint, filter_instance_name: filterInfo.filter_instance_name, + fuzzy_search_schema_name: filterInfo.fuzzy_search_schema_name, filter_status: filterInfo.filter_status, filter_source: filterInfo.filter_source, filter_audit_level: filterInfo.filter_audit_level, @@ -323,6 +324,7 @@ const SQLPanel: React.FC = () => { fuzzy_search_sql_fingerprint: filterValues.fuzzy_search_sql_fingerprint, filter_assignee: !!filterValues.filter_assignee ? username : undefined, filter_instance_name: filterValues.filter_instance_name, + fuzzy_search_schema_name: filterValues.fuzzy_search_schema_name, filter_source: filterValues.filter_source as | exportSqlManageV1FilterSourceEnum | undefined, @@ -387,14 +389,14 @@ const SQLPanel: React.FC = () => { } type="primary" > - {t("sqlManagement.table.actions.batchAssignment")} + {t('sqlManagement.table.actions.batchAssignment')} @@ -404,13 +406,13 @@ const SQLPanel: React.FC = () => { } type="primary" > - {t("sqlManagement.table.actions.batchSolve")} + {t('sqlManagement.table.actions.batchSolve')} @@ -420,7 +422,7 @@ const SQLPanel: React.FC = () => { } type="primary" > - {t("sqlManagement.table.actions.batchIgnore")} + {t('sqlManagement.table.actions.batchIgnore')} @@ -431,7 +433,7 @@ const SQLPanel: React.FC = () => { onClick={exportAction} disabled={exportButtonDisabled} > - {t("sqlManagement.table.actions.export")} + {t('sqlManagement.table.actions.export')} @@ -457,7 +459,7 @@ const SQLPanel: React.FC = () => { showSizeChanger: true, total: data?.total ?? 0, current: pagination.pageIndex, - pageSize: pagination.pageSize + pageSize: pagination.pageSize, }} expandable={{ expandedRowRender, @@ -473,7 +475,7 @@ const SQLPanel: React.FC = () => { ) : null, columnWidth: 14, }} - scroll={{ x: "max-content" }} + scroll={{ x: 'max-content' }} /> diff --git a/src/page/SQLManagement/SQLPanel/index.type.ts b/src/page/SQLManagement/SQLPanel/index.type.ts index 7332f86e..dc93a220 100644 --- a/src/page/SQLManagement/SQLPanel/index.type.ts +++ b/src/page/SQLManagement/SQLPanel/index.type.ts @@ -23,6 +23,8 @@ export type SQLPanelFilterFormFields = { filter_rule?: string; fuzzy_search_endpoint?: string; + + fuzzy_search_schema_name?: string; }; export type SQLPanelFilterFormProps = {