Merge pull request #179 from lucasun/dev_2.3.0_fe

迭代V2.5, 修复broker监控问题,增加JMX认证支持等...
This commit is contained in:
EricZeng
2021-02-09 18:48:42 +08:00
committed by GitHub
38 changed files with 810 additions and 169 deletions

View File

@@ -94,6 +94,9 @@ import 'antd/es/divider/style';
import Upload from 'antd/es/upload'; import Upload from 'antd/es/upload';
import 'antd/es/upload/style'; import 'antd/es/upload/style';
import Transfer from 'antd/es/transfer';
import 'antd/es/transfer/style';
import TimePicker from 'antd/es/time-picker'; import TimePicker from 'antd/es/time-picker';
import 'antd/es/time-picker/style'; import 'antd/es/time-picker/style';
@@ -142,5 +145,6 @@ export {
TimePicker, TimePicker,
RangePickerValue, RangePickerValue,
Badge, Badge,
Popover Popover,
Transfer
}; };

View File

@@ -25,7 +25,7 @@
.editor{ .editor{
height: 100%; height: 100%;
position: absolute; position: absolute;
left: -14%; left: -12%;
width: 120%; width: 120%;
} }
} }

View File

@@ -21,24 +21,12 @@ class Monacoeditor extends React.Component<IEditorProps> {
public state = { public state = {
placeholder: '', placeholder: '',
}; };
// public arr = '{"clusterId":95,"startId":37397856,"step":100,"topicName":"kmo_topic_metrics_tempory_zq"}';
// public Ars(a: string) {
// const obj = JSON.parse(a);
// const newobj: any = {};
// for (const item in obj) {
// if (typeof obj[item] === 'object') {
// this.Ars(obj[item]);
// } else {
// newobj[item] = obj[item];
// }
// }
// return JSON.stringify(newobj);
// }
public async componentDidMount() { public async componentDidMount() {
const { value, onChange } = this.props; const { value, onChange } = this.props;
const format: any = await format2json(value); const format: any = await format2json(value);
this.editor = monaco.editor.create(this.ref, { this.editor = monaco.editor.create(this.ref, {
value: format.result, value: format.result || value,
language: 'json', language: 'json',
lineNumbers: 'off', lineNumbers: 'off',
scrollBeyondLastLine: false, scrollBeyondLastLine: false,
@@ -48,7 +36,7 @@ class Monacoeditor extends React.Component<IEditorProps> {
minimap: { minimap: {
enabled: false, enabled: false,
}, },
// automaticLayout: true, // 自动布局 automaticLayout: true, // 自动布局
glyphMargin: true, // 字形边缘 {},[] glyphMargin: true, // 字形边缘 {},[]
// useTabStops: false, // useTabStops: false,
// formatOnPaste: true, // formatOnPaste: true,

View File

@@ -130,6 +130,8 @@ class XForm extends React.Component<IXFormProps> {
this.renderFormItem(formItem), this.renderFormItem(formItem),
)} )}
{formItem.renderExtraElement ? formItem.renderExtraElement() : null} {formItem.renderExtraElement ? formItem.renderExtraElement() : null}
{/* 添加保存时间提示文案 */}
{formItem.attrs?.prompttype ? <span style={{ color: "#cccccc", fontSize: '12px', lineHeight: '20px', display: 'block' }}>{formItem.attrs.prompttype}</span> : null}
</Form.Item> </Form.Item>
); );
})} })}

View File

@@ -67,7 +67,7 @@ export const timeMonthStr = 'YYYY/MM';
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
export const indexUrl ={ export const indexUrl ={
indexUrl:'https://github.com/didi/kafka-manager', indexUrl:'https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/kafka_metrics_desc.md', // 指标说明
cagUrl:'https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/add_cluster/add_cluster.md', // 集群接入指南 Cluster access Guide cagUrl:'https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/add_cluster/add_cluster.md', // 集群接入指南 Cluster access Guide
} }

View File

