Newer
Older
import {AfterViewInit, Component, ElementRef, OnInit, Renderer, ViewChild,} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {OverAllService} from '../../overAll.service';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {NzMessageService} from 'ng-zorro-antd';
import {BasiCheckComponent} from '../../../modal/basi-check/basi-check.component';
import {NzModalService} from 'ng-zorro-antd';
import {pageSize} from '../../../app.constants';
import {WarnListComponent} from '../../../modal/warn-list/warn-list.component';
selector: 'jhi-basic-detail',
templateUrl: './basic-detail.component.html',
styles: [
`
.checkTags {
position: absolute;
@ViewChild('thirdTabs') thirdTabs: ElementRef;
@ViewChild('warnList') warnList: WarnListComponent;
chartOption1;
responseTimeStr;
losedStr;
cpuUsedStr;
usedStr;
chartOption2;
chartOption3;
chartOption4;
secondOptionLeft;
secondOptionRight;
dataSet: any[];
panel1 = {active: true, name: '响应时间与丢包率', disabled: false};
panel2 = {active: true, name: 'CPU使用率及内存使用率'};
panel3 = {active: true, name: '磁盘使用率', disabled: false};
disable: '',
enable: '',
error: '',
warning: '',
hostid: ''
};
keyType = '1';
//图表
isGrapha = false;
chartOptionGrapha;
constructor(private routerInfo: ActivatedRoute, private message: NzMessageService,
private fb: FormBuilder, private modalService: NzModalService) {
}
ngOnInit() {
this.routerInfo.queryParams.subscribe(queryParams => {
this.hostId = queryParams.hostId;
this.hostType = queryParams.type;
});
this.responseTime();
this.losed();
this.cpused();
this.disks();
this.used();
this.inOutInfo();
//监测点
this.getCheckList();
this.getCheckStatus();
this.findItemType();
//历史告警
const obj = {};
this.warnList.getList(obj);
}
ngAfterViewInit() {
// this.renderer.setElementStyle(this.thirdTabs.nativeElement,'margin-left','108px');
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
responseTime() {
this.overAllSer.responseTime(this.hostId).subscribe(
(res) => {
if (res.errCode == 10000) {
this.responseTimeStr = res.data.responseTime;
const responseTime = res.data.responseTime;
const other = 100 - res.data.responseTime;
const data = [
{value: responseTime},
{value: other},
{
value: 100, name: '', tooltip: {
formatter: function(a) {
return '';
}
}
}
];
this.chartOption1 = {
title: {
text: '平均响应时间',
top: '5%',
left: '38%',
textStyle: {
color: '#999',
fontSize: 12,
}
},
tooltip: {
trigger: 'item',
show: false,
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
color: ['#7eb6ea', '#eeeeee', 'transparent'],
series: [
{
type: 'pie',
startAngle: 180,
radius: ['50%', '85%'],
center: ['50%', '75%'],
hoverAnimation: true,
data: data,
itemStyle: {
normal: {
show: false,
position: 'center'
},
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
labelLine: {
normal: {
show: false
}
},
}
]
};
} else {
this.message.info(res.errMsg);
}
}
);
this.losedStr = res.data.losed;
const losed = res.data.losed;
const other = 100 - res.data.losed;
const data = [
{value: losed},
{value: other},
{
value: 100, name: '', tooltip: {
formatter: function(a) {
return '';
}
}
}
itemStyle: {
normal: {
show: false,
position: 'center'
},
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
labelLine: {
normal: {
show: false
}
},
}
]
};
this.cpuUsedStr = res.data.cpuUsed;
const losed = res.data.cpuUsed;
const other = 100 - res.data.cpuUsed;
const data = [
{value: losed},
{value: other},
{
value: 100, name: '', tooltip: {
formatter: function(a) {
return '';
}
}
}
itemStyle: {
normal: {
show: false,
position: 'center'
},
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
labelLine: {
normal: {
show: false
}
},
}
]
};
this.usedStr = res.data.used;
const used = res.data.used;
const other = 100 - res.data.used;
const data = [
{value: used},
{value: other},
{
value: 100, name: '', tooltip: {
formatter: function(a) {
return '';
}
}
}
itemStyle: {
normal: {
show: false,
position: 'center'
},
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
labelLine: {
normal: {
show: false
}
},
}
]
};
series: [
{
name: '已使用',
type: 'bar',
stack: '总空间',
label: {
normal: {
show: true,
position: 'insideRight',
formatter: (obj) => {
const item = (res.data.disks[obj.dataIndex].used / (1024 * 1024 * 1024)).toFixed(2);
return item + 'G';
}
}
},
itemStyle: {
normal: {
color: '#3194e0'
},
},
data: res.data.disks.map((item) => {
const pre = (item.used / item.total) * 100; //已使用百分比
return pre;
})
},
{
name: '剩余空间',
type: 'bar',
stack: '总空间',
label: {
normal: {
show: true,
position: 'insideRight',
const cut = (res.data.disks[obj.dataIndex].total - res.data.disks[obj.dataIndex].used);
const item = (cut / (1024 * 1024 * 1024)).toFixed(2);
return item + 'G';
}
}
},
itemStyle: {
normal: {
color: '#bfbfbf'
},
},
data: res.data.disks.map((item) => {
const pre = (item.total - item.used) / (item.total) * 100; //剩余百分比
// const use = (item.total - item.used)/(1024*1024*1024); //剩余空间
// const surplus = use.toFixed(2);
return pre;
})
},
]
};
return item.used;
});
used = this.add(used);
this.secondOptionRight = {
data: [total, used],
itemStyle: {
normal: {
label: {
position: 'inner',
}
},
labelLine: {
normal: {
show: false
}
},
}
]
};
add(arr) {
let total = 0;
for (let i = 0; i < arr.length; i++) {
total += arr[i];
}
return (total / 1024 / 1024 / 1024).toFixed(2);
getCheckList() {
this.loading = true;
const data = {
hostid: this.hostId,
pageNum: this.pageIndex,
pageCount: pageSize,
applicationid: this.applicationId,
};
(res) => {
this.checkList = res.data.data;
this.totalNum = res.data.totalNum;
);
}
//分页
change(e) {
this.pageIndex = e;
this.getCheckList();
}
changeType(type) {
this.pageIndex = 1;
this.applicationId = type;
this.getCheckList();
getCheckStatus() {
this.overAllSer.findItemCount(this.hostId).subscribe(
(res) => {
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该监测点吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
showImageModal(data) {
this.isGrapha = true;
const data1 = {
date: '2018-10-20',
itemid: data.itemid
};
this.overAllSer.findGraphData(data1).subscribe(
(res) => {
if (res.errCode == 10000 && res.data.length > 0) {
const result = res.data;
this.chartOptionGrapha = {
title: {
text: data.itemName
},
tooltip: {
trigger: 'axis'
},
xAxis: {
data: result.map((item) => {
return item.time;
})
},
yAxis: {
splitLine: {
show: false
}
},
dataZoom: [{
startValue: '2014-06-01'
}, {
type: 'inside'
}],
series: {
type: 'line',
data: result.map((item) => {
return item.value;
}),
}
};
}
}
);
findItemType() {
const data = {
'hostids': []
};
data.hostids.push(this.hostId);
this.overAllSer.findItemType(data).subscribe(
(res) => {
this.itemTypeList = res.data;
}
);
updateItem(itemid, status) {
const data = {
'status': status,
'itemid': itemid
};
nzTitle: '',
nzContent: '<b style="color: red;">确认修改监控项状态吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {