Newer
Older
import {AfterViewInit, Component, ElementRef, OnInit, Renderer2, ViewChild} from '@angular/core';
import {AlarmService} from '../alarm/alarm.service';
import {NzMessageService} from 'ng-zorro-antd';
import {LayoutService} from '../layouts/layout.service';
import {SelectGroupComponent} from '../modal/select-group/select-group.component';
import {CommonService} from '../shared/common/common.service';
import {AnalysisService} from '../analysis/analysis.service';
import {TopologyViewComponent} from '../component/topology-view/topology-view.component';
@Component({
selector: 'jhi-home',
templateUrl: './home.component.html',
styleUrls: [
'home.css'
]
})
@ViewChild('smartTopologyView') smartTopologyView: TopologyViewComponent;
{'label': '最近一天', value: '2'},
{'label': '最近三天', value: '3'},
{'label': '最近一周', value: '4'},
];
leftTwoData = {
high: 0,
warning: 0,
normal: 0,
disabled: 0,
flowListNum; //接口流量排行 数值
flowListPre; //发送利用率排名 百分比
countOrderList; //cpu内存使用率排名列表
isTrendLoading = false;
trendObj = {
startTime: '',
endTime: ''
};
dataSet; //拓扑图
topoId;
private overAllSer: OverAllService, private message: NzMessageService,
private alarmSer: AlarmService, private renderer: Renderer2,
private eventManager: JhiEventManager, private analysisSer: AnalysisService,
private router: Router, private commonSer: CommonService,
this.flowRankNum();
this.flowRankPre();
this.countOrde();
//获取分组
getGroup() {
this.overAllSer.findGroup().subscribe(
(res) => {
this.groupList = res.data;
this.obj.leftGroupId = this.groupList[0].groupid;
this.countGroupItem();
}
//获取拓扑图列表
getList() {
this.topologySer.findAll().subscribe(
(res) => {
if (res.errCode == 10000) {
this.dataSet = res.data;
}
}
);
}
this.layoutSer.findHostCountByStatusByGroup(this.obj.leftGroupId).subscribe(
this.setLeftOne(res.data);
}
);
this.layoutSer.findItemStatisticsByGroupid(this.obj.leftGroupId).subscribe(
this.leftOneTotal = data.disabled + data.high + data.normal + data.warning;
if (this.leftOneData.high > 0) {
let a: any = (this.leftOneData.high / this.leftOneTotal) * 100;
if (this.leftOneData.warning > 0) {
let b: any = ((this.leftOneData.warning / this.leftOneTotal) * 100);
this.leftOneDataPre.warningPer = b.toFixed(2);
if (this.leftOneData.normal > 0) {
let c: any = ((this.leftOneData.normal / this.leftOneTotal) * 100);
this.leftOneDataPre.normalPer = c.toFixed(2);
if (this.leftOneData.disabled > 0) {
let d: any = ((this.leftOneData.disabled / this.leftOneTotal) * 100);
this.leftOneDataPre.disabledPer = d.toFixed(2);
fontWeight: 'normal',
},
subtextStyle: {
color: '#de4751',
fontSize: 12
}
},
tooltip: {
trigger: 'item',
label: {
normal: {
show: false,
position: 'center'
}
},
labelLine: {
normal: {
show: false
}
},
data: [
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
}
this.leftTwoTotal = data.disabled + data.high + data.normal + data.warning;
if (this.leftTwoData.high > 0) {
let w: any = ((this.leftTwoData.high / this.leftTwoTotal) * 100);
if (this.leftTwoData.warning > 0) {
let x: any = ((this.leftTwoData.warning / this.leftTwoTotal) * 100);
this.leftTwoDataPre.warningPer = x.toFixed(2);
if (this.leftTwoData.normal > 0) {
let y: any = ((this.leftTwoData.normal / this.leftTwoTotal) * 100);
if (this.leftTwoData.disabled > 0) {
let z: any = ((this.leftTwoData.disabled / this.leftTwoTotal) * 100);
fontWeight: 'normal',
},
subtextStyle: {
color: '#de4751',
fontSize: 12
}
},
tooltip: {
trigger: 'item',
label: {
normal: {
show: false,
position: 'center'
}
},
labelLine: {
normal: {
show: false
}
},
data: [
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
};
return arr;
}),
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
return arr;
}),
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
startTime: this.trendObj.startTime,
endTime: this.trendObj.endTime,
};
(res) => {
if (res.errCode == 10000) {
if (res.data.length > 0) {
const response = res.data;
this.setAlarmTrend(response);
} else {
//设置告警趋势echarts图表
setAlarmTrend(data) {
this.charTrendOption = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
},
legend: {
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
minInterval: 1,
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
axisLabel: {
show: true,
interval: 'auto',
formatter: '{value} 个'
},
],
series: [
{
name: '严重',
type: 'bar',
stack: '严重',
return e.errorcount;
})
},
{
name: '告警',
type: 'bar',
stack: '告警',
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
const nowDate = new Date().getTime();
let day1, day2;
switch (this.timeTypeTrend) {
case'1': {
day1 = nowDate - 1 * 60 * 60 * 1000;
this.trendObj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.trendObj.endTime = this.datePipe.transform(nowDate, 'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'2': {
day1 = nowDate - 1 * 24 * 60 * 60 * 1000;
this.trendObj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.trendObj.endTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'3': {
day1 = nowDate - 3 * 24 * 60 * 60 * 1000;
day2 = nowDate;
this.trendObj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.trendObj.endTime = this.datePipe.transform(day2, 'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'4': {
day1 = nowDate - 7 * 24 * 60 * 60 * 1000;
day2 = nowDate;
this.trendObj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.trendObj.endTime = this.datePipe.transform(day2, 'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'5': {
break;
}
}
this.getAlarmTrend();
}
//查询拓扑图
getDetail(e) {
console.log(e);
this.smartTopologyView.getDetail(e);