import * as React from 'react'; import './index.less'; import { SearchAndFilterContainer } from 'container/search-filter'; import { expert } from 'store/expert'; import { Table, Button, Tooltip } from 'antd'; import { observer } from 'mobx-react'; import { IPartition } from 'types/base-type'; import { pagination } from 'constants/table'; import { BatchExpansion } from './batch-expansion'; import { region } from 'store/region'; import { transBToMB } from 'lib/utils'; @observer export class PartitionTopic extends SearchAndFilterContainer { public capacityData: IPartition[]; public selectedRows: IPartition[]; public state = { searchKey: '', loading: false, hasSelected: false, partitionVisible: true, }; public onSelectChange = { onChange: (selectedRowKeys: string[], selectedRows: []) => { this.selectedRows = selectedRows; this.setState({ hasSelected: !!selectedRowKeys.length, }); }, }; public InsufficientPartition(partitionData: IPartition[]) { const columns = [ { title: 'Topic名称', dataIndex: 'topicName', width: '30%', sorter: (a: IPartition, b: IPartition) => a.topicName.charCodeAt(0) - b.topicName.charCodeAt(0), render: (text: string, item: IPartition) => ( {text} ), }, { title: '所在集群', dataIndex: 'clusterName', width: '15%', }, { title: '分区个数', dataIndex: 'presentPartitionNum', width: '10%', }, { title: '分区平均流量(MB/s)', dataIndex: 'bytesInPerPartition', width: '10%', sorter: (a: IPartition, b: IPartition) => b.bytesInPerPartition - a.bytesInPerPartition, render: (t: number) => transBToMB(t), }, { title: '近三天峰值流量(MB/s)', dataIndex: 'maxAvgBytesInList', width: '25%', render: (val: number, item: IPartition, index: number) => ( item.maxAvgBytesInList.map((record: number) => ( {transBToMB(record)} )) ), }, { title: '操作', dataIndex: 'action', width: '10%', render: (val: string, item: IPartition, index: number) => ( <> this.dataMigration([item])}>扩分区 ), }, ]; const { loading, hasSelected } = this.state; return ( <>
); } public dataMigration(item: IPartition[]) { this.capacityData = item; this.setState({ partitionVisible: false, }); } public getData(origin: IPartition[]) { let data: IPartition[] = []; let { searchKey } = this.state; searchKey = (searchKey + '').trim().toLowerCase(); if (expert.active !== -1 || searchKey !== '') { data = origin.filter(d => ((d.topicName !== undefined && d.topicName !== null) && d.topicName.toLowerCase().includes(searchKey as string)) && (expert.active === -1 || +d.clusterId === expert.active), ); } else { data = origin; } return data; } public componentDidMount() { expert.getInsufficientPartition(); if (!expert.metaData.length) { expert.getMetaData(false); } } public onChangeVisible(value?: boolean) { this.setState({ partitionVisible: value, }); } public render() { return ( this.state.partitionVisible ? <>{this.InsufficientPartition(this.getData(expert.partitionedData))} : this.onChangeVisible(value)} capacityData={this.capacityData} /> ); } }