V2.4.1 FE

This commit is contained in:
孙超
2021-04-25 20:43:20 +08:00
parent 2672502c07
commit 47b8fe5022
63 changed files with 1558 additions and 329 deletions

View File

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

View File

@@ -1,5 +1,5 @@
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 {
deleteCluster,
getBasicInfo,
@@ -9,10 +9,16 @@ import {
getTopicsBasicInfo,
getTasksKafkaFiles,
getMetaData,
getOperationRecordData,
getConfigure,
addNewConfigure,
editConfigure,
addNewConfigGateway,
deleteConfigure,
getGatewayList,
getGatewayType,
editConfigGateway,
deleteConfigGateway,
getDataCenter,
getClusterBroker,
getClusterConsumer,
@@ -49,6 +55,9 @@ import {
getStaffSummary,
getBillStaffSummary,
getBillStaffDetail,
getCandidateController,
addCandidateController,
deleteCandidateCancel
} from 'lib/api';
import { getControlMetricOption, getClusterMetricOption } from 'lib/line-charts-config';
@@ -59,6 +68,7 @@ import { transBToMB } from 'lib/utils';
import moment from 'moment';
import { timestore } from './time';
import { message } from 'component/antd';
class Admin {
@observable
@@ -94,9 +104,23 @@ class Admin {
@observable
public metaList: IMetaData[] = [];
@observable
public oRList: any[] = [];
@observable
public oRparams:any={
moduleId:0
};
@observable
public configureList: IConfigure[] = [];
@observable
public configGatewayList: IConfigGateway[] = [];
@observable
public gatewayType: [];
@observable
public dataCenterList: string[] = [];
@@ -142,6 +166,12 @@ class Admin {
@observable
public controllerHistory: IController[] = [];
@observable
public controllerCandidate: IController[] = [];
@observable
public filtercontrollerCandidate: string = '';
@observable
public brokersPartitions: IBrokersPartitions[] = [];
@@ -152,7 +182,7 @@ class Admin {
public brokersAnalysisTopic: IAnalysisTopicVO[] = [];
@observable
public brokersMetadata: IBrokersMetadata[] = [];
public brokersMetadata: IBrokersMetadata[] | any = [];
@observable
public brokersRegions: IBrokersRegions[] = [];
@@ -206,10 +236,10 @@ class Admin {
public kafkaRoles: IKafkaRoles[];
@observable
public controlType: IOptionType = 'byteIn/byteOut' ;
public controlType: IOptionType = 'byteIn/byteOut';
@observable
public type: IOptionType = 'byteIn/byteOut' ;
public type: IOptionType = 'byteIn/byteOut';
@observable
public currentClusterId = null as number;
@@ -241,7 +271,7 @@ class Admin {
@action.bound
public setClusterRealTime(data: IClusterReal) {
this.clusterRealData = data;
this.clusterRealData = data;
this.getRealClusterLoading(false);
}
@@ -284,7 +314,7 @@ class Admin {
return {
...item,
label: item.fileName,
value: item.fileName + ',' + item.fileMd5,
value: item.fileName + ',' + item.fileMd5,
};
}));
}
@@ -298,6 +328,15 @@ class Admin {
}) : [];
}
@action.bound
public setOperationRecordList(data:any){
this.setLoading(false);
this.oRList = data ? data.map((item:any, index: any) => {
item.key = index;
return item;
}) : [];
}
@action.bound
public setConfigure(data: IConfigure[]) {
this.configureList = data ? data.map((item, index) => {
@@ -306,6 +345,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
public setDataCenter(data: string[]) {
this.dataCenterList = data || [];
@@ -335,6 +388,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
public setBrokersBasicInfo(data: IBrokersBasicInfo) {
this.brokersBasicInfo = data;
@@ -356,10 +420,10 @@ class Admin {
this.replicaStatus = data.brokerReplicaStatusList.slice(1);
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.copyValueList.push({name: copyValueMap[index], value: item});
this.copyValueList.push({ name: copyValueMap[index], value: item });
});
}
@@ -415,16 +479,16 @@ class Admin {
}
@action.bound
public setBrokersMetadata(data: IBrokersMetadata[]) {
this.brokersMetadata = data ? data.map((item, index) => {
item.key = index;
return {
...item,
text: `${item.host} BrokerID${item.brokerId}`,
label: item.host,
value: item.brokerId,
};
}) : [];
public setBrokersMetadata(data: IBrokersMetadata[]|any) {
this.brokersMetadata = data ? data.map((item:any, index:any) => {
item.key = index;
return {
...item,
text: `${item.host} BrokerID${item.brokerId}`,
label: item.host,
value: item.brokerId,
};
}) : [];
}
@action.bound
@@ -461,9 +525,9 @@ class Admin {
@action.bound
public setLogicalClusters(data: ILogicalCluster[]) {
this.logicalClusters = data ? data.map((item, index) => {
item.key = index;
return item;
}) : [];
item.key = index;
return item;
}) : [];
}
@action.bound
@@ -474,25 +538,25 @@ class Admin {
@action.bound
public setClustersThrottles(data: IThrottles[]) {
this.clustersThrottles = data ? data.map((item, index) => {
item.key = index;
return item;
}) : [];
item.key = index;
return item;
}) : [];
}
@action.bound
public setPartitionsLocation(data: IPartitionsLocation[]) {
this.partitionsLocation = data ? data.map((item, index) => {
item.key = index;
return item;
}) : [];
item.key = index;
return item;
}) : [];
}
@action.bound
public setTaskManagement(data: ITaskManage[]) {
this.taskManagement = data ? data.map((item, index) => {
item.key = index;
return item;
}) : [];
item.key = index;
return item;
}) : [];
}
@action.bound
@@ -568,7 +632,7 @@ class Admin {
return deleteCluster(clusterId).then(() => this.getMetaData(true));
}
public getPeakFlowChartData(value: ILabelValue[], map: string []) {
public getPeakFlowChartData(value: ILabelValue[], map: string[]) {
return getPieChartOption(value, map);
}
@@ -611,6 +675,12 @@ class Admin {
getMetaData(needDetail).then(this.setMetaList);
}
public getOperationRecordData(params: any) {
this.setLoading(true);
this.oRparams = params
getOperationRecordData(params).then(this.setOperationRecordList);
}
public getConfigure() {
getConfigure().then(this.setConfigure);
}
@@ -627,6 +697,30 @@ class Admin {
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() {
getDataCenter().then(this.setDataCenter);
}
@@ -643,6 +737,20 @@ class Admin {
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) {
return getBrokersBasicInfo(clusterId, brokerId).then(this.setBrokersBasicInfo);
}

View File

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

View File

@@ -31,6 +31,12 @@ class CustomModal {
this.params = value;
}
@action.bound
public showOfflineAppNewModal(value: any) {
this.modalId = 'offlineAppNewModal';
this.params = value;
}
@action.bound
public showOrderOpResult() {
this.modalId = 'orderOpResult';

View File

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