Skip to content

Commit

Permalink
feat: add cluster remove, choose dir (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
xigongdaEricyang committed Dec 30, 2022
1 parent 9551dd0 commit 77cd3e7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 39 deletions.
30 changes: 17 additions & 13 deletions src/pages/ServiceManage/LeaderDistribution/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,27 @@
display: flex;
flex-wrap: wrap;
overflow: auto;
>pre{
margin:0 5px;
div {
margin:5px 0;
white-space: break-spaces;
word-break: break-all;
}
}
}
}
.content-overview{
display: flex;
padding: 20px 30px 20px 0;
justify-content: space-between;

.table-overview{
flex: 1;
margin-top: 20px;
}

.ant-empty-normal{
margin: 0;
}
}
.overview-header{
display: block;
Expand Down Expand Up @@ -54,15 +69,4 @@
.ant-empty-normal{
margin: 0;
}
.content-overview{
display: flex;
padding: 20px 30px 20px 0;
.table-overview{
flex: 1;
margin-top: 20px;
}
.ant-empty-normal{
margin: 0;
}
}
}
54 changes: 28 additions & 26 deletions src/pages/ServiceManage/LeaderDistribution/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const mapState = (state: IRootState) => ({

interface IProps
extends ReturnType<typeof mapState>,
ReturnType<typeof mapDispatch> {
ReturnType<typeof mapDispatch> {
isOverview?: boolean;
baseRouter?: string;
cluster?: ICluster;
Expand Down Expand Up @@ -63,7 +63,7 @@ const LeaderDistribution: React.FC<IProps> = (props: IProps) => {
const getStorageInfo = async () => {
const res = await props.asyncGetHostsInfo();
const data = res.map((item: any) => ({
name: item.Host+':'+item.Port,
name: item.Host + ':' + item.Port,
count: item['Leader count'],
distribution: item['Leader distribution'],
})).sort((a, b) => a.name > b.name ? 1 : -1);
Expand Down Expand Up @@ -110,29 +110,31 @@ const LeaderDistribution: React.FC<IProps> = (props: IProps) => {
}
};

const columns = [
{
title: intl.get('common.service'),
dataIndex: 'name',
},
{
title: intl.get('service.leaderNumber'),
dataIndex: 'count',
},
{
title: intl.get('service.leaderDistribute'),
dataIndex: 'distribution',
render: distribution => (
<div className="distribution-table">
{distribution.split(',').map(each => <pre>{each.trim(' ')}</pre>)}
</div>
),
},
];
const columns = useMemo(() => (
[
{
title: intl.get('common.service'),
dataIndex: 'name',
},
{
title: intl.get('service.leaderNumber'),
dataIndex: 'count',
},
{
title: intl.get('service.leaderDistribute'),
dataIndex: 'distribution',
render: distribution => (
<div className="distribution-table">
{distribution.split(',').map(each => <div className="leader-item">{each.trim()}</div>)}
</div>
),
},
]
), []);

const options = useMemo(
() =>
isOverview ? { width: 350, height: 226 } : { width: 500, height: 286 },
isOverview ? { width: 320, height: 226 } : { width: 500, height: 286 },
[isOverview],
);

Expand Down Expand Up @@ -165,10 +167,10 @@ const LeaderDistribution: React.FC<IProps> = (props: IProps) => {
})}
>
{data.length > 0 ? (
<PieChart options={options} renderChart={renderChart} />
) : (
<Empty description={intl.get('common.noData')} />
)}
<PieChart options={options} renderChart={renderChart} />
) : (
<Empty description={intl.get('common.noData')} />
)}
<Table
className={classnames('leader-table', {
'table-overview': isOverview,
Expand Down

0 comments on commit 77cd3e7

Please sign in to comment.