未验证 提交 e4dc4bae 编写于 作者: Z ZQKC 提交者: GitHub

Merge pull request #2 from didi/master

pull
...@@ -10,7 +10,7 @@ import { IClusterData } from 'types/base-type'; ...@@ -10,7 +10,7 @@ import { IClusterData } from 'types/base-type';
const TabPane = Tabs.TabPane; const TabPane = Tabs.TabPane;
const detailUrl ='/admin/cluster_detail?clusterId='; const detailUrl = '/admin/cluster_detail?clusterId=';
const collectionColumns: Array<ColumnProps<IClusterData>> = [ const collectionColumns: Array<ColumnProps<IClusterData>> = [
{ {
...@@ -24,7 +24,8 @@ const collectionColumns: Array<ColumnProps<IClusterData>> = [ ...@@ -24,7 +24,8 @@ const collectionColumns: Array<ColumnProps<IClusterData>> = [
key: 'clusterName', key: 'clusterName',
sorter: (a: IClusterData, b: IClusterData) => a.clusterName.charCodeAt(0) - b.clusterName.charCodeAt(0), sorter: (a: IClusterData, b: IClusterData) => a.clusterName.charCodeAt(0) - b.clusterName.charCodeAt(0),
render: (text, record) => { render: (text, record) => {
return <a href={`${detailUrl}${record.clusterId}`}>{record.clusterName}</a>; const url = `${detailUrl}${record.clusterId}&clusterName=${record.clusterName}`;
return <a href={encodeURI(url)}>{record.clusterName}</a>;
}, },
}, },
{ {
......
...@@ -39,10 +39,10 @@ export class UserManage extends SearchAndFilter { ...@@ -39,10 +39,10 @@ export class UserManage extends SearchAndFilter {
public renderColumns = () => { public renderColumns = () => {
const role = Object.assign({ const role = Object.assign({
title: '角色', title: '角色',
key: 'role', key: 'roleName',
dataIndex: 'role', dataIndex: 'roleName',
filters: users.filterRole, filters: users.filterRole,
onFilter: (value: string, record: any) => record.role.indexOf(value) === 0, onFilter: (value: string, record: any) => record.roleName.indexOf(value) === 0,
}, this.renderColumnsFilter('filterVisible')); }, this.renderColumnsFilter('filterVisible'));
return [ return [
......
import * as React from 'react'; import * as React from 'react';
import './index.less'; import './index.less';
import { Table, Modal, notification, PaginationConfig, Button } from 'component/antd'; import { Table, Modal, notification, PaginationConfig, Button, Spin } from 'component/antd';
import { broker, IBroker, IBrokerNetworkInfo, IBrokerPartition } from 'store/broker'; import { broker, IBroker, IBrokerNetworkInfo, IBrokerPartition } from 'store/broker';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { StatusGraghCom } from 'component/flow-table'; import { StatusGraghCom } from 'component/flow-table';
...@@ -49,10 +49,19 @@ export class BrokerList extends SearchAndFilter { ...@@ -49,10 +49,19 @@ export class BrokerList extends SearchAndFilter {
const status = Object.assign({ const status = Object.assign({
title: '已同步', title: '已同步',
dataIndex: 'status', dataIndex: 'underReplicatedPartitionCount',
key: 'status', key: 'underReplicatedPartitionCount',
filters: [{ text: '', value: '' }, { text: '', value: '' }], filters: [{ text: '', value: '1' }, { text: '', value: '0' }],
onFilter: (value: string, record: IBrokerPartition) => record.status === value, onFilter: (value: string, record: IBrokerPartition) => {
// underReplicatedPartitionCount > 0 表示未同步完成
const syncStatus = record.underReplicatedPartitionCount ? '0' : '1';
return syncStatus === value;
},
render: (text: number) => (
<>
<span style={{ marginRight: 8 }}>{text ? '' : ''}</span>
</>
),
}, this.renderColumnsFilter('filterVisible')); }, this.renderColumnsFilter('filterVisible'));
return [{ return [{
...@@ -80,7 +89,8 @@ export class BrokerList extends SearchAndFilter { ...@@ -80,7 +89,8 @@ export class BrokerList extends SearchAndFilter {
title: '未同步副本数量', title: '未同步副本数量',
dataIndex: 'notUnderReplicatedPartitionCount', dataIndex: 'notUnderReplicatedPartitionCount',
key: 'notUnderReplicatedPartitionCount', key: 'notUnderReplicatedPartitionCount',
sorter: (a: IBrokerPartition, b: IBrokerPartition) => a.notUnderReplicatedPartitionCount - b.notUnderReplicatedPartitionCount, sorter: (a: IBrokerPartition, b: IBrokerPartition) =>
a.notUnderReplicatedPartitionCount - b.notUnderReplicatedPartitionCount,
}, },
status, status,
region, region,
...@@ -205,7 +215,7 @@ export class BrokerList extends SearchAndFilter { ...@@ -205,7 +215,7 @@ export class BrokerList extends SearchAndFilter {
const dataPartitions = this.state.searchId !== '' ? const dataPartitions = this.state.searchId !== '' ?
broker.partitions.filter((d) => d.brokerId === +this.state.searchId) : broker.partitions; broker.partitions.filter((d) => d.brokerId === +this.state.searchId) : broker.partitions;
return ( return (
<> <Spin spinning={broker.loading}>
<div className="k-row"> <div className="k-row">
<ul className="k-tab"> <ul className="k-tab">
<li>Broker概览</li> <li>Broker概览</li>
...@@ -239,7 +249,7 @@ export class BrokerList extends SearchAndFilter { ...@@ -239,7 +249,7 @@ export class BrokerList extends SearchAndFilter {
pagination={pagination} pagination={pagination}
/> />
</div> </div>
</> </Spin>
); );
} }
} }
...@@ -45,14 +45,19 @@ class LeaderRebalance extends React.Component<any> { ...@@ -45,14 +45,19 @@ class LeaderRebalance extends React.Component<any> {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
const url = Url(); const url = Url();
this.clusterName = decodeURI(atob(url.search.clusterName)); if (url.search.clusterName) {
this.clusterName = decodeURI(url.search.clusterName);
}
this.clusterId = Number(url.search.clusterId); this.clusterId = Number(url.search.clusterId);
} }
public handleSubmit = (e: React.MouseEvent<any, MouseEvent>) => { public handleSubmit = (e: React.MouseEvent<any, MouseEvent>) => {
e.preventDefault(); e.preventDefault();
this.setState({ loading: true });
this.props.form.validateFieldsAndScroll((err: any, values: any) => { this.props.form.validateFieldsAndScroll((err: any, values: any) => {
if (err) {
return;
}
this.setState({ loading: true });
this.brokerId = Number(values.brokerId); this.brokerId = Number(values.brokerId);
addRebalance({ brokerId: this.brokerId, clusterId: this.clusterId, dimension: 0 }).then(() => { addRebalance({ brokerId: this.brokerId, clusterId: this.clusterId, dimension: 0 }).then(() => {
cluster.getRebalance(this.clusterId).then(() => { cluster.getRebalance(this.clusterId).then(() => {
......
...@@ -35,6 +35,7 @@ export interface IBrokerPartition extends IBroker { ...@@ -35,6 +35,7 @@ export interface IBrokerPartition extends IBroker {
leaderCount: number; leaderCount: number;
partitionCount: number; partitionCount: number;
notUnderReplicatedPartitionCount: number; notUnderReplicatedPartitionCount: number;
underReplicatedPartitionCount?: number;
regionName: string; regionName: string;
bytesInPerSec: number; bytesInPerSec: number;
} }
...@@ -74,6 +75,9 @@ interface IBrokerOption { ...@@ -74,6 +75,9 @@ interface IBrokerOption {
} }
class Broker { class Broker {
@observable
public loading: boolean = false;
@observable @observable
public brokerBaseInfo: IBrokerBaseInfo = {} as IBrokerBaseInfo; public brokerBaseInfo: IBrokerBaseInfo = {} as IBrokerBaseInfo;
...@@ -119,6 +123,11 @@ class Broker { ...@@ -119,6 +123,11 @@ class Broker {
@observable @observable
public BrokerOptions: IValueLabel[] = [{ value: null, label: '请选择Broker' }]; public BrokerOptions: IValueLabel[] = [{ value: null, label: '请选择Broker' }];
@action.bound
public setLoading(value: boolean) {
this.loading = value;
}
@action.bound @action.bound
public setBrokerBaseInfo(data: IBrokerBaseInfo) { public setBrokerBaseInfo(data: IBrokerBaseInfo) {
data.startTime = moment(data.startTime).format('YYYY-MM-DD HH:mm:ss'), data.startTime = moment(data.startTime).format('YYYY-MM-DD HH:mm:ss'),
...@@ -216,7 +225,8 @@ class Broker { ...@@ -216,7 +225,8 @@ class Broker {
} }
public getBrokerList(clusterId: number) { public getBrokerList(clusterId: number) {
getBrokerList(clusterId).then(this.setBrokerList); this.setLoading(true);
getBrokerList(clusterId).then(this.setBrokerList).finally(() => this.setLoading(false));
} }
public getBrokerNetwork(clusterId: number) { public getBrokerNetwork(clusterId: number) {
...@@ -224,7 +234,8 @@ class Broker { ...@@ -224,7 +234,8 @@ class Broker {
} }
public getBrokerPartition(clusterId: number) { public getBrokerPartition(clusterId: number) {
getBrokerPartition(clusterId).then(this.setBrokerPartition); this.setLoading(true);
getBrokerPartition(clusterId).then(this.setBrokerPartition).finally(() => this.setLoading(false));
} }
public getOneBrokerNetwork(clusterId: number, brokerId: number) { public getOneBrokerNetwork(clusterId: number, brokerId: number) {
......
...@@ -17,7 +17,7 @@ export class Users { ...@@ -17,7 +17,7 @@ export class Users {
@action.bound @action.bound
public setUserData(data: []) { public setUserData(data: []) {
this.userData = data.map((d: any) => { this.userData = data.map((d: any) => {
d.role = this.roleMap[d.role]; d.roleName = this.roleMap[d.role];
return d; return d;
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册