Skip to content

Commit ac4ea13

Browse files
authored
修复一些前端问题 (#1199)
请不要在没有先创建Issue的情况下创建Pull Request。 ## 变更的目的是什么 XXXXX ## 简短的更新日志 - [Bugfix]修复重置offset接口调用过多问题 - [Bugfix]修复消费组Offset重置后,提示重置成功,但是前端不刷新数据,Offset无变化的问题 - [Optimize]消费组详情控制数据实时刷新 ## 验证这一变化 XXXX 请遵循此清单,以帮助我们快速轻松地整合您的贡献: * [ ] 一个 PR(Pull Request的简写)只解决一个问题,禁止一个 PR 解决多个问题; * [ ] 确保 PR 有对应的 Issue(通常在您开始处理之前创建),除非是书写错误之类的琐碎更改不需要 Issue ; * [ ] 格式化 PR 及 Commit-Log 的标题及内容,例如 #861 。PS:Commit-Log 需要在 Git Commit 代码时进行填写,在 GitHub 上修改不了; * [ ] 编写足够详细的 PR 描述,以了解 PR 的作用、方式和原因; * [ ] 编写必要的单元测试来验证您的逻辑更正。如果提交了新功能或重大更改,请记住在 test 模块中添加 integration-test; * [ ] 确保编译通过,集成测试通过;
1 parent b6ea4ae commit ac4ea13

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/Detail.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ const GroupDetail = (props: any) => {
236236
chartData={chartData}
237237
groupName={hashDataParse(location.hash).groupName}
238238
loading={loadingObj}
239+
refreshKey={refreshKey}
239240
/>
240241
),
241242
// expandedRowRender,
@@ -268,7 +269,12 @@ const GroupDetail = (props: any) => {
268269
},
269270
}}
270271
/>
271-
<ResetOffsetDrawer visible={resetOffsetVisible} setVisible={setResetOffsetVisible} record={resetOffsetArg}></ResetOffsetDrawer>
272+
<ResetOffsetDrawer
273+
visible={resetOffsetVisible}
274+
setVisible={setResetOffsetVisible}
275+
record={resetOffsetArg}
276+
resetOffsetFn={forceRefresh}
277+
></ResetOffsetDrawer>
272278
</Drawer>
273279
);
274280
};

km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ExpandedRow.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { IconFont } from '@knowdesign/icons';
88
import API from '@src/api/index';
99
import { hashDataParse } from '@src/constants/common';
1010
const { Option } = Select;
11-
import PubSub from 'pubsub-js'
1211

1312
export interface MetricLine {
1413
createTime?: number;
@@ -42,7 +41,7 @@ const metricWithType = [
4241
{ metricName: 'Lag', metricType: 102 },
4342
];
4443

45-
export const ExpandedRow: any = ({ record, groupName }: any) => {
44+
export const ExpandedRow: any = ({ record, groupName, refreshKey }: any) => {
4645
const params: any = useParams<{
4746
clusterId: string;
4847
}>();
@@ -194,7 +193,7 @@ export const ExpandedRow: any = ({ record, groupName }: any) => {
194193
endTime: timeRange[1],
195194
topNu: 0,
196195
};
197-
Utils.post(API.getTopicGroupMetricHistory(clusterId), params).then((data: Array<MetricData>) => {
196+
Utils.post(API.getTopicGroupMetricHistory(clusterId), params, { timeout: 300000 }).then((data: Array<MetricData>) => {
198197
// ! 替换接口返回
199198
setAllGroupMetricsData(data);
200199
});
@@ -211,15 +210,6 @@ export const ExpandedRow: any = ({ record, groupName }: any) => {
211210
getTopicGroupMetric({ pagination, sorter });
212211
};
213212

214-
// useEffect(() => {
215-
// getTopicGroupMetric();
216-
// }, [sortObj]);
217-
218-
// 订阅重置offset成功的消息
219-
PubSub.subscribe('ConsumerGroup-ResetOffset', function(data){
220-
getTopicGroupMetric({});
221-
})
222-
223213
useEffect(() => {
224214
const hashData = hashDataParse(location.hash);
225215
// if (!hashData.groupName) return;
@@ -248,7 +238,7 @@ export const ExpandedRow: any = ({ record, groupName }: any) => {
248238
// 获取Consumer列表 表格模式
249239
getTopicGroupMetric({});
250240
});
251-
}, [hashDataParse(location.hash).groupName]);
241+
}, [hashDataParse(location.hash).groupName, refreshKey]);
252242

253243
useEffect(() => {
254244
if (partitionList.length === 0) return;

km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ResetOffsetDrawer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useParams } from 'react-router-dom';
44
import EditTable from '../TestingProduce/component/EditTable';
55
import Api from '@src/api/index';
66
import moment from 'moment';
7-
import PubSub from 'pubsub-js';
87

98
const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number | String) => void }) => {
109
const { value, onChange } = props;
@@ -45,7 +44,7 @@ const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number
4544
};
4645

4746
export default (props: any) => {
48-
const { record, visible, setVisible } = props;
47+
const { record, visible, setVisible, resetOffsetFn } = props;
4948
const routeParams = useParams<{
5049
clusterId: string;
5150
}>();
@@ -108,7 +107,7 @@ export default (props: any) => {
108107
});
109108
setVisible(false);
110109
// 发布重置offset成功的消息
111-
PubSub.publish('ConsumerGroup-ResetOffset', '1');
110+
resetOffsetFn();
112111
} else {
113112
notification.error({
114113
message: '重置offset失败',

0 commit comments

Comments
 (0)