@@ -100,7 +100,7 @@ export class ClusterConsumer extends SearchAndFilterContainer {
<div className="k-row"> <div className="k-row">
<ul className="k-tab"> <ul className="k-tab">
<li>{this.props.tab}</li> <li>{this.props.tab}</li>
{this.renderSearch()} {this.renderSearch('', '请输入消费组名称')}
</ul> </ul>
<Table <Table
columns={this.columns} columns={this.columns}

View File

@@ -2,7 +2,8 @@
import * as React from 'react'; import * as React from 'react';
import { SearchAndFilterContainer } from 'container/search-filter'; import { SearchAndFilterContainer } from 'container/search-filter';
import { Table } from 'component/antd'; import { Table, Button, Popconfirm, Modal, Transfer, notification } from 'component/antd';
// import { Transfer } from 'antd'
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { pagination } from 'constants/table'; import { pagination } from 'constants/table';
import Url from 'lib/url-parser'; import Url from 'lib/url-parser';
@@ -16,8 +17,12 @@ import { timeFormat } from 'constants/strategy';
export class ClusterController extends SearchAndFilterContainer { export class ClusterController extends SearchAndFilterContainer {
public clusterId: number; public clusterId: number;
public state = { public state: any = {
searchKey: '', searchKey: '',
searchCandidateKey: '',
isCandidateModel: false,
mockData: [],
targetKeys: [],
}; };
constructor(props: any) { constructor(props: any) {
@@ -37,6 +42,94 @@ export class ClusterController extends SearchAndFilterContainer {
return data; return data;
} }
public getCandidateData<T extends IController>(origin: T[]) {
let data: T[] = origin;
let { searchCandidateKey } = this.state;
searchCandidateKey = (searchCandidateKey + '').trim().toLowerCase();
data = searchCandidateKey ? origin.filter((item: IController) =>
(item.host !== undefined && item.host !== null) && item.host.toLowerCase().includes(searchCandidateKey as string),
) : origin;
return data;
}
// 候选controller
public renderCandidateController() {
const columns = [
{
title: 'BrokerId',
dataIndex: 'brokerId',
key: 'brokerId',
width: '20%',
sorter: (a: IController, b: IController) => b.brokerId - a.brokerId,
render: (r: string, t: IController) => {
return (
<a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
</a>
);
},
},
{
title: 'BrokerHost',
key: 'host',
dataIndex: 'host',
width: '20%',
// render: (r: string, t: IController) => {
// return (
// <a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
// </a>
// );
// },
},
{
title: 'Broker状态',
key: 'status',
dataIndex: 'status',
width: '20%',
render: (r: number, t: IController) => {
return (
<span>{r === 1 ? '不在线' : '在线'}</span>
);
},
},
{
title: '创建时间',
dataIndex: 'startTime',
key: 'startTime',
width: '25%',
sorter: (a: IController, b: IController) => b.timestamp - a.timestamp,
render: (t: number) => moment(t).format(timeFormat),
},
{
title: '操作',
dataIndex: 'operation',
key: 'operation',
width: '15%',
render: (r: string, t: IController) => {
return (
<Popconfirm
title="确定删除?"
onConfirm={() => this.deleteCandidateCancel(t)}
cancelText="取消"
okText="确认"
>
<a></a>
</Popconfirm>
);
},
},
];
return (
<Table
columns={columns}
dataSource={this.getCandidateData(admin.controllerCandidate)}
pagination={pagination}
rowKey="key"
/>
);
}
public renderController() { public renderController() {
const columns = [ const columns = [
@@ -58,12 +151,6 @@ export class ClusterController extends SearchAndFilterContainer {
key: 'host', key: 'host',
dataIndex: 'host', dataIndex: 'host',
width: '30%', width: '30%',
// render: (r: string, t: IController) => {
// return (
// <a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
// </a>
// );
// },
}, },
{ {
title: '变更时间', title: '变更时间',
@@ -87,16 +174,104 @@ export class ClusterController extends SearchAndFilterContainer {
public componentDidMount() { public componentDidMount() {
admin.getControllerHistory(this.clusterId); admin.getControllerHistory(this.clusterId);
admin.getCandidateController(this.clusterId);
admin.getBrokersMetadata(this.clusterId);
}
public addController = () => {
this.setState({ isCandidateModel: true, targetKeys: [] })
}
public addCandidateChange = (targetKeys: any) => {
this.setState({ targetKeys })
}
public handleCandidateCancel = () => {
this.setState({ isCandidateModel: false });
}
public handleCandidateOk = () => {
let brokerIdList = this.state.targetKeys.map((item: any) => {
return admin.brokersMetadata[item].brokerId
})
admin.addCandidateController(this.clusterId, brokerIdList).then(data => {
notification.success({ message: '新增成功' });
admin.getCandidateController(this.clusterId);
}).catch(err => {
notification.error({ message: '新增失败' });
})
this.setState({ isCandidateModel: false, targetKeys: [] });
}
public deleteCandidateCancel = (target: any) => {
admin.deleteCandidateCancel(this.clusterId, [target.brokerId]).then(() => {
notification.success({ message: '删除成功' });
});
this.setState({ isCandidateModel: false });
}
public renderAddCandidateController() {
let filterControllerCandidate = admin.brokersMetadata.filter((item: any) => {
return !admin.filtercontrollerCandidate.includes(item.brokerId)
})
return (
<Modal
title="新增候选Controller"
visible={this.state.isCandidateModel}
// okText="确认"
// cancelText="取消"
maskClosable={false}
// onOk={() => this.handleCandidateOk()}
onCancel={() => this.handleCandidateCancel()}
footer={<>
<Button style={{ width: '60px' }} onClick={() => this.handleCandidateCancel()}></Button>
<Button disabled={this.state.targetKeys.length > 0 ? false : true} style={{ width: '60px' }} type="primary" onClick={() => this.handleCandidateOk()}></Button>
</>
}
>
<Transfer
dataSource={filterControllerCandidate}
targetKeys={this.state.targetKeys}
render={item => item.host}
onChange={(targetKeys) => this.addCandidateChange(targetKeys)}
titles={['未选', '已选']}
locale={{
itemUnit: '项',
itemsUnit: '项',
}}
listStyle={{
width: "45%",
}}
/>
</Modal>
);
} }
public render() { public render() {
return ( return (
<div className="k-row"> <div className="k-row">
<ul className="k-tab"> <ul className="k-tab">
<li>
<span>Controller</span>
<span style={{ display: 'inline-block', color: "#a7a8a9", fontSize: '12px', marginLeft: '15px' }}>Controller将会优先从以下Broker中选举</span>
</li>
<div style={{ display: 'flex' }}>
<div style={{ marginRight: '15px' }}>
<Button onClick={() => this.addController()} type='primary'>Controller</Button>
</div>
{this.renderSearch('', '请查找Host', 'searchCandidateKey')}
</div>
</ul>
{this.renderCandidateController()}
<ul className="k-tab" style={{ marginTop: '10px' }}>
<li>{this.props.tab}</li> <li>{this.props.tab}</li>
{this.renderSearch('', '请输入Host')} {this.renderSearch('', '请输入Host')}
</ul> </ul>
{this.renderController()} {this.renderController()}
{this.renderAddCandidateController()}
</div> </div>
); );
} }

View File

@@ -95,3 +95,9 @@
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
} }
.asd{
display: flex;
justify-content: space-around;
align-items: center;
}

View File

@@ -32,9 +32,9 @@ export class ClusterDetail extends React.Component {
} }
public render() { public render() {
let content = {} as IMetaData; let content = {} as IMetaData;
content = admin.basicInfo ? admin.basicInfo : content; content = admin.basicInfo ? admin.basicInfo : content;
return ( return (
<> <>
<PageHeader <PageHeader
className="detail topic-detail-header" className="detail topic-detail-header"
@@ -46,7 +46,7 @@ export class ClusterDetail extends React.Component {
<ClusterOverview basicInfo={content} /> <ClusterOverview basicInfo={content} />
</TabPane> </TabPane>
<TabPane tab="Topic信息" key="2"> <TabPane tab="Topic信息" key="2">
<ClusterTopic tab={'Topic信息'}/> <ClusterTopic tab={'Topic信息'} />
</TabPane> </TabPane>
<TabPane tab="Broker信息" key="3"> <TabPane tab="Broker信息" key="3">
<ClusterBroker tab={'Broker信息'} basicInfo={content} /> <ClusterBroker tab={'Broker信息'} basicInfo={content} />
@@ -60,11 +60,11 @@ export class ClusterDetail extends React.Component {
<TabPane tab="逻辑集群信息" key="6"> <TabPane tab="逻辑集群信息" key="6">
<LogicalCluster tab={'逻辑集群信息'} basicInfo={content} /> <LogicalCluster tab={'逻辑集群信息'} basicInfo={content} />
</TabPane> </TabPane>
<TabPane tab="Controller变更历史" key="7"> <TabPane tab="Controller信息" key="7">
<ClusterController tab={'Controller变更历史'} /> <ClusterController tab={'Controller变更历史'} />
</TabPane> </TabPane>
<TabPane tab="限流信息" key="8"> <TabPane tab="限流信息" key="8">
<CurrentLimiting tab={'限流信息'}/> <CurrentLimiting tab={'限流信息'} />
</TabPane> </TabPane>
</Tabs> </Tabs>
</> </>

View File

@@ -12,6 +12,7 @@ import { urlPrefix } from 'constants/left-menu';
import { indexUrl } from 'constants/strategy' import { indexUrl } from 'constants/strategy'
import { region } from 'store'; import { region } from 'store';
import './index.less'; import './index.less';
import Monacoeditor from 'component/editor/monacoEditor';
import { getAdminClusterColumns } from '../config'; import { getAdminClusterColumns } from '../config';
const { confirm } = Modal; const { confirm } = Modal;
@@ -132,6 +133,25 @@ export class ClusterList extends SearchAndFilterContainer {
"security.protocol": "SASL_PLAINTEXT", "security.protocol": "SASL_PLAINTEXT",
"sasl.mechanism": "PLAIN", "sasl.mechanism": "PLAIN",
"sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\\"xxxxxx\\" password=\\"xxxxxx\\";" "sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\\"xxxxxx\\" password=\\"xxxxxx\\";"
}`,
rows: 8,
},
},
{
key: 'jmxProperties',
label: 'JMX认证',
type: 'text_area',
rules: [{
required: false,
message: '请输入JMX认证',
}],
attrs: {
placeholder: `请输入JMX认证例如
{
"maxConn": 10, #KM对单台Broker对最大连接数
"username": "xxxxx", #用户名
"password": "xxxxx", #密码
"openSSL": true, #开启SSLtrue表示开启SSLfalse表示关闭
}`, }`,
rows: 8, rows: 8,
}, },

View File

@@ -1,8 +1,8 @@
import * as React from 'react'; import * as React from 'react';
import { IUser, IUploadFile, IConfigure, IMetaData, IBrokersPartitions } from 'types/base-type'; import { IUser, IUploadFile, IConfigure, IConfigGateway, IMetaData } from 'types/base-type';
import { users } from 'store/users'; import { users } from 'store/users';
import { version } from 'store/version'; import { version } from 'store/version';
import { showApplyModal, showModifyModal, showConfigureModal } from 'container/modal/admin'; import { showApplyModal, showApplyModalModifyPassword, showModifyModal, showConfigureModal, showConfigGatewayModal } from 'container/modal/admin';
import { Popconfirm, Tooltip } from 'component/antd'; import { Popconfirm, Tooltip } from 'component/antd';
import { admin } from 'store/admin'; import { admin } from 'store/admin';
import { cellStyle } from 'constants/table'; import { cellStyle } from 'constants/table';
@@ -27,6 +27,7 @@ export const getUserColumns = () => {
return ( return (
<span className="table-operation"> <span className="table-operation">
<a onClick={() => showApplyModal(record)}></a> <a onClick={() => showApplyModal(record)}></a>
<a onClick={() => showApplyModalModifyPassword(record)}></a>
<Popconfirm <Popconfirm
title="确定删除?" title="确定删除?"
onConfirm={() => users.deleteUser(record.username)} onConfirm={() => users.deleteUser(record.username)}
@@ -184,6 +185,87 @@ export const getConfigureColumns = () => {
return columns; return columns;
}; };
// 网关配置
export const getConfigColumns = () => {
const columns = [
{
title: '配置类型',
dataIndex: 'type',
key: 'type',
width: '25%',
ellipsis: true,
sorter: (a: IConfigGateway, b: IConfigGateway) => a.type.charCodeAt(0) - b.type.charCodeAt(0),
},
{
title: '配置键',
dataIndex: 'name',
key: 'name',
width: '15%',
ellipsis: true,
sorter: (a: IConfigGateway, b: IConfigGateway) => a.name.charCodeAt(0) - b.name.charCodeAt(0),
},
{
title: '配置值',
dataIndex: 'value',
key: 'value',
width: '20%',
ellipsis: true,
sorter: (a: IConfigGateway, b: IConfigGateway) => a.value.charCodeAt(0) - b.value.charCodeAt(0),
render: (t: string) => {
return t.substr(0, 1) === '{' && t.substr(0, -1) === '}' ? JSON.stringify(JSON.parse(t), null, 4) : t;
},
},
{
title: '修改时间',
dataIndex: 'modifyTime',
key: 'modifyTime',
width: '15%',
sorter: (a: IConfigGateway, b: IConfigGateway) => b.modifyTime - a.modifyTime,
render: (t: number) => moment(t).format(timeFormat),
},
{
title: '版本号',
dataIndex: 'version',
key: 'version',
width: '10%',
ellipsis: true,
sorter: (a: IConfigGateway, b: IConfigGateway) => b.version.charCodeAt(0) - a.version.charCodeAt(0),
},
{
title: '描述信息',
dataIndex: 'description',
key: 'description',
width: '20%',
ellipsis: true,
onCell: () => ({
style: {
maxWidth: 180,
...cellStyle,
},
}),
},
{
title: '操作',
width: '10%',
render: (text: string, record: IConfigGateway) => {
return (
<span className="table-operation">
<a onClick={() => showConfigGatewayModal(record)}></a>
<Popconfirm
title="确定删除?"
onConfirm={() => admin.deleteConfigGateway({ id: record.id })}
cancelText="取消"
okText="确认"
>
<a></a>
</Popconfirm>
</span>);
},
},
];
return columns;
};
const renderClusterHref = (value: number | string, item: IMetaData, key: number) => { const renderClusterHref = (value: number | string, item: IMetaData, key: number) => {
return ( // 0 暂停监控--不可点击 1 监控中---可正常点击 return ( // 0 暂停监控--不可点击 1 监控中---可正常点击
<> <>

View File

@@ -3,11 +3,11 @@ import { SearchAndFilterContainer } from 'container/search-filter';
import { Table, Button, Spin } from 'component/antd'; import { Table, Button, Spin } from 'component/antd';
import { admin } from 'store/admin'; import { admin } from 'store/admin';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { IConfigure } from 'types/base-type'; import { IConfigure, IConfigGateway } from 'types/base-type';
import { users } from 'store/users'; import { users } from 'store/users';
import { pagination } from 'constants/table'; import { pagination } from 'constants/table';
import { getConfigureColumns } from './config'; import { getConfigureColumns, getConfigColumns } from './config';
import { showConfigureModal } from 'container/modal/admin'; import { showConfigureModal, showConfigGatewayModal } from 'container/modal/admin';
@observer @observer
export class ConfigureManagement extends SearchAndFilterContainer { export class ConfigureManagement extends SearchAndFilterContainer {
@@ -17,7 +17,12 @@ export class ConfigureManagement extends SearchAndFilterContainer {
}; };
public componentDidMount() { public componentDidMount() {
admin.getConfigure(); if (this.props.isShow) {
admin.getGatewayList();
admin.getGatewayType();
} else {
admin.getConfigure();
}
} }
public getData<T extends IConfigure>(origin: T[]) { public getData<T extends IConfigure>(origin: T[]) {
@@ -34,15 +39,34 @@ export class ConfigureManagement extends SearchAndFilterContainer {
return data; return data;
} }
public getGatewayData<T extends IConfigGateway>(origin: T[]) {
let data: T[] = origin;
let { searchKey } = this.state;
searchKey = (searchKey + '').trim().toLowerCase();
data = searchKey ? origin.filter((item: IConfigGateway) =>
((item.name !== undefined && item.name !== null) && item.name.toLowerCase().includes(searchKey as string))
|| ((item.value !== undefined && item.value !== null) && item.value.toLowerCase().includes(searchKey as string))
|| ((item.description !== undefined && item.description !== null) &&
item.description.toLowerCase().includes(searchKey as string)),
) : origin;
return data;
}
public renderTable() { public renderTable() {
return ( return (
<Spin spinning={users.loading}> <Spin spinning={users.loading}>
<Table {this.props.isShow ? <Table
rowKey="key"
columns={getConfigColumns()}
dataSource={this.getGatewayData(admin.configGatewayList)}
pagination={pagination}
/> : <Table
rowKey="key" rowKey="key"
columns={getConfigureColumns()} columns={getConfigureColumns()}
dataSource={this.getData(admin.configureList)} dataSource={this.getData(admin.configureList)}
pagination={pagination} pagination={pagination}
/> />}
</Spin> </Spin>
); );
@@ -53,7 +77,7 @@ export class ConfigureManagement extends SearchAndFilterContainer {
<ul> <ul>
{this.renderSearch('', '请输入配置键、值或描述')} {this.renderSearch('', '请输入配置键、值或描述')}
<li className="right-btn-1"> <li className="right-btn-1">
<Button type="primary" onClick={() => showConfigureModal()}></Button> <Button type="primary" onClick={() => this.props.isShow ? showConfigGatewayModal() : showConfigureModal()}></Button>
</li> </li>
</ul> </ul>
); );

View File

@@ -6,6 +6,7 @@ import { curveKeys, CURVE_KEY_MAP, PERIOD_RADIO_MAP, PERIOD_RADIO } from './conf
import moment = require('moment'); import moment = require('moment');
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { timeStampStr } from 'constants/strategy'; import { timeStampStr } from 'constants/strategy';
import { adminMonitor } from 'store/admin-monitor';
@observer @observer
export class DataCurveFilter extends React.Component { export class DataCurveFilter extends React.Component {
@@ -21,6 +22,7 @@ export class DataCurveFilter extends React.Component {
} }
public refreshAll = () => { public refreshAll = () => {
adminMonitor.setRequestId(null);
Object.keys(curveKeys).forEach((c: curveKeys) => { Object.keys(curveKeys).forEach((c: curveKeys) => {
const { typeInfo, curveInfo: option } = CURVE_KEY_MAP.get(c); const { typeInfo, curveInfo: option } = CURVE_KEY_MAP.get(c);
const { parser } = typeInfo; const { parser } = typeInfo;
@@ -32,7 +34,7 @@ export class DataCurveFilter extends React.Component {
return ( return (
<> <>
<Radio.Group onChange={this.radioChange} defaultValue={curveInfo.periodKey}> <Radio.Group onChange={this.radioChange} defaultValue={curveInfo.periodKey}>
{PERIOD_RADIO.map(p => <Radio.Button key={p.key} value={p.key}>{p.label}</Radio.Button>)} {PERIOD_RADIO.map(p => <Radio.Button key={p.key} value={p.key}>{p.label}</Radio.Button>)}
</Radio.Group> </Radio.Group>
<DatePicker.RangePicker <DatePicker.RangePicker
format={timeStampStr} format={timeStampStr}

View File

@@ -13,17 +13,20 @@ export class PlatformManagement extends React.Component {
public render() { public render() {
return ( return (
<> <>
<Tabs activeKey={location.hash.substr(1) || '1'} type="card" onChange={handleTabKey}> <Tabs activeKey={location.hash.substr(1) || '1'} type="card" onChange={handleTabKey}>
<TabPane tab="应用管理" key="1"> <TabPane tab="应用管理" key="1">
<AdminAppList /> <AdminAppList />
</TabPane> </TabPane>
<TabPane tab="用户管理" key="2"> <TabPane tab="用户管理" key="2">
<UserManagement /> <UserManagement />
</TabPane> </TabPane>
<TabPane tab="配置管理" key="3"> <TabPane tab="平台配置" key="3">
<ConfigureManagement /> <ConfigureManagement isShow={false} />
</TabPane> </TabPane>
</Tabs> <TabPane tab="网关配置" key="4">
<ConfigureManagement isShow={true} />
</TabPane>
</Tabs>
</> </>
); );
} }

View File

@@ -29,7 +29,7 @@ export class UserManagement extends SearchAndFilterContainer {
searchKey = (searchKey + '').trim().toLowerCase(); searchKey = (searchKey + '').trim().toLowerCase();
data = searchKey ? origin.filter((item: IUser) => data = searchKey ? origin.filter((item: IUser) =>
(item.username !== undefined && item.username !== null) && item.username.toLowerCase().includes(searchKey as string)) : origin ; (item.username !== undefined && item.username !== null) && item.username.toLowerCase().includes(searchKey as string)) : origin;
return data; return data;
} }

View File

@@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { alarm } from 'store/alarm'; import { alarm } from 'store/alarm';
import { IMonitorGroups } from 'types/base-type'; import { IMonitorGroups } from 'types/base-type';
import { getValueFromLocalStorage, setValueToLocalStorage } from 'lib/local-storage'; import { getValueFromLocalStorage, setValueToLocalStorage, deleteValueFromLocalStorage } from 'lib/local-storage';
import { VirtualScrollSelect } from '../../../component/virtual-scroll-select'; import { VirtualScrollSelect } from '../../../component/virtual-scroll-select';
interface IAlarmSelectProps { interface IAlarmSelectProps {
@@ -36,6 +36,10 @@ export class AlarmSelect extends React.Component<IAlarmSelectProps> {
onChange && onChange(params); onChange && onChange(params);
} }
public componentWillUnmount() {
deleteValueFromLocalStorage('monitorGroups');
}
public render() { public render() {
const { value, isDisabled } = this.props; const { value, isDisabled } = this.props;
return ( return (

View File

@@ -9,6 +9,7 @@ import { pagination } from 'constants/table';
import { urlPrefix } from 'constants/left-menu'; import { urlPrefix } from 'constants/left-menu';
import { alarm } from 'store/alarm'; import { alarm } from 'store/alarm';
import 'styles/table-filter.less'; import 'styles/table-filter.less';
import { Link } from 'react-router-dom';
@observer @observer
export class AlarmList extends SearchAndFilterContainer { export class AlarmList extends SearchAndFilterContainer {
@@ -24,7 +25,7 @@ export class AlarmList extends SearchAndFilterContainer {
if (app.active !== '-1' || searchKey !== '') { if (app.active !== '-1' || searchKey !== '') {
data = origin.filter(d => data = origin.filter(d =>
((d.name !== undefined && d.name !== null) && d.name.toLowerCase().includes(searchKey as string) ((d.name !== undefined && d.name !== null) && d.name.toLowerCase().includes(searchKey as string)
|| ((d.operator !== undefined && d.operator !== null) && d.operator.toLowerCase().includes(searchKey as string))) || ((d.operator !== undefined && d.operator !== null) && d.operator.toLowerCase().includes(searchKey as string)))
&& (app.active === '-1' || d.appId === (app.active + '')), && (app.active === '-1' || d.appId === (app.active + '')),
); );
} else { } else {
@@ -55,9 +56,7 @@ export class AlarmList extends SearchAndFilterContainer {
{this.renderSearch('名称:', '请输入告警规则或者操作人')} {this.renderSearch('名称:', '请输入告警规则或者操作人')}
<li className="right-btn-1"> <li className="right-btn-1">
<Button type="primary"> <Button type="primary">
<a href={`${urlPrefix}/alarm/add`}> <Link to={`/alarm/add`}></Link>
</a>
</Button> </Button>
</li> </li>
</> </>
@@ -68,6 +67,9 @@ export class AlarmList extends SearchAndFilterContainer {
if (!alarm.monitorStrategies.length) { if (!alarm.monitorStrategies.length) {
alarm.getMonitorStrategies(); alarm.getMonitorStrategies();
} }
if (!app.data.length) {
app.getAppList();
}
} }
public render() { public render() {

View File

@@ -91,7 +91,7 @@ export class MyCluster extends SearchAndFilterContainer {
], ],
formData: {}, formData: {},
visible: true, visible: true,
title: '申请集群', title: <div><span></span><a className='applicationDocument' href="https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/resource_apply.md" target='_blank'></a></div>,
okText: '确认', okText: '确认',
onSubmit: (value: any) => { onSubmit: (value: any) => {
value.idc = region.currentRegion; value.idc = region.currentRegion;

View File

@@ -117,12 +117,12 @@ class DataMigrationFormTable extends React.Component<IFormTableProps> {
key: 'maxThrottle', key: 'maxThrottle',
editable: true, editable: true,
}, { }, {
title: '迁移保存时间(h)', title: '迁移后Topic保存时间(h)',
dataIndex: 'reassignRetentionTime', dataIndex: 'reassignRetentionTime',
key: 'reassignRetentionTime', key: 'reassignRetentionTime',
editable: true, editable: true,
}, { }, {
title: '原保存时间(h)', title: '原Topic保存时间(h)',
dataIndex: 'retentionTime', dataIndex: 'retentionTime',
key: 'retentionTime', // originalRetentionTime key: 'retentionTime', // originalRetentionTime
width: '132px', width: '132px',

View File

@@ -61,6 +61,7 @@ export const showEditClusterTopic = (item: IClusterTopics) => {
attrs: { attrs: {
placeholder: '请输入保存时间', placeholder: '请输入保存时间',
suffix: '小时', suffix: '小时',
prompttype:'修改保存时间,预计一分钟左右生效!'
}, },
}, },
{ {

View File

@@ -158,26 +158,26 @@ export const createMigrationTasks = () => {
}, },
{ {
key: 'originalRetentionTime', key: 'originalRetentionTime',
label: '原保存时间', label: '原Topic保存时间',
rules: [{ rules: [{
required: true, required: true,
message: '请输入原保存时间', message: '请输入原Topic保存时间',
}], }],
attrs: { attrs: {
disabled: true, disabled: true,
placeholder: '请输入原保存时间', placeholder: '请输入原Topic保存时间',
suffix: '小时', suffix: '小时',
}, },
}, },
{ {
key: 'reassignRetentionTime', key: 'reassignRetentionTime',
label: '迁移保存时间', label: '迁移后Topic保存时间',
rules: [{ rules: [{
required: true, required: true,
message: '请输入迁移保存时间', message: '请输入迁移后Topic保存时间',
}], }],
attrs: { attrs: {
placeholder: '请输入迁移保存时间', placeholder: '请输入迁移后Topic保存时间',
suffix: '小时', suffix: '小时',
}, },
}, },

View File

@@ -24,26 +24,111 @@ export const showApplyModal = (record?: IUser) => {
value: +item, value: +item,
})), })),
rules: [{ required: true, message: '请选择角色' }], rules: [{ required: true, message: '请选择角色' }],
}, {
key: 'password',
label: '密码',
type: FormItemType.inputPassword,
rules: [{ required: !record, message: '请输入密码' }],
}, },
// {
// key: 'password',
// label: '密码',
// type: FormItemType.inputPassword,
// rules: [{ required: !record, message: '请输入密码' }],
// },
], ],
formData: record || {}, formData: record || {},
visible: true, visible: true,
title: record ? '修改用户' : '新增用户', title: record ? '修改用户' : '新增用户',
onSubmit: (value: IUser) => { onSubmit: (value: IUser) => {
if (record) { if (record) {
return users.modfiyUser(value).then(() => { return users.modfiyUser(value)
message.success('操作成功');
});
} }
return users.addUser(value).then(() => { return users.addUser(value).then(() => {
message.success('操作成功'); message.success('操作成功');
}); });
}, },
}; };
if(!record){
let formMap: any = xFormModal.formMap
formMap.splice(2, 0,{
key: 'password',
label: '密码',
type: FormItemType.inputPassword,
rules: [{ required: !record, message: '请输入密码' }],
},)
}
wrapper.open(xFormModal); wrapper.open(xFormModal);
}; };
// const handleCfPassword = (rule:any, value:any, callback:any)=>{
// if()
// }
export const showApplyModalModifyPassword = (record: IUser) => {
const xFormModal:any = {
formMap: [
// {
// key: 'oldPassword',
// label: '旧密码',
// type: FormItemType.inputPassword,
// rules: [{
// required: true,
// message: '请输入旧密码',
// }]
// },
{
key: 'newPassword',
label: '新密码',
type: FormItemType.inputPassword,
rules: [
{
required: true,
message: '请输入新密码',
}
],
attrs:{
onChange:(e:any)=>{
users.setNewPassWord(e.target.value)
}
}
},
{
key: 'confirmPassword',
label: '确认密码',
type: FormItemType.inputPassword,
rules: [
{
required: true,
message: '请确认密码',
validator:(rule:any, value:any, callback:any) => {
// 验证新密码的一致性
if(users.newPassWord){
if(value!==users.newPassWord){
rule.message = "两次密码输入不一致";
callback('两次密码输入不一致')
}else{
callback()
}
}else if(!value){
rule.message = "请确认密码";
callback('请确认密码');
}else{
callback()
}
},
}
],
},
],
formData: record || {},
visible: true,
title: '修改密码',
onSubmit: (value: IUser) => {
let params:any = {
username:record?.username,
password:value.confirmPassword,
role:record?.role,
}
return users.modfiyUser(params).then(() => {
message.success('操作成功');
});
},
}
wrapper.open(xFormModal);
};

View File

@@ -1,6 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import { notification } from 'component/antd'; import { notification, Select } from 'component/antd';
import { IUploadFile, IConfigure } from 'types/base-type'; import { IUploadFile, IConfigure, IConfigGateway } from 'types/base-type';
import { version } from 'store/version'; import { version } from 'store/version';
import { admin } from 'store/admin'; import { admin } from 'store/admin';
import { wrapper } from 'store'; import { wrapper } from 'store';
@@ -97,8 +97,8 @@ const updateFormModal = (type: number) => {
formMap[2].attrs = { formMap[2].attrs = {
accept: version.fileSuffix, accept: version.fileSuffix,
}, },
// tslint:disable-next-line:no-unused-expression // tslint:disable-next-line:no-unused-expression
wrapper.ref && wrapper.ref.updateFormMap$(formMap, wrapper.xFormWrapper.formData, true); wrapper.ref && wrapper.ref.updateFormMap$(formMap, wrapper.xFormWrapper.formData, true);
} }
}; };
@@ -157,8 +157,8 @@ export const showModifyModal = (record: IUploadFile) => {
export const showConfigureModal = async (record?: IConfigure) => { export const showConfigureModal = async (record?: IConfigure) => {
if (record) { if (record) {
const result:any = await format2json(record.configValue); const result: any = await format2json(record.configValue);
record.configValue = result.result; record.configValue = result.result || record.configValue;
} }
const xFormModal = { const xFormModal = {
formMap: [ formMap: [
@@ -193,10 +193,69 @@ export const showConfigureModal = async (record?: IConfigure) => {
return admin.editConfigure(value).then(data => { return admin.editConfigure(value).then(data => {
notification.success({ message: '编辑配置成功' }); notification.success({ message: '编辑配置成功' });
}); });
} else {
return admin.addNewConfigure(value).then(data => {
notification.success({ message: '新建配置成功' });
});
}
},
};
wrapper.open(xFormModal);
};
export const showConfigGatewayModal = async (record?: IConfigGateway) => {
const xFormModal = {
formMap: [
{
key: 'type',
label: '配置类型',
rules: [{ required: true, message: '请选择配置类型' }],
type: "select",
options: admin.gatewayType.map((item: any, index: number) => ({
key: index,
label: item.configName,
value: item.configType,
})),
attrs: {
disabled: record ? true : false,
}
}, {
key: 'name',
label: '配置键',
rules: [{ required: true, message: '请输入配置键' }],
attrs: {
disabled: record ? true : false,
},
}, {
key: 'value',
label: '配置值',
type: 'text_area',
rules: [{
required: true,
message: '请输入配置值',
}],
}, {
key: 'description',
label: '描述',
type: 'text_area',
rules: [{ required: true, message: '请输入备注' }],
},
],
formData: record || {},
visible: true,
isWaitting: true,
title: `${record ? '编辑配置' : '新建配置'}`,
onSubmit: async (parmas: IConfigGateway) => {
if (record) {
parmas.id = record.id;
return admin.editConfigGateway(parmas).then(data => {
notification.success({ message: '编辑配置成功' });
});
} else {
return admin.addNewConfigGateway(parmas).then(data => {
notification.success({ message: '新建配置成功' });
});
} }
return admin.addNewConfigure(value).then(data => {
notification.success({ message: '新建配置成功' });
});
}, },
}; };
wrapper.open(xFormModal); wrapper.open(xFormModal);

View File

@@ -85,7 +85,7 @@ export const showEditModal = (record?: IAppItem, from?: string, isDisabled?: boo
], ],
formData: record, formData: record,
visible: true, visible: true,
title: isDisabled ? '详情' : record ? '编辑' : <div><span></span><a className='applicationDocument' href="###" target='_blank'></a></div>, title: isDisabled ? '详情' : record ? '编辑' : <div><span></span><a className='applicationDocument' href="https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/resource_apply.md" target='_blank'></a></div>,
// customRenderElement: isDisabled ? '' : record ? '' : <span className="tips">集群资源充足时预计1分钟自动审批通过</span>, // customRenderElement: isDisabled ? '' : record ? '' : <span className="tips">集群资源充足时预计1分钟自动审批通过</span>,
isWaitting: true, isWaitting: true,
onSubmit: (value: IAppItem) => { onSubmit: (value: IAppItem) => {

View File

@@ -20,14 +20,14 @@ export interface IRenderData {
} }
export const migrationModal = (renderData: IRenderData[]) => { export const migrationModal = (renderData: IRenderData[]) => {
const xFormWrapper = { const xFormWrapper = {
type: 'drawer', type: 'drawer',
visible: true, visible: true,
width: 1000, width: 1000,
title: '新建迁移任务', title: '新建迁移任务',
customRenderElement: <WrappedDataMigrationFormTable data={renderData}/>, customRenderElement: <WrappedDataMigrationFormTable data={renderData} />,
nofooter: true, nofooter: true,
noform: true, noform: true,
}; };
wrapper.open(xFormWrapper as IXFormWrapper); wrapper.open(xFormWrapper as IXFormWrapper);
}; };

View File

@@ -75,8 +75,8 @@ export const showApprovalModal = (info: IOrderInfo, status: number, from?: strin
// }], // }],
rules: [{ rules: [{
required: true, required: true,
message: '请输入大于12小于999的整数', message: '请输入大于0小于10000的整数',
pattern: /^([1-9]{1}[0-9]{2})$|^([2-9]{1}[0-9]{1})$|^(1[2-9]{1})$/, pattern: /^\+?[1-9]\d{0,3}(\.\d*)?$/,
}], }],
}, { }, {
key: 'species', key: 'species',

View File

@@ -88,7 +88,7 @@ export const applyTopic = () => {
], ],
formData: {}, formData: {},
visible: true, visible: true,
title: '申请Topic', title: <div><span>Topic</span><a className='applicationDocument' href="https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/resource_apply.md" target='_blank'></a></div>,
okText: '确认', okText: '确认',
// customRenderElement: <span className="tips">集群资源充足时预计1分钟自动审批通过</span>, // customRenderElement: <span className="tips">集群资源充足时预计1分钟自动审批通过</span>,
isWaitting: true, isWaitting: true,

View File

@@ -126,7 +126,7 @@ export class SearchAndFilterContainer extends React.Component<any, ISearchAndFil
); );
} }
public renderSearch(text?: string, placeholder?: string, keyName: string = 'searchKey') { public renderSearch(text?: string, placeholder?: string, keyName: string = 'searchKey',) {
const value = this.state[keyName] as string; const value = this.state[keyName] as string;
return ( return (
<li className="render-box"> <li className="render-box">

View File

@@ -101,7 +101,9 @@ export class ConnectInformation extends SearchAndFilterContainer {
<> <>
<div className="k-row" > <div className="k-row" >
<ul className="k-tab"> <ul className="k-tab">
<li></li> <li>
<span style={{ color: '#a7a8a9', fontSize: '12px', padding: '0 15px' }}>20</span>
</li>
{this.renderSearch('', '请输入连接信息', 'searchKey')} {this.renderSearch('', '请输入连接信息', 'searchKey')}
</ul> </ul>
{this.renderConnectionInfo(this.getData(topic.connectionInfo))} {this.renderConnectionInfo(this.getData(topic.connectionInfo))}

View File

@@ -138,7 +138,7 @@ export class GroupID extends SearchAndFilterContainer {
public renderConsumerDetails() { public renderConsumerDetails() {
const consumerGroup = this.consumerGroup; const consumerGroup = this.consumerGroup;
const columns = [{ const columns: any = [{
title: 'Partition ID', title: 'Partition ID',
dataIndex: 'partitionId', dataIndex: 'partitionId',
key: 'partitionId', key: 'partitionId',
@@ -179,7 +179,8 @@ export class GroupID extends SearchAndFilterContainer {
<> <>
<div className="details-box"> <div className="details-box">
<b>{consumerGroup}</b> <b>{consumerGroup}</b>
<div> <div style={{ display: 'flex' }}>
{this.renderSearch('', '请输入Consumer ID')}
<Button onClick={this.backToPage}></Button> <Button onClick={this.backToPage}></Button>
<Button onClick={this.updateDetailsStatus}></Button> <Button onClick={this.updateDetailsStatus}></Button>
<Button onClick={() => this.showResetOffset()}>Offset</Button> <Button onClick={() => this.showResetOffset()}>Offset</Button>
@@ -187,7 +188,7 @@ export class GroupID extends SearchAndFilterContainer {
</div> </div>
<Table <Table
columns={columns} columns={columns}
dataSource={topic.consumeDetails} dataSource={this.getDetailData(topic.consumeDetails)}
rowKey="key" rowKey="key"
pagination={pagination} pagination={pagination}
/> />
@@ -214,7 +215,12 @@ export class GroupID extends SearchAndFilterContainer {
dataIndex: 'location', dataIndex: 'location',
key: 'location', key: 'location',
width: '34%', width: '34%',
}, }, {
title: '状态',
dataIndex: 'state',
key: 'state',
width: '34%',
}
]; ];
return ( return (
<> <>
@@ -236,7 +242,17 @@ export class GroupID extends SearchAndFilterContainer {
data = searchKey ? origin.filter((item: IConsumerGroups) => data = searchKey ? origin.filter((item: IConsumerGroups) =>
(item.consumerGroup !== undefined && item.consumerGroup !== null) && item.consumerGroup.toLowerCase().includes(searchKey as string), (item.consumerGroup !== undefined && item.consumerGroup !== null) && item.consumerGroup.toLowerCase().includes(searchKey as string),
) : origin ; ) : origin;
return data;
}
public getDetailData<T extends IConsumeDetails>(origin: T[]) {
let data: T[] = origin;
let { searchKey } = this.state;
searchKey = (searchKey + '').trim().toLowerCase();
data = searchKey ? origin.filter((item: IConsumeDetails) =>
(item.clientId !== undefined && item.clientId !== null) && item.clientId.toLowerCase().includes(searchKey as string),
) : origin;
return data; return data;
} }

View File

@@ -71,32 +71,32 @@ class ResetOffset extends React.Component<any> {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const { typeValue, offsetValue } = this.state; const { typeValue, offsetValue } = this.state;
return ( return (
<> <>
<Alert message="重置之前一定要关闭消费客户端" type="warning" showIcon={true} /> <Alert message="重置消费偏移前,请先关闭客户端,否则会重置失败 " type="warning" showIcon={true} />
<Alert message="重置之前一定要关闭消费客户端" type="warning" showIcon={true} /> <Alert message="关闭客户端后,请等待一分钟之后再重置消费偏移 " type="warning" showIcon={true} />
<Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} className="mb-30"/> {/* <Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} className="mb-30" /> */}
<div className="o-container"> <div className="o-container">
<Form labelAlign="left" onSubmit={this.handleSubmit} > <Form labelAlign="left" onSubmit={this.handleSubmit} >
<Radio.Group onChange={this.onChangeType} value={typeValue}> <Radio.Group onChange={this.onChangeType} value={typeValue}>
<Radio value="time"><span className="title-con"></span></Radio> <Radio value="time"><span className="title-con"></span></Radio>
<Row> <Row>
<Col span={26}> <Col span={26}>
<Form.Item label="" > <Form.Item label="" >
<Radio.Group <Radio.Group
onChange={this.onChangeOffset} onChange={this.onChangeOffset}
value={offsetValue} value={offsetValue}
disabled={typeValue === 'partition'} disabled={typeValue === 'partition'}
defaultValue="offset" defaultValue="offset"
className="mr-10" className="mr-10"
> >
<Radio.Button value="offset">offset</Radio.Button> <Radio.Button value="offset">offset</Radio.Button>
<Radio.Button value="custom"></Radio.Button> <Radio.Button value="custom"></Radio.Button>
</Radio.Group> </Radio.Group>
{typeValue === 'time' && offsetValue === 'custom' && {typeValue === 'time' && offsetValue === 'custom' &&
getFieldDecorator('timestamp', { getFieldDecorator('timestamp', {
rules: [{ required: false, message: '' }], rules: [{ required: false, message: '' }],
initialValue: moment(), initialValue: moment(),
})( })(
<DatePicker <DatePicker
showTime={true} showTime={true}
format={timeMinute} format={timeMinute}
@@ -109,7 +109,7 @@ class ResetOffset extends React.Component<any> {
</Col> </Col>
</Row> </Row>
<Radio value="partition"><span className="title-con"></span></Radio> <Radio value="partition"><span className="title-con"></span></Radio>
</Radio.Group> </Radio.Group>
<Row> <Row>
<Form.Item> <Form.Item>
<Row> <Row>

View File

@@ -1,5 +1,5 @@
import fetch, { formFetch } from './fetch'; import fetch, { formFetch } from './fetch';
import { IUploadFile, IUser, IQuotaModelItem, ILimitsItem, ITopic, IOrderParams, ISample, IMigration, IExecute, IEepand, IUtils, ITopicMetriceParams, IRegister, IEditTopic, IExpand, IDeleteTopic, INewRegions, INewLogical, IRebalance, INewBulidEnums, ITrigger, IApprovalOrder, IMonitorSilences, IConfigure, IBatchApproval } from 'types/base-type'; import { IUploadFile, IUser, IQuotaModelItem, ILimitsItem, ITopic, IOrderParams, ISample, IMigration, IExecute, IEepand, IUtils, ITopicMetriceParams, IRegister, IEditTopic, IExpand, IDeleteTopic, INewRegions, INewLogical, IRebalance, INewBulidEnums, ITrigger, IApprovalOrder, IMonitorSilences, IConfigure, IConfigGateway, IBatchApproval } from 'types/base-type';
import { IRequestParams } from 'types/alarm'; import { IRequestParams } from 'types/alarm';
import { apiCache } from 'lib/api-cache'; import { apiCache } from 'lib/api-cache';
@@ -442,6 +442,34 @@ export const deleteConfigure = (configKey: string) => {
}); });
}; };
export const getGatewayList = () => {
return fetch(`/rd/gateway-configs`);
};
export const getGatewayType = () => {
return fetch(`/op/gateway-configs/type-enums`);
};
export const addNewConfigGateway = (params: IConfigGateway) => {
return fetch(`/op/gateway-configs`, {
method: 'POST',
body: JSON.stringify(params),
});
};
export const editConfigGateway = (params: IConfigGateway) => {
return fetch(`/op/gateway-configs`, {
method: 'PUT',
body: JSON.stringify(params),
});
};
export const deleteConfigGateway = (params: IConfigure) => {
return fetch(`/op/gateway-configs`, {
method: 'DELETE',
body: JSON.stringify(params),
});
};
export const getDataCenter = () => { export const getDataCenter = () => {
return fetch(`/normal/configs/idc`); return fetch(`/normal/configs/idc`);
}; };
@@ -530,6 +558,23 @@ export const getControllerHistory = (clusterId: number) => {
return fetch(`/rd/clusters/${clusterId}/controller-history`); return fetch(`/rd/clusters/${clusterId}/controller-history`);
}; };
export const getCandidateController = (clusterId: number) => {
return fetch(`/rd/clusters/${clusterId}/controller-preferred-candidates`);
};
export const addCandidateController = (params:any) => {
return fetch(`/op/cluster-controller/preferred-candidates`, {
method: 'POST',
body: JSON.stringify(params),
});
};
export const deleteCandidateCancel = (params:any)=>{
return fetch(`/op/cluster-controller/preferred-candidates`, {
method: 'DELETE',
body: JSON.stringify(params),
});
}
/** /**
* 运维管控 broker * 运维管控 broker
*/ */

View File

@@ -77,7 +77,7 @@ export const getControlMetricOption = (type: IOptionType, data: IClusterMetrics[
name = '条'; name = '条';
data.map(item => { data.map(item => {
item.messagesInPerSec = item.messagesInPerSec !== null ? Number(item.messagesInPerSec.toFixed(2)) : null; item.messagesInPerSec = item.messagesInPerSec !== null ? Number(item.messagesInPerSec.toFixed(2)) : null;
}); });
break; break;
case 'brokerNum': case 'brokerNum':
case 'topicNum': case 'topicNum':
@@ -224,7 +224,7 @@ export const getClusterMetricOption = (type: IOptionType, record: IClusterMetric
name = '条'; name = '条';
data.map(item => { data.map(item => {
item.messagesInPerSec = item.messagesInPerSec !== null ? Number(item.messagesInPerSec.toFixed(2)) : null; item.messagesInPerSec = item.messagesInPerSec !== null ? Number(item.messagesInPerSec.toFixed(2)) : null;
}); });
break; break;
default: default:
const { name: unitName, data: xData } = dealFlowData(metricTypeMap[type], data); const { name: unitName, data: xData } = dealFlowData(metricTypeMap[type], data);
@@ -248,8 +248,8 @@ export const getClusterMetricOption = (type: IOptionType, record: IClusterMetric
const unitSeries = item.data[item.seriesName] !== null ? Number(item.data[item.seriesName]) : null; const unitSeries = item.data[item.seriesName] !== null ? Number(item.data[item.seriesName]) : null;
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
result += '<span style="display:inline-block;margin-right:0px;border-radius:10px;width:9px;height:9px;background-color:' + item.color + '"></span>'; result += '<span style="display:inline-block;margin-right:0px;border-radius:10px;width:9px;height:9px;background-color:' + item.color + '"></span>';
if ( (item.data.produceThrottled && item.seriesName === 'appIdBytesInPerSec') if ((item.data.produceThrottled && item.seriesName === 'appIdBytesInPerSec')
|| (item.data.consumeThrottled && item.seriesName === 'appIdBytesOutPerSec') ) { || (item.data.consumeThrottled && item.seriesName === 'appIdBytesOutPerSec')) {
return result += item.seriesName + ': ' + unitSeries + '(被限流)' + '<br>'; return result += item.seriesName + ': ' + unitSeries + '(被限流)' + '<br>';
} }
return result += item.seriesName + ': ' + unitSeries + '<br>'; return result += item.seriesName + ': ' + unitSeries + '<br>';
@@ -317,7 +317,7 @@ export const getMonitorMetricOption = (seriesName: string, data: IMetricPoint[])
if (ele.name === item.seriesName) { if (ele.name === item.seriesName) {
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
result += '<span style="display:inline-block;margin-right:0px;border-radius:10px;width:9px;height:9px;background-color:' + item.color + '"></span>'; result += '<span style="display:inline-block;margin-right:0px;border-radius:10px;width:9px;height:9px;background-color:' + item.color + '"></span>';
return result += item.seriesName + ': ' + (item.data.value === null ? '' : item.data.value.toFixed(2)) + '<br>'; return result += item.seriesName + ': ' + (item.data.value === null ? '' : item.data.value.toFixed(2)) + '<br>';
} }
}); });
}); });

View File

@@ -3,6 +3,11 @@ import { observable, action } from 'mobx';
import { getBrokersMetricsHistory } from 'lib/api'; import { getBrokersMetricsHistory } from 'lib/api';
import { IClusterMetrics } from 'types/base-type'; import { IClusterMetrics } from 'types/base-type';
const STATUS = {
PENDING: 'pending',
REJECT: 'reject',
FULLFILLED: 'fullfilled'
}
class AdminMonitor { class AdminMonitor {
@observable @observable
public currentClusterId = null as number; public currentClusterId = null as number;
@@ -33,33 +38,42 @@ class AdminMonitor {
@action.bound @action.bound
public setBrokersChartsData(data: IClusterMetrics[]) { public setBrokersChartsData(data: IClusterMetrics[]) {
this.brokersMetricsHistory = data; this.brokersMetricsHistory = data;
this.setRequestId(null); this.setRequestId(STATUS.FULLFILLED);
Promise.all(this.taskQueue).then(() => {
this.setRequestId(null);
this.taskQueue = [];
})
return data; return data;
} }
public taskQueue = [] as any[];
public getBrokersMetricsList = async (startTime: string, endTime: string) => { public getBrokersMetricsList = async (startTime: string, endTime: string) => {
if (this.requestId && this.requestId !== 'error') { if (this.requestId) {
return new Promise((res, rej) => { //逐条定时查询任务状态
window.setTimeout(() => { const p = new Promise((res, rej) => {
if (this.requestId === 'error') { const timer = window.setInterval(() => {
rej(); if (this.requestId === STATUS.REJECT) {
} else { rej(this.brokersMetricsHistory);
window.clearInterval(timer);
} else if (this.requestId === STATUS.FULLFILLED) {
res(this.brokersMetricsHistory); res(this.brokersMetricsHistory);
window.clearInterval(timer);
} }
}, 800); // TODO: 该实现方式待优化 }, (this.taskQueue.length + 1) * 100);
}); });
this.taskQueue.push(p);
return p;
} }
this.setRequestId('requesting'); this.setRequestId(STATUS.PENDING);
return getBrokersMetricsHistory(this.currentClusterId, this.currentBrokerId, startTime, endTime) return getBrokersMetricsHistory(this.currentClusterId, this.currentBrokerId, startTime, endTime)
.then(this.setBrokersChartsData).catch(() => this.setRequestId('error')); .then(this.setBrokersChartsData).catch(() => this.setRequestId(STATUS.REJECT));
} }
public getBrokersChartsData = async (startTime: string, endTime: string, reload?: boolean) => { public getBrokersChartsData = async (startTime: string, endTime: string, reload?: boolean) => {
if (this.brokersMetricsHistory && !reload) { if (this.brokersMetricsHistory && !reload) {
return new Promise(res => res(this.brokersMetricsHistory)); return new Promise(res => res(this.brokersMetricsHistory));
} }
return this.getBrokersMetricsList(startTime, endTime); return this.getBrokersMetricsList(startTime, endTime);
} }
} }

View File

@@ -1,5 +1,5 @@
import { observable, action } from 'mobx'; import { observable, action } from 'mobx';
import { INewBulidEnums, ILabelValue, IClusterReal, IOptionType, IClusterMetrics, IClusterTopics, IKafkaFiles, IMetaData, IConfigure, IBrokerData, IOffset, IController, IBrokersBasicInfo, IBrokersStatus, IBrokersTopics, IBrokersPartitions, IBrokersAnalysis, IAnalysisTopicVO, IBrokersMetadata, IBrokersRegions, IThrottles, ILogicalCluster, INewRegions, INewLogical, ITaskManage, IPartitionsLocation, ITaskType, ITasksEnums, ITasksMetaData, ITaskStatusDetails, IKafkaRoles, IEnumsMap, IStaffSummary, IBill, IBillDetail } from 'types/base-type'; import { INewBulidEnums, ILabelValue, IClusterReal, IOptionType, IClusterMetrics, IClusterTopics, IKafkaFiles, IMetaData, IConfigure, IConfigGateway, IBrokerData, IOffset, IController, IBrokersBasicInfo, IBrokersStatus, IBrokersTopics, IBrokersPartitions, IBrokersAnalysis, IAnalysisTopicVO, IBrokersMetadata, IBrokersRegions, IThrottles, ILogicalCluster, INewRegions, INewLogical, ITaskManage, IPartitionsLocation, ITaskType, ITasksEnums, ITasksMetaData, ITaskStatusDetails, IKafkaRoles, IEnumsMap, IStaffSummary, IBill, IBillDetail } from 'types/base-type';
import { import {
deleteCluster, deleteCluster,
getBasicInfo, getBasicInfo,
@@ -12,7 +12,12 @@ import {
getConfigure, getConfigure,
addNewConfigure, addNewConfigure,
editConfigure, editConfigure,
addNewConfigGateway,
deleteConfigure, deleteConfigure,
getGatewayList,
getGatewayType,
editConfigGateway,
deleteConfigGateway,
getDataCenter, getDataCenter,
getClusterBroker, getClusterBroker,
getClusterConsumer, getClusterConsumer,
@@ -49,6 +54,9 @@ import {
getStaffSummary, getStaffSummary,
getBillStaffSummary, getBillStaffSummary,
getBillStaffDetail, getBillStaffDetail,
getCandidateController,
addCandidateController,
deleteCandidateCancel
} from 'lib/api'; } from 'lib/api';
import { getControlMetricOption, getClusterMetricOption } from 'lib/line-charts-config'; import { getControlMetricOption, getClusterMetricOption } from 'lib/line-charts-config';
@@ -59,6 +67,7 @@ import { transBToMB } from 'lib/utils';
import moment from 'moment'; import moment from 'moment';
import { timestore } from './time'; import { timestore } from './time';
import { message } from 'component/antd';
class Admin { class Admin {
@observable @observable
@@ -97,6 +106,12 @@ class Admin {
@observable @observable
public configureList: IConfigure[] = []; public configureList: IConfigure[] = [];
@observable
public configGatewayList: IConfigGateway[] = [];
@observable
public gatewayType: [];
@observable @observable
public dataCenterList: string[] = []; public dataCenterList: string[] = [];
@@ -142,6 +157,12 @@ class Admin {
@observable @observable
public controllerHistory: IController[] = []; public controllerHistory: IController[] = [];
@observable
public controllerCandidate: IController[] = [];
@observable
public filtercontrollerCandidate: string = '';
@observable @observable
public brokersPartitions: IBrokersPartitions[] = []; public brokersPartitions: IBrokersPartitions[] = [];
@@ -152,7 +173,7 @@ class Admin {
public brokersAnalysisTopic: IAnalysisTopicVO[] = []; public brokersAnalysisTopic: IAnalysisTopicVO[] = [];
@observable @observable
public brokersMetadata: IBrokersMetadata[] = []; public brokersMetadata: IBrokersMetadata[] | any = [];
@observable @observable
public brokersRegions: IBrokersRegions[] = []; public brokersRegions: IBrokersRegions[] = [];
@@ -206,10 +227,10 @@ class Admin {
public kafkaRoles: IKafkaRoles[]; public kafkaRoles: IKafkaRoles[];
@observable @observable
public controlType: IOptionType = 'byteIn/byteOut' ; public controlType: IOptionType = 'byteIn/byteOut';
@observable @observable
public type: IOptionType = 'byteIn/byteOut' ; public type: IOptionType = 'byteIn/byteOut';
@observable @observable
public currentClusterId = null as number; public currentClusterId = null as number;
@@ -241,7 +262,7 @@ class Admin {
@action.bound @action.bound
public setClusterRealTime(data: IClusterReal) { public setClusterRealTime(data: IClusterReal) {
this.clusterRealData = data; this.clusterRealData = data;
this.getRealClusterLoading(false); this.getRealClusterLoading(false);
} }
@@ -284,7 +305,7 @@ class Admin {
return { return {
...item, ...item,
label: item.fileName, label: item.fileName,
value: item.fileName + ',' + item.fileMd5, value: item.fileName + ',' + item.fileMd5,
}; };
})); }));
} }
@@ -306,6 +327,20 @@ class Admin {
}) : []; }) : [];
} }
@action.bound
public setConfigGatewayList(data: IConfigGateway[]) {
this.configGatewayList = data ? data.map((item, index) => {
item.key = index;
return item;
}) : [];
}
@action.bound
public setConfigGatewayType(data: any) {
this.setLoading(false);
this.gatewayType = data || [];
}
@action.bound @action.bound
public setDataCenter(data: string[]) { public setDataCenter(data: string[]) {
this.dataCenterList = data || []; this.dataCenterList = data || [];
@@ -335,6 +370,17 @@ class Admin {
}) : []; }) : [];
} }
@action.bound
public setCandidateController(data: IController[]) {
this.controllerCandidate = data ? data.map((item, index) => {
item.key = index;
return item;
}) : [];
this.filtercontrollerCandidate = data?data.map((item,index)=>{
return item.brokerId
}).join(','):''
}
@action.bound @action.bound
public setBrokersBasicInfo(data: IBrokersBasicInfo) { public setBrokersBasicInfo(data: IBrokersBasicInfo) {
this.brokersBasicInfo = data; this.brokersBasicInfo = data;
@@ -356,10 +402,10 @@ class Admin {
this.replicaStatus = data.brokerReplicaStatusList.slice(1); this.replicaStatus = data.brokerReplicaStatusList.slice(1);
this.bytesInStatus.forEach((item, index) => { this.bytesInStatus.forEach((item, index) => {
this.peakValueList.push({ name: peakValueMap[index], value: item}); this.peakValueList.push({ name: peakValueMap[index], value: item });
}); });
this.replicaStatus.forEach((item, index) => { this.replicaStatus.forEach((item, index) => {
this.copyValueList.push({name: copyValueMap[index], value: item}); this.copyValueList.push({ name: copyValueMap[index], value: item });
}); });
} }
@@ -415,16 +461,16 @@ class Admin {
} }
@action.bound @action.bound
public setBrokersMetadata(data: IBrokersMetadata[]) { public setBrokersMetadata(data: IBrokersMetadata[]|any) {
this.brokersMetadata = data ? data.map((item, index) => { this.brokersMetadata = data ? data.map((item:any, index:any) => {
item.key = index; item.key = index;
return { return {
...item, ...item,
text: `${item.host} BrokerID${item.brokerId}`, text: `${item.host} BrokerID${item.brokerId}`,
label: item.host, label: item.host,
value: item.brokerId, value: item.brokerId,
}; };
}) : []; }) : [];
} }
@action.bound @action.bound
@@ -461,9 +507,9 @@ class Admin {
@action.bound @action.bound
public setLogicalClusters(data: ILogicalCluster[]) { public setLogicalClusters(data: ILogicalCluster[]) {
this.logicalClusters = data ? data.map((item, index) => { this.logicalClusters = data ? data.map((item, index) => {
item.key = index; item.key = index;
return item; return item;
}) : []; }) : [];
} }
@action.bound @action.bound
@@ -474,25 +520,25 @@ class Admin {
@action.bound @action.bound
public setClustersThrottles(data: IThrottles[]) { public setClustersThrottles(data: IThrottles[]) {
this.clustersThrottles = data ? data.map((item, index) => { this.clustersThrottles = data ? data.map((item, index) => {
item.key = index; item.key = index;
return item; return item;
}) : []; }) : [];
} }
@action.bound @action.bound
public setPartitionsLocation(data: IPartitionsLocation[]) { public setPartitionsLocation(data: IPartitionsLocation[]) {
this.partitionsLocation = data ? data.map((item, index) => { this.partitionsLocation = data ? data.map((item, index) => {
item.key = index; item.key = index;
return item; return item;
}) : []; }) : [];
} }
@action.bound @action.bound
public setTaskManagement(data: ITaskManage[]) { public setTaskManagement(data: ITaskManage[]) {
this.taskManagement = data ? data.map((item, index) => { this.taskManagement = data ? data.map((item, index) => {
item.key = index; item.key = index;
return item; return item;
}) : []; }) : [];
} }
@action.bound @action.bound
@@ -568,7 +614,7 @@ class Admin {
return deleteCluster(clusterId).then(() => this.getMetaData(true)); return deleteCluster(clusterId).then(() => this.getMetaData(true));
} }
public getPeakFlowChartData(value: ILabelValue[], map: string []) { public getPeakFlowChartData(value: ILabelValue[], map: string[]) {
return getPieChartOption(value, map); return getPieChartOption(value, map);
} }
@@ -627,6 +673,30 @@ class Admin {
deleteConfigure(configKey).then(() => this.getConfigure()); deleteConfigure(configKey).then(() => this.getConfigure());
} }
public getGatewayList() {
getGatewayList().then(this.setConfigGatewayList);
}
public getGatewayType() {
this.setLoading(true);
getGatewayType().then(this.setConfigGatewayType);
}
public addNewConfigGateway(params: IConfigGateway) {
return addNewConfigGateway(params).then(() => this.getGatewayList());
}
public editConfigGateway(params: IConfigGateway) {
return editConfigGateway(params).then(() => this.getGatewayList());
}
public deleteConfigGateway(params: any) {
deleteConfigGateway(params).then(() => {
// message.success('删除成功')
this.getGatewayList()
});
}
public getDataCenter() { public getDataCenter() {
getDataCenter().then(this.setDataCenter); getDataCenter().then(this.setDataCenter);
} }
@@ -643,6 +713,20 @@ class Admin {
return getControllerHistory(clusterId).then(this.setControllerHistory); return getControllerHistory(clusterId).then(this.setControllerHistory);
} }
public getCandidateController(clusterId: number) {
return getCandidateController(clusterId).then(data=>{
return this.setCandidateController(data)
});
}
public addCandidateController(clusterId: number, brokerIdList: any) {
return addCandidateController({clusterId, brokerIdList}).then(()=>this.getCandidateController(clusterId));
}
public deleteCandidateCancel(clusterId: number, brokerIdList: any){
return deleteCandidateCancel({clusterId, brokerIdList}).then(()=>this.getCandidateController(clusterId));
}
public getBrokersBasicInfo(clusterId: number, brokerId: number) { public getBrokersBasicInfo(clusterId: number, brokerId: number) {
return getBrokersBasicInfo(clusterId, brokerId).then(this.setBrokersBasicInfo); return getBrokersBasicInfo(clusterId, brokerId).then(this.setBrokersBasicInfo);
} }

View File

@@ -181,6 +181,7 @@ class Alarm {
public modifyMonitorStrategy(params: IRequestParams) { public modifyMonitorStrategy(params: IRequestParams) {
return modifyMonitorStrategy(params).then(() => { return modifyMonitorStrategy(params).then(() => {
message.success('操作成功'); message.success('操作成功');
window.location.href = `${urlPrefix}/alarm`;
}).finally(() => this.setLoading(false)); }).finally(() => this.setLoading(false));
} }

View File

@@ -19,6 +19,9 @@ export class Users {
@observable @observable
public staff: IStaff[] = []; public staff: IStaff[] = [];
@observable
public newPassWord: any = null;
@action.bound @action.bound
public setAccount(data: IUser) { public setAccount(data: IUser) {
setCookie([{ key: 'role', value: `${data.role}`, time: 1 }]); setCookie([{ key: 'role', value: `${data.role}`, time: 1 }]);
@@ -42,6 +45,11 @@ export class Users {
this.loading = value; this.loading = value;
} }
@action.bound
public setNewPassWord(value: boolean) {
this.newPassWord = value;
}
public getAccount() { public getAccount() {
getAccount().then(this.setAccount); getAccount().then(this.setAccount);
} }

View File

@@ -190,6 +190,7 @@ export interface IUser {
chineseName?: string; chineseName?: string;
department?: string; department?: string;
key?: number; key?: number;
confirmPassword?:string
} }
export interface IOffset { export interface IOffset {
@@ -486,6 +487,17 @@ export interface IConfigure {
key?: number; key?: number;
} }
export interface IConfigGateway {
id: number;
key?: number;
modifyTime: number;
name: string;
value: string;
version: string;
type: string;
description: string;
}
export interface IEepand { export interface IEepand {
brokerIdList: number[]; brokerIdList: number[];
clusterId: number; clusterId: number;
@@ -650,8 +662,10 @@ export interface IBrokerData {
export interface IController { export interface IController {
brokerId: number; brokerId: number;
host: string; host: string;
timestamp: number; timestamp?: number;
version: number; version?: number;
startTime?: number;
status?: number;
key?: number; key?: number;
} }