Skip to content

Commit 62f7d3f

Browse files
committed
fix: 图表逻辑 & 展示优化
1 parent 26e60d8 commit 62f7d3f

File tree

20 files changed

+329
-261
lines changed

20 files changed

+329
-261
lines changed

km-console/packages/layout-clusters-fe/src/api/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export enum MetricType {
1414
Broker = 103,
1515
Partition = 104,
1616
Replication = 105,
17+
Zookeeper = 110,
1718
Controls = 901,
1819
}
1920

@@ -61,6 +62,8 @@ const api = {
6162
phyClusterState: getApi(`/physical-clusters/state`),
6263

6364
getOperatingStateList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/groups-overview`),
65+
getGroupTopicList: (clusterPhyId: number, groupName: string) => getApi(`/clusters/${clusterPhyId}/groups/${groupName}/topics-overview`),
66+
6467
// 物理集群接口
6568
phyCluster: getApi(`/physical-clusters`),
6669
getPhyClusterBasic: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/basic`),
@@ -127,6 +130,7 @@ const api = {
127130
getApi(`/clusters/${clusterPhyId}/topics/${topicName}/brokers-partitions-summary`),
128131
getTopicPartitionsDetail: (clusterPhyId: string, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/partitions`),
129132
getTopicMessagesList: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/records`), // Messages列表
133+
getTopicGroupList: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/groups-overview`), // Consumers列表
130134
getTopicMessagesMetadata: (topicName: string, clusterPhyId: number) => getApi(`/clusters//${clusterPhyId}/topics/${topicName}/metadata`), // Messages列表
131135
getTopicACLsList: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/acl-Bindings`), // ACLs列表
132136
getTopicConfigs: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/config-topics/${topicName}/configs`), // Configuration列表

km-console/packages/layout-clusters-fe/src/components/SingleChartHeader/IndicatorDrawer.tsx renamed to km-console/packages/layout-clusters-fe/src/components/ChartOperateBar/MetricSelect.tsx

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import React, { useState, useEffect } from 'react';
2-
import { Drawer, Button, Space, Divider, AppContainer, ProTable } from 'knowdesign';
1+
import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
2+
import { Drawer, Button, Space, Divider, AppContainer, ProTable, Utils } from 'knowdesign';
33
import { IconFont } from '@knowdesign/icons';
4-
import { IindicatorSelectModule } from './index';
4+
import { MetricSelect } from './index';
55
import './style/indicator-drawer.less';
66
import { useLocation } from 'react-router-dom';
77

88
interface PropsType extends React.HTMLAttributes<HTMLDivElement> {
9-
onClose: () => void;
10-
visible: boolean;
11-
isGroup?: boolean; // 是否分组
12-
indicatorSelectModule: IindicatorSelectModule;
9+
metricSelect: MetricSelect;
1310
}
1411

