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 {WarnListComponent} from '../../../modal/warn-list/warn-list.component';
selector: 'jhi-basic-detail',
templateUrl: './basic-detail.component.html',
styles: [
`
.checkTags {
position: absolute;
.time-select{
position: absolute;
top: 55px;
right: 15px;
z-index: 999;
}
:host ::ng-deep .tabs-smart .ant-tabs-nav-scroll div.ant-tabs-tab:nth-child(3){
margin-right: 150px;
}
@ViewChild('thirdTabs') thirdTabs: ElementRef;
@ViewChild('warnList') warnList: WarnListComponent;
@ViewChild('colorEle') colorEle:ElementRef;
@ViewChild('checkEle') checkEle:ElementRef;
chartOption1;
responseTimeStr;
losedStr;
cpuUsedStr;
usedStr;
chartOption2;
chartOption3;
chartOption4;
secondOptionLeft;
secondOptionRight;
dataSet: any[];
panel1 = {active: true, name: '响应时间与丢包率', disabled: false};
constructor(private routerInfo: ActivatedRoute, private message: NzMessageService,
private fb: FormBuilder, private modalService: NzModalService,private datePipe:DatePipe) {
}
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();
//监测点
//历史告警
const obj = {};
this.warnList.getList(obj);
}
ngAfterViewInit() {
console.log(this.colorEle.nativeElement.offsetWidth);
this.checkEle.nativeElement.children[1].children[0].children[0].children[2].children[0].children[0].children[2].style.marginRight = this.colorEle.nativeElement.offsetWidth +'px';
console.log(this.checkEle.nativeElement.children[1].children[0].children[0].children[2].children[0].children[0].children[2].style.marginRight);
responseTime() {
this.overAllSer.responseTime(this.hostId).subscribe(
(res) => {
if (res.errCode == 10000) {
this.responseTimeStr = res.data.responseTime.toFixed(2);
const responseTime = this.responseTimeStr;
const other = 100 - this.responseTimeStr;
const data = [
{value: responseTime},
{value: other},
{
value: 100, name: '', tooltip: {
formatter: function(a) {
return '';
}
}
}
];
this.chartOption1 = {
title: {
text: '平均响应时间',
top: '5%',
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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'
},
},
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'
},
},
const pre = ( (item.total - item.used) / (item.total) * 100 ).toFixed(2); //剩余百分比
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);
const data = {
obj:{
hostid:Number(this.hostId)
},
pageNum:this.pageNum,
pageCount:this.pageSize
}
this.overAllSer.inOutInfoSnmp(data).subscribe(
this.smartCheck.showAddModal(this.hostId);
}
//编辑监测点
showEditModal(item){
this.smartCheck.showEditModal(this.hostId,item.itemid);
//添加or编辑监测点 之后
getList(){
this.getCheckList();
this.getCheckStatus();
this.findItemType();
}
getCheckList() {
this.loading = true;
const data = {
pageNum: this.pageIndex,
pageCount: pageSize,
obj:{
applicationid: this.applicationId,
hostid: this.hostId,
}
(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: () => {
const data = {
params:[item.itemid]
};
this.overAllSer.deleteItem(data).subscribe(
this.selectGraphadata = data;
this.getGraphDate();
}
//获取图表数据
getGraphDate(){
const data = {
date: this.datePipe.transform(this.imageSelectDate,'yyyy-MM-dd'),
itemid: this.selectGraphadata.itemid
(res) => {
if (res.errCode == 10000 && res.data.length > 0) {
const result = res.data;
this.chartOptionGrapha = {
title: {
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
},
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;
const data = {
applicationid:'',
name:'全部'
}
this.itemTypeList.push(data);
updateItem(itemid, status) {
const data = {
'status': status,
'itemid': itemid
};
nzTitle: '',
nzContent: '<b style="color: red;">确认修改监控项状态吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {