From 00f3ac245507992ff205b74cacecd77d46b9468b Mon Sep 17 00:00:00 2001 From: erge Date: Thu, 30 Nov 2023 21:37:54 +0800 Subject: [PATCH] =?UTF-8?q?[Optimize]=E6=B6=88=E8=B4=B9=E7=BB=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A7=E5=88=B6=E6=95=B0=E6=8D=AE=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/ConsumerGroup/Detail.tsx | 8 +++++++- .../src/pages/ConsumerGroup/ExpandedRow.tsx | 16 +++------------- .../pages/ConsumerGroup/ResetOffsetDrawer.tsx | 5 ++--- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/Detail.tsx b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/Detail.tsx index 44d613740..6438a139d 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/Detail.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/Detail.tsx @@ -236,6 +236,7 @@ const GroupDetail = (props: any) => { chartData={chartData} groupName={hashDataParse(location.hash).groupName} loading={loadingObj} + refreshKey={refreshKey} /> ), // expandedRowRender, @@ -268,7 +269,12 @@ const GroupDetail = (props: any) => { }, }} /> - + ); }; diff --git a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ExpandedRow.tsx b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ExpandedRow.tsx index 85ab81cc4..3c2c24d00 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ExpandedRow.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ExpandedRow.tsx @@ -8,7 +8,6 @@ import { IconFont } from '@knowdesign/icons'; import API from '@src/api/index'; import { hashDataParse } from '@src/constants/common'; const { Option } = Select; -import PubSub from 'pubsub-js' export interface MetricLine { createTime?: number; @@ -42,7 +41,7 @@ const metricWithType = [ { metricName: 'Lag', metricType: 102 }, ]; -export const ExpandedRow: any = ({ record, groupName }: any) => { +export const ExpandedRow: any = ({ record, groupName, refreshKey }: any) => { const params: any = useParams<{ clusterId: string; }>(); @@ -194,7 +193,7 @@ export const ExpandedRow: any = ({ record, groupName }: any) => { endTime: timeRange[1], topNu: 0, }; - Utils.post(API.getTopicGroupMetricHistory(clusterId), params).then((data: Array) => { + Utils.post(API.getTopicGroupMetricHistory(clusterId), params, { timeout: 300000 }).then((data: Array) => { // ! 替换接口返回 setAllGroupMetricsData(data); }); @@ -211,15 +210,6 @@ export const ExpandedRow: any = ({ record, groupName }: any) => { getTopicGroupMetric({ pagination, sorter }); }; - // useEffect(() => { - // getTopicGroupMetric(); - // }, [sortObj]); - - // 订阅重置offset成功的消息 - PubSub.subscribe('ConsumerGroup-ResetOffset', function(data){ - getTopicGroupMetric({}); - }) - useEffect(() => { const hashData = hashDataParse(location.hash); // if (!hashData.groupName) return; @@ -248,7 +238,7 @@ export const ExpandedRow: any = ({ record, groupName }: any) => { // 获取Consumer列表 表格模式 getTopicGroupMetric({}); }); - }, [hashDataParse(location.hash).groupName]); + }, [hashDataParse(location.hash).groupName, refreshKey]); useEffect(() => { if (partitionList.length === 0) return; diff --git a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ResetOffsetDrawer.tsx b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ResetOffsetDrawer.tsx index da88da008..1e53f350c 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ResetOffsetDrawer.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ResetOffsetDrawer.tsx @@ -4,7 +4,6 @@ import { useParams } from 'react-router-dom'; import EditTable from '../TestingProduce/component/EditTable'; import Api from '@src/api/index'; import moment from 'moment'; -import PubSub from 'pubsub-js'; const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number | String) => void }) => { const { value, onChange } = props; @@ -45,7 +44,7 @@ const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number }; export default (props: any) => { - const { record, visible, setVisible } = props; + const { record, visible, setVisible, resetOffsetFn } = props; const routeParams = useParams<{ clusterId: string; }>(); @@ -108,7 +107,7 @@ export default (props: any) => { }); setVisible(false); // 发布重置offset成功的消息 - PubSub.publish('ConsumerGroup-ResetOffset', '1'); + resetOffsetFn(); } else { notification.error({ message: '重置offset失败',