Newer
Older
import {Component, OnInit} from '@angular/core';
import {TopologyService} from '../../topology.service';
import {LocalStorageService} from 'ngx-webstorage';
import {NzMessageService} from 'ng-zorro-antd';
declare let editor: any;
@Component({
selector: 'smart-line',
templateUrl: './line.component.html',
styles: []
})
export class LineComponent implements OnInit {
isLine = false;
hostIds = [];
inPageNum = 1;
outPageNum = 1;
inPageCount = 10;
outPageCount = 10;
totalNum;
inList;
constructor(private topologySer: TopologyService, private message: NzMessageService, private localStorage: LocalStorageService,) {
}
//in
incurrentPageDataChange($event: Array<{ kchecked: boolean }>): void {
const arr = this.inList.map(data=>{
return data.itemId;
});
const old = this.inSelect;
if(old){
const index = arr.indexOf(old.itemId);
this.inList[index].checked = false;
}
this.inSelect = item;
}else{
this.inSelect = null;
}
}
indeleteSelect(index){
this.inSelect = null;
}
changePageIn(e){
}
//out
outcurrentPageDataChange($event: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }>): void {
const arr = this.outList.map(data=>{
return data.itemId;
});
const old = this.outSelect;
if(old){
const index = arr.indexOf(old.itemId);
this.outList[index].checked = false;
}
this.outSelect = item;
}else{
this.outSelect = null;
}
}
outdeleteSelect(index){
this.outSelect = null;
}
changePageOut(e){
showModal(linkObj) {
this.hostIds = linkObj.hostIds; //线条上的主机id;
type:"in",
pageNum:this.inPageNum,
pageCount:this.inPageCount
}
this.topologySer.findFlowItemByHost(data).subscribe(
(res)=>{
this.totalNum = res.data.totalNum;
this.inList = res.data.data;
type:"out",
pageNum:this.outPageNum,
pageCount:this.outPageCount
}
this.topologySer.findFlowItemByHost(data).subscribe(
(res)=>{
this.totalNum = res.data.totalNum;
this.outList = res.data.data;
localStorage.setItem("line",'false');
}
handleLineOk() {
if(this.inSelect && !this.outSelect){
this.message.warning("必须选择一组!");
return false;
}
if(!this.inSelect && this.outSelect){
this.message.warning("必须选择一组!");
return false;
}
editor.utils.setLink(this.inSelect,this.outSelect);
localStorage.setItem("line",'false');