mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-15 21:08:34 +08:00
初始化3.0.0版本
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import React from 'react';
|
||||
import { timeFormat, getSizeAndUnit } from '../../constants/common';
|
||||
import moment from 'moment';
|
||||
import { Tag, Tooltip } from 'knowdesign';
|
||||
|
||||
export const getBrokerListColumns = (arg?: any) => {
|
||||
const columns = [
|
||||
{
|
||||
title: 'Broker ID',
|
||||
dataIndex: 'brokerId',
|
||||
key: 'brokerId',
|
||||
sorter: true,
|
||||
// eslint-disable-next-line react/display-name
|
||||
render: (t: number, r: any) => {
|
||||
return r?.alive ? (
|
||||
<a
|
||||
onClick={() => {
|
||||
window.location.hash = `brokerId=${t || t === 0 ? t : ''}&host=${r.host || ''}`;
|
||||
}}
|
||||
>
|
||||
{t}
|
||||
</a>
|
||||
) : (
|
||||
<span>{t}</span>
|
||||
);
|
||||
},
|
||||
fixed: 'left',
|
||||
width: 120,
|
||||
},
|
||||
// {
|
||||
// title: 'Rack',
|
||||
// dataIndex: 'rack',
|
||||
// key: 'rack',
|
||||
// },
|
||||
{
|
||||
title: 'Broker Host',
|
||||
dataIndex: 'host',
|
||||
key: 'host',
|
||||
width: 180,
|
||||
render: (t: any, r: any) => {
|
||||
return (
|
||||
<span>
|
||||
{t}
|
||||
{r?.alive ? <Tag className="tag-success">Live</Tag> : <Tag className="tag-error">Down</Tag>}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: ' JMX Port',
|
||||
dataIndex: 'jmxPort',
|
||||
key: 'jmxPort',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: 'Partitions',
|
||||
dataIndex: 'Partitions',
|
||||
key: 'Partitions',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: 'Partitions Skew',
|
||||
dataIndex: 'PartitionsSkew',
|
||||
key: 'PartitionsSkew',
|
||||
width: 140,
|
||||
render: (t: number) => {
|
||||
return t || t === 0 ? (t * 100).toFixed(2) + '%' : '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Leaders Partition',
|
||||
dataIndex: 'Leaders',
|
||||
key: 'Leaders',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
title: 'Leaders Skew',
|
||||
dataIndex: 'LeadersSkew',
|
||||
key: 'LeadersSkew',
|
||||
width: 120,
|
||||
render: (t: number) => {
|
||||
return t || t === 0 ? (t * 100).toFixed(2) + '%' : '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Message Size',
|
||||
dataIndex: 'LogSize',
|
||||
key: 'LogSize',
|
||||
sorter: true,
|
||||
width: 150,
|
||||
render: (t: number) => {
|
||||
return getSizeAndUnit(t, 'B').valueWithUnit;
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: 'Status',
|
||||
// dataIndex: 'alive',
|
||||
// key: 'alive',
|
||||
// width: 100,
|
||||
// // eslint-disable-next-line react/display-name
|
||||
// render: (t: boolean) => {
|
||||
// return <span className={t ? 'success' : 'error'}>{t ? 'Live' : 'Down'}</span>;
|
||||
// },
|
||||
// },
|
||||
{
|
||||
title: 'Roles',
|
||||
dataIndex: 'kafkaRoleList',
|
||||
key: 'kafkaRoleList',
|
||||
width: 100,
|
||||
// eslint-disable-next-line react/display-name
|
||||
render: (t: any[]) => {
|
||||
if (t) {
|
||||
const newContant = t
|
||||
?.filter((item: string) => item.slice(0, 3) == '__c' || item.slice(0, 3) == '__t')
|
||||
?.map((subItem: any) => {
|
||||
if (subItem.slice(0, 3) == '__c') {
|
||||
return 'GC';
|
||||
} else if (subItem.slice(0, 3) == '__t') {
|
||||
return 'TC';
|
||||
}
|
||||
return null;
|
||||
});
|
||||
const newTooltip = newContant.map((item: string) => {
|
||||
if (item === 'GC') {
|
||||
return 'GroupCoordinator';
|
||||
} else if (item === 'TC') {
|
||||
return 'TransactionCoordinator';
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return (
|
||||
<Tooltip title={newTooltip.join()}>
|
||||
<span>{newContant.length > 0 ? newContant.join('、') : '-'}</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
return '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Start Time',
|
||||
dataIndex: 'startTimeUnitMs',
|
||||
key: 'startTimeUnitMs',
|
||||
width: 200,
|
||||
render: (t: number) => (t ? moment(t).format(timeFormat) : '-'),
|
||||
},
|
||||
];
|
||||
return columns;
|
||||
};
|
||||
|
||||
export const defaultPagination = {
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
position: 'bottomRight',
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: ['10', '20', '50', '100', '200', '500'],
|
||||
};
|
||||
Reference in New Issue
Block a user