Commit 5cca4a59 authored by wangqinghua's avatar wangqinghua

2019.1.12

parent 730987ee
......@@ -62,7 +62,7 @@
</div>
</div>
<nz-spin [nzSpinning]="isLoading">
<div echarts [options]="chartOption" style="height: 400px;width: 100%"></div>
<div echarts [options]="chartOption" (chartInit)="onEchartInit($event)" style="height: 400px;width: 100%"></div>
</nz-spin>
<nz-tabset [nzTabPosition]="'top'" [nzType]="'card'">
<nz-tab nzTitle="接收流量排行">
......
......@@ -4,9 +4,8 @@ import {OverAllService} from '../../overAll/overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
import {pageSize} from '../../app.constants';
import {DatePipe} from '@angular/common';
import { setInterval, clearInterval } from 'timers';
declare var vis: any;
import {setInterval, clearInterval} from 'timers';
import { NgxEchartsModule } from 'ngx-echarts';
@Component({
selector: 'smart-flow-trend',
......@@ -23,6 +22,7 @@ export class FlowTrendComponent implements OnInit, OnDestroy {
startTime: '',
endTime: ''
};
echartObj;
//in
inList = [];
......@@ -60,6 +60,10 @@ export class FlowTrendComponent implements OnInit, OnDestroy {
this.getGroup();
}
onEchartInit(e){
this.echartObj = e;
}
//获取分组
getGroup() {
this.overAllSer.getgroups({}).subscribe(
......@@ -89,9 +93,9 @@ export class FlowTrendComponent implements OnInit, OnDestroy {
this.obj.hostid = this.hostList[0].hostid + '';
this.getEcharts(null);
// this.time_ = thisset
this.time_ = setInterval(()=>{
this.time_ = setInterval(() => {
this.findByTime();
},1000);
}, 1000);
} else {
this.message.warning('当前资源组无资源');
}
......@@ -101,24 +105,125 @@ export class FlowTrendComponent implements OnInit, OnDestroy {
}
//实时流量数据
findByTime(){
findByTime() {
this.topologySer.findByTime(this.obj.hostid).subscribe(
(res)=>{
if(res.errCode == 10000){
(res) => {
if (res.errCode == 10000) {
console.log('有值');
}else{
let nowTime = new Date().getTime() + 500;
const inData = {
clock:this.datePipe.transform(nowTime,"yyyy-MM-dd HH:mm"),
avg:res.data.in
};
this.inEchartData.push(inData);
const outData = {
clock:this.datePipe.transform(nowTime,"yyyy-MM-dd HH:mm"),
avg:res.data.out
};
this.outEchartData.push(outData);
this.flashEcharts();
} else {
this.message.warning(res.errMsg);
clearInterval(this.time_);
console.log("停止");
console.log('停止');
}
}
)
);
}
//实时刷新图表
flashEcharts() {
let itemStyle = {
normal: {},
emphasis: {
barBorderWidth: 1,
shadowBlur: 10,
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowColor: 'rgba(0,0,0,0.5)'
}
};
this.echartObj.setOption({
title: {
text: '进出口流量峰值趋势图',
left: 'center',
},
backgroundColor: '#eee',
tooltip: {
// trigger: 'axis',
formatter: (params) => {
let res = params.seriesName;
res += '<br/>时间:' + params.name;
let Mbps = 1000 * 1000;
let kbps = 1000;
let size = Math.abs(params.data);
if (size / Mbps > 1) {
res += '<br/>流量:' + (size / Mbps).toFixed(2) + 'Mbps';
} else if (size / kbps > 1) {
res += '<br/>流量:' + (size / kbps).toFixed(2) + 'kbps';
} else {
res += '<br/>流量:' + (size) + 'bbps';
}
return res;
}
},
xAxis: {
data: this.inEchartData.map(e => {
let date = this.datePipe.transform(e.clock, 'yyyy-MM-dd HH:mm');
return date;
}),
name: '时间',
},
dataZoom: [{
startValue: this.obj.startTime
}, {
type: 'inside'
}],
yAxis: {
inverse: true,
splitArea: {show: false},
type: 'value',
axisLabel: { //Y轴数据
formatter: function(value) {
return Math.abs(value) / 10000 + ' kbps'; //负数取绝对值变正数
},
textStyle: {
color: '#666'
}
},
},
grid: {
left: 100
},
series: [
{
name: '进口流量',
type: 'line',
stack: 'one',
itemStyle: itemStyle,
data: this.inEchartData.map(e => {
return e.avg;
})
},
{
// name: '出口流量',
type: 'line',
stack: 'one',
itemStyle: itemStyle,
data: this.outEchartData.map(e => {
return -e.avg;
})
}
]
})
}
//页面离开
ngOnDestroy(){
ngOnDestroy() {
//销毁定时任务
console.log("销毁定时任务");
console.log('销毁定时任务');
clearInterval(this.time_);
}
......
......@@ -31,7 +31,7 @@
<div nz-col nzSpan="3"></div>
</div>
<nz-table #nzTable [nzData]="checkList">
<nz-table #nzTable [nzData]="checkList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
<thead>
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked" (nzCheckedChange)="checkAll($event)"></th>
......@@ -46,11 +46,11 @@
<tbody>
<tr *ngFor="let data of checkList">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="selectItem(data,$event)"></td>
<td class="round-tag tag-form">{{data.inventoryNo}}</td>
<td>{{data.stock}}</td>
<td class="round-tag tag-form">{{data.name}}</td>
<td>{{data.key_}}</td>
<td>{{data.usedcount}}</td>
<td>{{data.lendcount}}</td>
<td>{{data.repaircount}}</td>
<td>{{data.type}}</td>
<td>{{data.status}}</td>
<td>
<span>编辑</span>
<span>删除</span>
......@@ -60,4 +60,4 @@
</nz-table>
<!--监控项原型-->
<smart-check-prototype #smartCheckProtoType></smart-check-prototype>
\ No newline at end of file
<smart-check-prototype #smartCheckProtoType (done)="getList()"></smart-check-prototype>
\ No newline at end of file
......@@ -8,18 +8,19 @@ import {pageSize} from '../../../app.constants';
import {CheckPrototypeComponent} from '../modal/check-prototype/check-prototype.component';
@Component({
selector: 'smart-check-list',
templateUrl: './check-list.component.html',
styles: []
selector: 'smart-check-list',
templateUrl: './check-list.component.html',
styles: []
})
export class CheckListComponent implements OnInit {
@ViewChild('smartCheckProtoType') smartCheckProtoType:CheckPrototypeComponent;
@ViewChild('smartCheckProtoType') smartCheckProtoType: CheckPrototypeComponent;
tempName;
disName;
hostId;
discoveryids;
loading = false;
pageNum = 1;
pageCount = pageSize;
totalNum;
......@@ -30,17 +31,17 @@ export class CheckListComponent implements OnInit {
allChecked;
indeterminate;
constructor(private overAllSer: OverAllService, private routerInfo: ActivatedRoute,private router:Router,
private message:NzMessageService,private systemSer:SystemService,
private commonSer:CommonService) {
this.routerInfo.queryParams.subscribe(
(res) => {
this.discoveryids = res.discoveryids;
this.tempName = res.name;
this.hostId = res.hostId;
}
);
}
constructor(private overAllSer: OverAllService, private routerInfo: ActivatedRoute, private router: Router,
private message: NzMessageService, private systemSer: SystemService,
private commonSer: CommonService) {
this.routerInfo.queryParams.subscribe(
(res) => {
this.discoveryids = res.discoveryids;
this.tempName = res.name;
this.hostId = res.hostId;
}
);
}
checkAll(value: boolean): void {
this.checkList.forEach(data => data.checked = value);
......@@ -71,76 +72,84 @@ export class CheckListComponent implements OnInit {
this.indeterminate = (!allChecked) && (!allUnChecked);
}
ngOnInit() {
this.getList();
}
ngOnInit() {
this.getList();
}
//翻页
change(e) {
this.pageNum = e;
this.getList();
}
getList(){
getList() {
this.loading = true;
const data = {
pageNum:this.pageNum,
pageCount:this.pageCount,
hostIds:[this.discoveryids]
pageNum: this.pageNum,
pageCount: this.pageCount,
discoveryids: [this.discoveryids]
};
this.overAllSer.findItemPrototype(data).subscribe(
(res) => {
this.checkList = res.data.data;
this.totalNum = res.data.totalNum;
this.loading = false;
}
);
}
//新增监控项原型
showAddModal(){
this.smartCheckProtoType.showAddModal(this.hostId,this.discoveryids,"添加监控项原型")
showAddModal() {
this.smartCheckProtoType.showAddModal(this.hostId, this.discoveryids, '添加监控项原型');
}
//编辑监控项原型
showEditModal(data){
this.smartCheckProtoType.showEditModal(this.hostId,this.discoveryids,data.itemid,"编辑监控项原型")
showEditModal(data) {
this.smartCheckProtoType.showEditModal(this.hostId, this.discoveryids, data.itemid, '编辑监控项原型');
}
//单个删除
deleteCheck(item){
this.commonSer.confirmThing("删除","确定删除当前的自动发现",()=>{
const data ={
ids:[]
deleteCheck(item) {
this.commonSer.confirmThing('删除', '确定删除当前的自动发现', () => {
const data = {
ids: []
};
data.ids.push(item.itemid);
this.overAllSer.deleteItemPrototype(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
}else{
} else {
this.message.error(res.errMsg);
}
}
)
})
);
});
}
//批量删除
deleteBatchCheck(){
if(this.selectList.length == 0){
this.message.warning("请选择需要删除的监控项原型");
deleteBatchCheck() {
if (this.selectList.length == 0) {
this.message.warning('请选择需要删除的监控项原型');
return false;
}
this.commonSer.confirmThing("删除","确定删除选择的监控项原型",()=>{
const data ={
ids:this.selectList.map(e=>{
this.commonSer.confirmThing('删除', '确定删除选择的监控项原型', () => {
const data = {
ids: this.selectList.map(e => {
return e.itemid;
})
};
this.overAllSer.deleteItemPrototype(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
}else{
} else {
this.message.error(res.errMsg);
}
}
)
})
);
});
}
}
......@@ -28,7 +28,7 @@
<div nz-col nzSpan="3"></div>
</div>
<nz-table #nzTable [nzData]="discoveryList">
<nz-table #nzTable [nzData]="discoveryList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
<thead>
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked" (nzCheckedChange)="checkAll($event)"></th>
......
......@@ -8,9 +8,9 @@ import {OverAllService} from '../../overAll.service';
import {DiscoveryComponent} from '../../../modal/discovery/discovery.component';
@Component({
selector: 'smart-discovery-list',
templateUrl: './discovery-list.component.html',
styles: []
selector: 'smart-discovery-list',
templateUrl: './discovery-list.component.html',
styles: []
})
export class DiscoveryListComponent implements OnInit {
@ViewChild('smartDiscovery') smartDiscovery: DiscoveryComponent;
......@@ -19,6 +19,7 @@ export class DiscoveryListComponent implements OnInit {
discoveryList;
tempName;
loading = false;
pageNum = 1;
pageCount = pageSize;
totalNum;
......@@ -28,13 +29,13 @@ export class DiscoveryListComponent implements OnInit {
disabledButton = true;
indeterminate = false;
constructor(private overAllSer: OverAllService, private routerInfo: ActivatedRoute,private router:Router,
private message:NzMessageService,private systemSer:SystemService,
private commonSer:CommonService) {
constructor(private overAllSer: OverAllService, private routerInfo: ActivatedRoute, private router: Router,
private message: NzMessageService, private systemSer: SystemService,
private commonSer: CommonService) {
this.routerInfo.queryParams.subscribe(
(res) => {
this.templateid = res.templateid;
this.tempName = res.name
this.tempName = res.name;
}
);
}
......@@ -72,95 +73,103 @@ export class DiscoveryListComponent implements OnInit {
this.getList();
}
//翻页
change(e) {
this.pageNum = e;
this.getList();
}
getList() {
this.loading = true;
const data = {
pageNum:this.pageNum,
pageCount:this.pageCount,
hostIds:[this.templateid]
pageNum: this.pageNum,
pageCount: this.pageCount,
hostIds: [this.templateid]
};
this.overAllSer.findPageLldrule(data).subscribe(
(res) => {
this.discoveryList = res.data.data;
this.totalNum = res.data.totalNum;
this.loading = false;
}
);
}
//添加自动发现
showAddModal() {
this.smartDiscovery.showAddModal(this.templateid,"添加自动发现")
this.smartDiscovery.showAddModal(this.templateid, '添加自动发现');
}
//编辑自动发现
showEditModal(data){
this.smartDiscovery.showEditModal(this.templateid,data.itemid,"编辑自动发现");
showEditModal(data) {
this.smartDiscovery.showEditModal(this.templateid, data.itemid, '编辑自动发现');
}
//goto 监测项原型
goToCheck(data){
this.router.navigate(['app/main/checkList'],{
queryParams:{
hostId:this.templateid,
discoveryids:data.itemid,
name:data.name,
tempName : this.tempName
goToCheck(data) {
this.router.navigate(['app/main/checkList'], {
queryParams: {
hostId: this.templateid,
discoveryids: data.itemid,
name: data.name,
tempName: this.tempName
}
})
});
}
//goto 阈值原型
goToTrigger(data){
this.router.navigate(['app/main/triggerList'],{
queryParams:{
id:data.itemid,
name:data.name,
tempName : this.tempName
goToTrigger(data) {
this.router.navigate(['app/main/triggerList'], {
queryParams: {
id: data.itemid,
name: data.name,
tempName: this.tempName
}
})
});
}
//单个删除
deleteDiscovery(item){
this.commonSer.confirmThing("删除","确定删除当前的自动发现",()=>{
const data ={
ids:[]
deleteDiscovery(item) {
this.commonSer.confirmThing('删除', '确定删除当前的自动发现', () => {
const data = {
ids: []
};
data.ids.push(item.itemid);
this.overAllSer.deleteLldrule(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
}else{
} else {
this.message.error(res.errMsg);
}
}
)
})
);
});
}
//批量删除
deleteBatchDiscovery(){
if(this.selectList.length == 0){
this.message.warning("请选择需要删除的自动发现");
deleteBatchDiscovery() {
if (this.selectList.length == 0) {
this.message.warning('请选择需要删除的自动发现');
return false;
}
this.commonSer.confirmThing("删除","确定删除选择的自动发现",()=>{
const data ={
ids:this.selectList.map(e=>{
this.commonSer.confirmThing('删除', '确定删除选择的自动发现', () => {
const data = {
ids: this.selectList.map(e => {
return e.itemid;
})
};
this.overAllSer.deleteLldrule(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
}else{
} else {
this.message.error(res.errMsg);
}
}
)
})
);
});
}
}
......@@ -31,7 +31,7 @@
<div nz-col nzSpan="3"></div>
</div>
<nz-table #nzTable [nzData]="triggerList">
<nz-table #nzTable [nzData]="triggerList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
<thead>
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked"
......@@ -59,4 +59,4 @@
</tbody>
</nz-table>
<!--触发器原型-->
<smart-trigger-prototype #smartTriggerPrototype></smart-trigger-prototype>
\ No newline at end of file
<smart-trigger-prototype #smartTriggerPrototype (done)="getList()"></smart-trigger-prototype>
\ No newline at end of file
......@@ -14,13 +14,14 @@ import {TriggerPrototypeComponent} from '../modal/trigger-prototype/trigger-prot
})
export class TriggerListComponent implements OnInit {
@ViewChild('smartTriggerPrototype') smartTriggerPrototype:TriggerPrototypeComponent;
@ViewChild('smartTriggerPrototype') smartTriggerPrototype: TriggerPrototypeComponent;
tempName;
disName;
hostId;
discoveryids;
color = color;
loading = false;
pageNum = 1;
pageCount = pageSize;
totalNum;
......@@ -76,71 +77,79 @@ export class TriggerListComponent implements OnInit {
this.getList();
}
//翻页
change(e) {
this.pageNum = e;
this.getList();
}
getList() {
this.loading = true;
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount,
hostIds: [this.discoveryids]
discoveryids: [this.discoveryids]
};
this.overAllSer.findPageTrigger(data).subscribe(
(res) => {
this.triggerList = res.data.data;
this.totalNum = res.data.totalNum;
this.loading = false;
}
);
}
showAddModal() {
this.smartTriggerPrototype.showAddModal("新增阈值原型",this.tempName);
this.smartTriggerPrototype.showAddModal('新增阈值原型', this.tempName);
}
showEditModal(data) {
this.smartTriggerPrototype.showEditModal("编辑阈值原型",data.id,this.tempName);
this.smartTriggerPrototype.showEditModal('编辑阈值原型', data.id, this.tempName);
}
//单个删除
deleteTrigger(item){
this.commonSer.confirmThing("删除","确定删除当前的阈值原型",()=>{
const data ={
ids:[]
deleteTrigger(item) {
this.commonSer.confirmThing('删除', '确定删除当前的阈值原型', () => {
const data = {
ids: []
};
data.ids.push(item.triggerid);
this.overAllSer.deleteTrigger(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
}else{
} else {
this.message.error(res.errMsg);
}
}
)
})
);
});
}
//批量删除
deleteBatchTrigger(){
if(this.selectList.length == 0){
this.message.warning("请选择需要删除的阈值原型");
deleteBatchTrigger() {
if (this.selectList.length == 0) {
this.message.warning('请选择需要删除的阈值原型');
return false;
}
this.commonSer.confirmThing("删除","确定删除选择的阈值原型",()=>{
const data ={
ids:this.selectList.map(e=>{
this.commonSer.confirmThing('删除', '确定删除选择的阈值原型', () => {
const data = {
ids: this.selectList.map(e => {
return e.triggerid;
})
};
this.overAllSer.deleteTrigger(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
}else{
} else {
this.message.error(res.errMsg);
}
}
)
})
);
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment