From ea0c744677d18ae0e4872e0781c95018b64681ba Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 10 Sep 2023 13:51:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?'[Feature]=E5=A2=9E=E5=8A=A0Truncate?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD(#1043)'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout-clusters-fe/src/api/index.ts | 1 + .../src/pages/TopicList/index.tsx | 51 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/api/index.ts b/km-console/packages/layout-clusters-fe/src/api/index.ts index 7dadd9ec..95b84749 100755 --- a/km-console/packages/layout-clusters-fe/src/api/index.ts +++ b/km-console/packages/layout-clusters-fe/src/api/index.ts @@ -108,6 +108,7 @@ const api = { getTopicState: (clusterPhyId: number, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/state`), getTopicMetadata: (clusterPhyId: number, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/metadata-combine-exist`), + deleteTopicData: () => getApi(`/topics/truncate-topic`), // 最新的指标值 getMetricPointsLatest: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/latest-metrics`), diff --git a/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx b/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx index 4c3f8857..9521e5c4 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx @@ -1,7 +1,22 @@ /* eslint-disable react/display-name */ import React, { useState, useEffect } from 'react'; import { useHistory, useParams } from 'react-router-dom'; -import { AppContainer, Input, ProTable, Select, Switch, Tooltip, Utils, Dropdown, Menu, Button, Divider, Tag } from 'knowdesign'; +import { + AppContainer, + Input, + ProTable, + Select, + Switch, + Tooltip, + Utils, + Dropdown, + Menu, + Button, + Divider, + Tag, + Popconfirm, + notification, +} from 'knowdesign'; import { IconFont } from '@knowdesign/icons'; import Create from './Create'; import './index.less'; @@ -85,6 +100,25 @@ const AutoPage = (props: any) => { setTopicListLoading(false); }); }; + const deleteTopicData = (record: any) => { + console.log(record, 'record'); + const params = { + clusterId: Number(routeParams.clusterId), + topicName: record.topicName, + }; + Utils.post(Api.deleteTopicData(), params).then((data: any) => { + if (data === null) { + notification.success({ + message: '清除数据成功', + }); + getTopicsList(); + } else { + notification.error({ + message: '清除数据失败', + }); + } + }); + }; useEffect(() => { getTopicsList(); }, [sortObj, showInternalTopics, searchKeywords, pageIndex, pageSize]); @@ -247,7 +281,7 @@ const AutoPage = (props: any) => { dataIndex: 'desc', key: 'desc', fixed: 'right', - width: 140, + width: 200, render: (value: any, record: any) => { return (
@@ -257,6 +291,19 @@ const AutoPage = (props: any) => { <> )} {global.hasPermission(ClustersPermissionMap.TOPIC_DEL) ? : <>} + {global.hasPermission(ClustersPermissionMap.TOPIC_DEL) ? ( // TODO:替换为清除数据的权限 + deleteTopicData(record)} + okText="是" + cancelText="否" + > + + + ) : ( + <> + )}
); }, From 128b180c83bf719340d92bbe57c45114668c8458 Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 10 Sep 2023 22:45:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Bugfix]=E5=8E=BB=E9=99=A4=E5=88=A0?= =?UTF-8?q?=E9=99=A4Truncate=E6=97=B6=E7=9A=84=E5=A4=9A=E4=BD=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/layout-clusters-fe/src/pages/TopicList/index.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx b/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx index 9521e5c4..0a00fa04 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx @@ -112,10 +112,6 @@ const AutoPage = (props: any) => { message: '清除数据成功', }); getTopicsList(); - } else { - notification.error({ - message: '清除数据失败', - }); } }); };