1512
interface MetricInfo {
@@ -27,25 +24,25 @@ type CategoryData = {
2724
metrics: MetricInfo[];
2825
};
2926

30-
const ExpandedRow = ({ metrics, category, selectedMetrics, selectedMetricChange }: any) => {
31-
const innerColumns = [
32-
{
33-
title: '指标名称',
34-
dataIndex: 'name',
35-
key: 'name',
36-
},
37-
{
38-
title: '单位',
39-
dataIndex: 'unit',
40-
key: 'unit',
41-
},
42-
{
43-
title: '描述',
44-
dataIndex: 'desc',
45-
key: 'desc',
46-
},
47-
];
27+
const expandedRowColumns = [
28+
{
29+
title: '指标名称',
30+
dataIndex: 'name',
31+
key: 'name',
32+
},
33+
{
34+
title: '单位',
35+
dataIndex: 'unit',
36+
key: 'unit',
37+
},
38+
{
39+
title: '描述',
40+
dataIndex: 'desc',
41+
key: 'desc',
42+
},
43+
];
4844

45+
const ExpandedRow = ({ metrics, category, selectedMetrics, selectedMetricChange }: any) => {
4946
return (
5047
<div
5148
style={{
@@ -62,7 +59,7 @@ const ExpandedRow = ({ metrics, category, selectedMetrics, selectedMetricChange
6259
showHeader: false,
6360
noPagination: true,
6461
rowKey: 'name',
65-
columns: innerColumns,
62+
columns: expandedRowColumns,
6663
dataSource: metrics,
6764
attrs: {
6865
rowSelection: {
@@ -79,13 +76,14 @@ const ExpandedRow = ({ metrics, category, selectedMetrics, selectedMetricChange
7976
);
8077
};
8178

82-
const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType) => {
79+
const MetricSelect = forwardRef(({ metricSelect }: PropsType, ref) => {
8380
const [global] = AppContainer.useGlobalValue();
8481
const { pathname } = useLocation();
8582
const [confirmLoading, setConfirmLoading] = useState<boolean>(false);
8683
const [categoryData, setCategoryData] = useState<CategoryData[]>([]);
8784
const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
8885
const [childrenSelectedRowKeys, setChildrenSelectedRowKeys] = useState<SelectedMetrics>({});
86+
const [visible, setVisible] = useState<boolean>(false);
8987

9088
const columns = [
9189
{
@@ -96,13 +94,13 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
9694
];
9795

9896
const formateTableData = () => {
99-
const tableData = indicatorSelectModule.tableData;
97+
const tableData = metricSelect.tableData;
10098
const categoryData: {
10199
[category: string]: MetricInfo[];
102100
} = {};
103101

104102
tableData.forEach(({ name, desc }) => {
105-
const metricDefine = global.getMetricDefine(indicatorSelectModule?.metricType, name);
103+
const metricDefine = global.getMetricDefine(metricSelect?.metricType, name);
106104
const returnData = {
107105
name,
108106
desc,
@@ -125,12 +123,12 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
125123
};
126124

127125
const formateSelectedKeys = () => {
128-
const newKeys = indicatorSelectModule.selectedRows;
126+
const newKeys = metricSelect.selectedRows;
129127
const result: SelectedMetrics = {};
130128
const selectedCategories: string[] = [];
131129

132130
newKeys.forEach((name: string) => {
133-
const metricDefine = global.getMetricDefine(indicatorSelectModule?.metricType, name);
131+
const metricDefine = global.getMetricDefine(metricSelect?.metricType, name);
134132
if (metricDefine) {
135133
if (!result[metricDefine.category]) {
136134
result[metricDefine.category] = [name];
@@ -217,10 +215,10 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
217215
const allRowKeys: string[] = [];
218216
Object.entries(childrenSelectedRowKeys).forEach(([, arr]) => allRowKeys.push(...arr));
219217

220-
indicatorSelectModule.submitCallback(allRowKeys).then(
218+
metricSelect.submitCallback(allRowKeys).then(
221219
() => {
222220
setConfirmLoading(false);
223-
onClose();
221+
setVisible(false);
224222
},
225223
() => {
226224
setConfirmLoading(false);
@@ -231,7 +229,7 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
231229
const rowSelection = {
232230
selectedRowKeys: selectedCategories,
233231
onChange: rowChange,
234-
// getCheckboxProps: (record: any) => indicatorSelectModule.checkboxProps && indicatorSelectModule.checkboxProps(record),
232+
// getCheckboxProps: (record: any) => metricSelect.checkboxProps && metricSelect.checkboxProps(record),
235233
getCheckboxProps: (record: CategoryData) => {
236234
const isAllSelected = record.metrics.length === childrenSelectedRowKeys[record.category]?.length;
237235
const isNotCheck = !childrenSelectedRowKeys[record.category] || childrenSelectedRowKeys[record.category]?.length === 0;
@@ -241,25 +239,33 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
241239
},
242240
};
243241

244-
useEffect(formateTableData, [indicatorSelectModule.tableData]);
242+
useEffect(formateTableData, [metricSelect.tableData]);
245243

246244
useEffect(() => {
247245
visible && formateSelectedKeys();
248-
}, [visible, indicatorSelectModule.selectedRows]);
246+
}, [visible, metricSelect.selectedRows]);
247+
248+
useImperativeHandle(
249+
ref,
250+
() => ({
251+
open: () => setVisible(true),
252+
}),
253+
[]
254+
);
249255

250256
return (
251257
<>
252258
<Drawer
253259
className="indicator-drawer"
254-
title={indicatorSelectModule.drawerTitle || '指标筛选'}
260+
title={metricSelect.drawerTitle || '指标筛选'}
255261
width="868px"
256262
forceRender={true}
257-
onClose={onClose}
263+
onClose={() => setVisible(false)}
258264
visible={visible}
259265
maskClosable={false}
260266
extra={
261267
<Space>
262-
<Button size="small" onClick={onClose}>
268+
<Button size="small" onClick={() => setVisible(false)}>
263269
取消
264270
</Button>
265271
<Button
@@ -281,6 +287,7 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
281287
rowKey: 'category',
282288
columns: columns,
283289
dataSource: categoryData,
290+
noPagination: true,
284291
attrs: {
285292
rowSelection: rowSelection,
286293
expandable: {
@@ -319,6 +326,6 @@ const IndicatorDrawer = ({ onClose, visible, indicatorSelectModule }: PropsType)
319326
</Drawer>
320327
</>
321328
);
322-
};
329+
});
323330

324-
export default IndicatorDrawer;
331+
export default MetricSelect;

km-console/packages/layout-clusters-fe/src/components/SingleChartHeader/NodeScope.tsx renamed to km-console/packages/layout-clusters-fe/src/components/ChartOperateBar/NodeScope.tsx

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const OptionsDefault = [
2626

2727
const NodeScope = ({ nodeScopeModule, change }: propsType) => {
2828
const {
29+
hasCustomScope,
2930
customScopeList: customList,
3031
scopeName = '',
3132
scopeLabel = '自定义范围',
@@ -128,51 +129,53 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
128129
</Space>
129130
</Radio.Group>
130131
</div>
131-
<div className="flx_r">
132-
<h6 className="time_title">{scopeLabel}</h6>
133-
<div className="custom-scope">
134-
<div className="check-row">
135-
<Checkbox className="check-all" indeterminate={indeterminate} onChange={onCheckAllChange} checked={checkAll}>
136-
全选
137-
</Checkbox>
138-
<Input
139-
className="search-input"
140-
suffix={<IconFont type="icon-fangdajing" style={{ fontSize: '16px' }} />}
141-
size="small"
142-
placeholder={searchPlaceholder}
143-
onChange={(e) => setScopeSearchValue(e.target.value)}
144-
/>
145-
</div>
146-
<div className="fixed-height">
147-
<Checkbox.Group style={{ width: '100%' }} onChange={checkChange} value={checkedListTemp}>
148-
<Row gutter={[10, 12]}>
149-
{customList
150-
.filter((item) => item.label.includes(scopeSearchValue))
151-
.map((item) => (
152-
<Col span={12} key={item.value}>
153-
<Checkbox value={item.value}>{item.label}</Checkbox>
154-
</Col>
155-
))}
156-
</Row>
157-
</Checkbox.Group>
158-
</div>
159-
160-
<div className="btn-con">
161-
<Button
162-
type="primary"
163-
size="small"
164-
className="btn-sure"
165-
onClick={customSure}
166-
disabled={checkedListTemp?.length > 0 ? false : true}
167-
>
168-
确定
169-
</Button>
170-
<Button size="small" onClick={customCancel}>
171-
取消
172-
</Button>
132+
{hasCustomScope && (
133+
<div className="flx_r">
134+
<h6 className="time_title">{scopeLabel}</h6>
135+
<div className="custom-scope">
136+
<div className="check-row">
137+
<Checkbox className="check-all" indeterminate={indeterminate} onChange={onCheckAllChange} checked={checkAll}>
138+
全选
139+
</Checkbox>
140+
<Input
141+
className="search-input"
142+
suffix={<IconFont type="icon-fangdajing" style={{ fontSize: '16px' }} />}
143+
size="small"
144+
placeholder={searchPlaceholder}
145+
onChange={(e) => setScopeSearchValue(e.target.value)}
146+
/>
147+
</div>
148+
<div className="fixed-height">
149+
<Checkbox.Group style={{ width: '100%' }} onChange={checkChange} value={checkedListTemp}>
150+
<Row gutter={[10, 12]}>
151+
{customList
152+
.filter((item) => item.label.includes(scopeSearchValue))
153+
.map((item) => (
154+
<Col span={12} key={item.value}>
155+
<Checkbox value={item.value}>{item.label}</Checkbox>
156+
</Col>
157+
))}
158+
</Row>
159+
</Checkbox.Group>
160+
</div>
161+
162+
<div className="btn-con">
163+
<Button
164+
type="primary"
165+
size="small"
166+
className="btn-sure"
167+
onClick={customSure}
168+
disabled={checkedListTemp?.length > 0 ? false : true}
169+
>
170+
确定
171+
</Button>
172+
<Button size="small" onClick={customCancel}>
173+
取消
174+
</Button>
175+
</div>
173176
</div>
174177
</div>
175-
</div>
178+
)}
176179
</div>
177180
</div>
178181
);
@@ -185,7 +188,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
185188
visible={popVisible}
186189
content={clickContent}
187190
placement="bottomRight"
188-
overlayClassName="d-node-scope-popover"
191+
overlayClassName={`d-node-scope-popover ${hasCustomScope ? 'large-size' : ''}`}
189192
onVisibleChange={visibleChange}
190193
>
191194
<span className="input-span">

km-console/packages/layout-clusters-fe/src/components/SingleChartHeader/image/empty.png renamed to km-console/packages/layout-clusters-fe/src/components/ChartOperateBar/image/empty.png

File renamed without changes.

0 commit comments

Comments
 (0)