2018-04-11 13:05:09 +00:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
AfterViewInit,
|
|
|
|
AfterContentInit,
|
|
|
|
ViewChild
|
|
|
|
} from '@angular/core';
|
2018-04-10 12:37:09 +00:00
|
|
|
import { Router } from '@angular/router';
|
2018-04-25 11:23:30 +00:00
|
|
|
import { TreeNode, MenuItem, ContextMenu } from 'primeng/primeng';
|
2018-04-13 10:32:17 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
import * as ListStore from '../../store/list';
|
|
|
|
import { ListSelector } from '../../store';
|
2018-04-16 11:23:43 +00:00
|
|
|
import { Page, PageParams } from 'app/commons/model';
|
2018-04-13 10:32:17 +00:00
|
|
|
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
|
|
|
import { Target } from 'packages/target/model';
|
|
|
|
import { Infra, InfraHost, InfraOSApplication, InfraService } from '../../model';
|
2018-04-16 11:23:43 +00:00
|
|
|
import { Domain } from 'packages/domain/model';
|
|
|
|
import { AuthSelector } from 'packages/member/store';
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
import { sensorListSelector } from 'packages/sensor/store';
|
|
|
|
|
|
|
|
import * as SensorListStore from 'packages/sensor/store/list';
|
|
|
|
import { Sensor } from 'packages/sensor/model';
|
|
|
|
|
|
|
|
import * as _ from 'lodash';
|
2018-04-13 10:32:17 +00:00
|
|
|
|
|
|
|
interface HostData {
|
|
|
|
id: string;
|
|
|
|
target?: Target;
|
|
|
|
host: InfraHost;
|
|
|
|
services: InfraService[];
|
|
|
|
}
|
2018-04-10 12:37:09 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-infra-map',
|
2018-04-11 13:05:09 +00:00
|
|
|
templateUrl: './map.component.html'
|
2018-04-10 12:37:09 +00:00
|
|
|
})
|
|
|
|
export class MapComponent implements OnInit, AfterContentInit {
|
2018-04-16 11:23:43 +00:00
|
|
|
// infraTree: TreeNode[] = testInfraList;
|
|
|
|
infraTree: TreeNode[] = [];
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
infras$ = this.listStore.pipe(select(ListSelector.select('page')));
|
2018-04-18 07:22:27 +00:00
|
|
|
sensors$ = this.sensorListStore.pipe(select(sensorListSelector.select('page')));
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-11 12:26:51 +00:00
|
|
|
display = false;
|
2018-04-13 10:32:17 +00:00
|
|
|
loading = false;
|
|
|
|
|
|
|
|
totalList: Infra[];
|
|
|
|
hostDataList: HostData[] = new Array();
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
sensorMap: Map<number, Array<Sensor>> = new Map();
|
|
|
|
|
|
|
|
targetTreeMap: Map<number, TreeNode> = new Map();
|
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
DEFAULT_EXPANDED: Boolean = true;
|
2018-04-25 11:23:30 +00:00
|
|
|
|
|
|
|
contextMenuProbe: MenuItem[];
|
|
|
|
contextMenuHost: MenuItem[];
|
2018-04-25 12:34:51 +00:00
|
|
|
contextMenuService: MenuItem[];
|
|
|
|
contextMenuSensor: MenuItem[];
|
2018-04-25 11:23:30 +00:00
|
|
|
|
|
|
|
@ViewChild('cmProbe') cmProbe: ContextMenu;
|
|
|
|
@ViewChild('cmHost') cmHost: ContextMenu;
|
2018-04-25 12:34:51 +00:00
|
|
|
@ViewChild('cmService') cmService: ContextMenu;
|
|
|
|
@ViewChild('cmSensor') cmSensor: ContextMenu;
|
|
|
|
|
|
|
|
visibleSidebar = false;
|
|
|
|
selectedNode: TreeNode = null;
|
|
|
|
targetNodeForView: Object = null;
|
2018-04-10 12:37:09 +00:00
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
constructor(private router: Router,
|
|
|
|
private listStore: Store<ListStore.State>,
|
2018-04-18 07:22:27 +00:00
|
|
|
private sensorListStore: Store<SensorListStore.State>
|
2018-04-25 09:04:47 +00:00
|
|
|
) { }
|
2018-04-13 10:32:17 +00:00
|
|
|
|
|
|
|
ngAfterContentInit() {
|
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
this.listStore.select(AuthSelector.select('domain')).subscribe(
|
|
|
|
(domain: Domain) => {
|
|
|
|
|
|
|
|
const pageParams: PageParams = {
|
|
|
|
pageNo: '0',
|
|
|
|
countPerPage: '10',
|
|
|
|
sortCol: 'id',
|
|
|
|
sortDirection: 'descending'
|
|
|
|
};
|
|
|
|
|
2018-04-25 09:04:47 +00:00
|
|
|
this.listStore.dispatch(new ListStore.ReadAllByDomain({ domain: domain, pageParams: pageParams }));
|
2018-04-16 11:23:43 +00:00
|
|
|
},
|
|
|
|
(error) => {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
this.infras$.subscribe(
|
|
|
|
(page: Page) => {
|
2018-04-16 11:23:43 +00:00
|
|
|
console.log(page);
|
2018-04-13 10:32:17 +00:00
|
|
|
if (page !== null) {
|
|
|
|
this.totalList = page.content;
|
2018-04-16 11:23:43 +00:00
|
|
|
console.log(this.totalList);
|
|
|
|
this.infraTree = this.generateInfraHostData();
|
2018-04-13 10:32:17 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
});
|
2018-04-18 07:22:27 +00:00
|
|
|
|
2018-04-25 09:04:47 +00:00
|
|
|
this.sensors$.subscribe(
|
|
|
|
(page: Page) => {
|
|
|
|
if (page !== null) {
|
|
|
|
const sensorList = page.content;
|
|
|
|
console.log(sensorList);
|
|
|
|
this.addTreeForSensor(sensorList);
|
2018-04-18 07:22:27 +00:00
|
|
|
}
|
2018-04-25 09:04:47 +00:00
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
2018-04-13 10:32:17 +00:00
|
|
|
}
|
2018-04-10 12:37:09 +00:00
|
|
|
|
2018-04-25 11:23:30 +00:00
|
|
|
ngOnInit() {
|
|
|
|
this.initContextMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
initContextMenu() {
|
|
|
|
this.contextMenuProbe = [
|
2018-04-25 12:34:51 +00:00
|
|
|
{ label: 'Probe Menu', command: (event) => this.closeContextMenu() },
|
|
|
|
{ label: 'View info', icon: 'fa-plus', command: (event) => this.viewInfo() }
|
2018-04-25 11:23:30 +00:00
|
|
|
];
|
|
|
|
this.contextMenuHost = [
|
2018-04-25 12:34:51 +00:00
|
|
|
{ label: 'Host Menu', command: (event) => this.closeContextMenu() },
|
|
|
|
{ label: 'View this Host', icon: 'fa-plus', command: (event) => this.viewInfo() },
|
|
|
|
{ label: 'Add sensor', icon: 'fa-plus', command: (event) => this.addSensor() },
|
|
|
|
{ label: 'Traceroute', icon: 'fa-plus' },
|
|
|
|
{ label: 'ARP Test', icon: 'fa-plus' },
|
|
|
|
{ label: 'Ping Test', icon: 'fa-plus' },
|
|
|
|
];
|
|
|
|
this.contextMenuService = [
|
|
|
|
{ label: 'Service Menu', command: (event) => this.closeContextMenu() },
|
|
|
|
{ label: 'View this Service', icon: 'fa-plus', command: (event) => this.viewInfo() },
|
|
|
|
{ label: 'Add sensor', icon: 'fa-plus', command: (event) => this.addSensor() },
|
2018-04-25 11:23:30 +00:00
|
|
|
];
|
2018-04-25 12:34:51 +00:00
|
|
|
this.contextMenuSensor = [
|
|
|
|
{ label: 'Sensor Menu', command: (event) => this.closeContextMenu() },
|
|
|
|
{ label: 'Edit', icon: 'fa-plus', command: (event) => this.viewInfo() },
|
|
|
|
{ label: 'Remove', icon: 'fa-plus', command: (event) => this.addSensor() },
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
closeContextMenu() {
|
|
|
|
this.cmProbe.hide();
|
|
|
|
this.cmHost.hide();
|
|
|
|
this.cmService.hide();
|
|
|
|
this.cmSensor.hide();
|
|
|
|
|
2018-04-25 11:23:30 +00:00
|
|
|
}
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
searchObj(treeList: any[], target: Target, searchList: any[]) {
|
|
|
|
|
|
|
|
if (treeList === undefined || treeList === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const t of treeList) {
|
|
|
|
if (t.obj !== undefined && t.obj == null) {
|
|
|
|
if (t.obj.target.id === target.id) {
|
|
|
|
searchList.push(t);
|
|
|
|
} else {
|
|
|
|
this.searchObj(t.children, target, searchList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
addTreeForSensor(sensorList: Array<Sensor>) {
|
|
|
|
|
|
|
|
if (sensorList === undefined || sensorList === null || sensorList.length <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// const tInfraTree = _.clone(this.infraTree);
|
|
|
|
|
|
|
|
// const it = tInfraTree[0];
|
|
|
|
// const it = this.infraTree[0];
|
|
|
|
// // for (const it of this.infraTree) {
|
|
|
|
// if (it.children === null || it.children === undefined) {
|
|
|
|
// it.children = [];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for (const itt of this.infraTree) {
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
for (const sensor of sensorList) {
|
|
|
|
const st = {
|
|
|
|
label: 'Sensors - ' + sensor.crawler.name,
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'sensor',
|
2018-04-18 07:22:27 +00:00
|
|
|
obj: sensor,
|
|
|
|
expanded: true
|
|
|
|
};
|
|
|
|
|
|
|
|
// FIXME:: target test id ....
|
2018-04-19 05:52:55 +00:00
|
|
|
const tt = this.targetTreeMap.get(4);
|
2018-04-18 07:22:27 +00:00
|
|
|
// const tt = this.targetTreeMap.get(sensor.target.id);
|
|
|
|
if (tt !== undefined && tt !== null) {
|
|
|
|
tt.children.push(st);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// it.children.push(st);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// this.infraTree = tInfraTree;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
generateInfraHostData(filterStr?: string): TreeNode[] {
|
2018-04-13 10:32:17 +00:00
|
|
|
|
|
|
|
const itl: TreeNode[] = [];
|
|
|
|
|
|
|
|
const probeMap: Map<number, InfraHost[]> = new Map();
|
|
|
|
|
|
|
|
const hostMap: Map<number, InfraService[]> = new Map();
|
|
|
|
|
|
|
|
this.loading = true;
|
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
this.sortInfraToMap(probeMap, hostMap, filterStr);
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
this.targetTreeMap.clear();
|
2018-04-18 07:22:27 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
const infraTree: TreeNode = this.generateInfraTree(probeMap, hostMap);
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
for (const infra of this.totalList) {
|
|
|
|
this.getSensorByInfra(infra);
|
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
this.loading = false;
|
2018-04-16 11:23:43 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
itl.push(infraTree);
|
2018-04-16 11:23:43 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
return itl;
|
2018-04-16 11:23:43 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
}
|
2018-04-16 11:23:43 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
generateInfraTree(probeMap: Map<number, InfraHost[]>, hostMap: Map<number, InfraService[]>): TreeNode {
|
2018-04-16 11:23:43 +00:00
|
|
|
|
2018-04-25 09:04:47 +00:00
|
|
|
const infraTree = {
|
2018-04-18 11:15:56 +00:00
|
|
|
label: 'Infra',
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'infra',
|
2018-04-18 11:15:56 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [],
|
|
|
|
};
|
2018-04-18 07:22:27 +00:00
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
probeMap.forEach((ifhl: InfraHost[], key: number) => {
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
const tp = {
|
2018-04-16 11:23:43 +00:00
|
|
|
label: 'Probe - ' + key,
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'probe',
|
2018-04-16 11:23:43 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: this.DEFAULT_EXPANDED.valueOf(),
|
2018-04-25 12:34:51 +00:00
|
|
|
obj: {
|
|
|
|
id: key
|
|
|
|
},
|
2018-04-16 11:23:43 +00:00
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
ifhl.map((ih: InfraHost, idx: number) => {
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
const th = {
|
2018-04-16 11:23:43 +00:00
|
|
|
label: 'Host - ' + ih.ip,
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'host',
|
2018-04-16 11:23:43 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: this.DEFAULT_EXPANDED.valueOf(),
|
2018-04-18 07:22:27 +00:00
|
|
|
obj: ih,
|
2018-04-16 11:23:43 +00:00
|
|
|
children: [],
|
|
|
|
};
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
this.targetTreeMap.set(ih.target.id, th);
|
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
if (hostMap.has(ih.ip)) {
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
const ifsl = hostMap.get(ih.ip);
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
|
|
|
|
|
2018-04-25 09:04:47 +00:00
|
|
|
for (let i = 0; i < ifsl.length; ++i) {
|
2018-04-18 07:22:27 +00:00
|
|
|
const ts = {
|
2018-04-16 11:23:43 +00:00
|
|
|
label: 'Service - ' + ifsl[i].vendor.name,
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'service',
|
2018-04-13 10:32:17 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: this.DEFAULT_EXPANDED.valueOf(),
|
2018-04-18 07:22:27 +00:00
|
|
|
obj: ifsl[i],
|
2018-04-13 10:32:17 +00:00
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
this.targetTreeMap.set(ifsl[i].target.id, ts);
|
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
th.children.push(ts);
|
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
tp.children.push(th);
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-16 11:23:43 +00:00
|
|
|
});
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
// ProbeTree.children.push(tp);
|
|
|
|
infraTree.children.push(tp);
|
2018-04-16 11:23:43 +00:00
|
|
|
});
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
return infraTree;
|
|
|
|
}
|
|
|
|
|
|
|
|
sortInfraToMap(probeMap: Map<number, InfraHost[]>, hostMap: Map<number, InfraService[]>, filterStr: string) {
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
for (const infra of this.totalList) {
|
2018-04-18 11:15:56 +00:00
|
|
|
const infraType = infra.infraType.name;
|
|
|
|
if (infraType === 'HOST') {
|
|
|
|
const infraHost: InfraHost = infra;
|
|
|
|
if (filterStr && String(infraHost.ip).indexOf(filterStr) < 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (probeMap.has(infraHost.probe.id) === false) {
|
|
|
|
probeMap.set(infraHost.probe.id, []);
|
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
const ihl: InfraHost[] = probeMap.get(infraHost.probe.id);
|
|
|
|
ihl.push(infraHost);
|
|
|
|
probeMap.set(infraHost.probe.id, ihl);
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
} else if (infraType === 'OS_SERVICE') {
|
|
|
|
const infraService: InfraService = infra;
|
|
|
|
if (filterStr && this.checkFilterString(infraService, filterStr)) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
if (hostMap.has(infraService.host.ip) === false) {
|
|
|
|
hostMap.set(infraService.host.ip, []);
|
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
const isl = hostMap.get(infraService.host.ip);
|
|
|
|
isl.push(infraService);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-04-13 10:32:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-04-18 07:22:27 +00:00
|
|
|
getSensorByInfra(infra: Infra) {
|
|
|
|
|
|
|
|
const pageParams: PageParams = {
|
|
|
|
pageNo: '0',
|
|
|
|
countPerPage: '10',
|
|
|
|
sortCol: 'id',
|
|
|
|
sortDirection: 'descending'
|
|
|
|
};
|
|
|
|
|
2018-04-25 09:04:47 +00:00
|
|
|
this.sensorListStore.dispatch(new SensorListStore.ReadAllByInfra({ id: String(infra.id), pageParams: pageParams }));
|
2018-04-18 07:22:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
checkFilterString(infraService: InfraService, filterStr: string) {
|
|
|
|
const upperCased = filterStr.toUpperCase().toUpperCase();
|
|
|
|
if (infraService.vendor.name.toUpperCase().indexOf(upperCased) < 0 &&
|
|
|
|
String(infraService.port).toUpperCase().indexOf(upperCased) < 0 &&
|
|
|
|
infraService.portType.toUpperCase().indexOf(upperCased)) {
|
2018-04-25 09:04:47 +00:00
|
|
|
return true;
|
2018-04-13 10:32:17 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
getExistHost(infraHost: InfraHost): HostData {
|
|
|
|
let node = null;
|
|
|
|
for (const data of this.hostDataList) {
|
|
|
|
if (data.host.ip === infraHost.ip) {
|
|
|
|
node = data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2018-04-11 12:26:51 +00:00
|
|
|
showDialog() {
|
|
|
|
this.display = true;
|
2018-04-11 13:05:09 +00:00
|
|
|
}
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
closeDialog() {
|
|
|
|
this.display = false;
|
|
|
|
}
|
|
|
|
|
2018-04-11 13:05:09 +00:00
|
|
|
expandAll() {
|
|
|
|
this.infraTree.forEach(node => {
|
|
|
|
this.expandRecursive(node, true);
|
|
|
|
});
|
|
|
|
}
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-11 13:05:09 +00:00
|
|
|
collapseAll() {
|
|
|
|
this.infraTree.forEach(node => {
|
|
|
|
this.expandRecursive(node, false);
|
|
|
|
});
|
|
|
|
}
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-11 13:05:09 +00:00
|
|
|
private expandRecursive(node: TreeNode, isExpand: boolean) {
|
|
|
|
node.expanded = isExpand;
|
|
|
|
if (node.children) {
|
|
|
|
node.children.forEach(childNode => {
|
|
|
|
this.expandRecursive(childNode, isExpand);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-04-25 09:04:47 +00:00
|
|
|
|
|
|
|
onNodeSelect(event) {
|
2018-04-25 11:23:30 +00:00
|
|
|
const nodeType = event.node.type;
|
2018-04-25 12:34:51 +00:00
|
|
|
this.selectedNode = event.node;
|
2018-04-25 11:23:30 +00:00
|
|
|
if (nodeType === 'probe') {
|
2018-04-25 12:34:51 +00:00
|
|
|
this.router.navigate(['probe', event.node.obj.id, 'info']);
|
2018-04-25 11:23:30 +00:00
|
|
|
} else if (nodeType === 'host') {
|
2018-04-25 09:04:47 +00:00
|
|
|
}
|
2018-04-25 12:34:51 +00:00
|
|
|
}
|
2018-04-25 11:23:30 +00:00
|
|
|
|
2018-04-25 12:34:51 +00:00
|
|
|
viewInfo() {
|
|
|
|
const nodeType = this.selectedNode.type;
|
|
|
|
if (nodeType !== 'probe' && nodeType !== 'host' && nodeType !== 'service') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.targetNodeForView = this.selectedNode['obj'];
|
|
|
|
this.visibleSidebar = true;
|
2018-04-25 11:23:30 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 12:34:51 +00:00
|
|
|
nodeMenu(event: MouseEvent, node: any) {
|
|
|
|
this.selectedNode = node;
|
|
|
|
|
2018-04-25 11:23:30 +00:00
|
|
|
this.cmProbe.hide();
|
|
|
|
this.cmHost.hide();
|
2018-04-25 12:34:51 +00:00
|
|
|
this.cmService.hide();
|
|
|
|
this.cmSensor.hide();
|
|
|
|
|
2018-04-25 11:23:30 +00:00
|
|
|
if (node.type === 'probe') {
|
|
|
|
this.cmProbe.show(event);
|
2018-04-25 12:34:51 +00:00
|
|
|
} else if (node.type === 'host') {
|
2018-04-25 11:23:30 +00:00
|
|
|
this.cmHost.show(event);
|
2018-04-25 12:34:51 +00:00
|
|
|
} else if (node.type === 'service') {
|
|
|
|
this.cmService.show(event);
|
|
|
|
} else if (node.type === 'sensor') {
|
|
|
|
this.cmSensor.show(event);
|
2018-04-25 11:23:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-04-25 09:04:47 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 12:34:51 +00:00
|
|
|
addSensor() {
|
|
|
|
alert('으악 내일 할래');
|
|
|
|
}
|
2018-04-11 13:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const testInfraList = [
|
2018-04-11 12:26:51 +00:00
|
|
|
{
|
2018-04-11 13:05:09 +00:00
|
|
|
label: 'Infra',
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'infra',
|
2018-04-11 12:26:51 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
2018-04-11 13:05:09 +00:00
|
|
|
expanded: true,
|
|
|
|
children: [
|
2018-04-11 12:26:51 +00:00
|
|
|
{
|
2018-04-11 13:05:09 +00:00
|
|
|
label: 'Zone - 192.168.1.0/24',
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'zone',
|
2018-04-11 12:26:51 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
2018-04-11 13:05:09 +00:00
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Host - 192.168.1.106 - Snoop Host',
|
2018-04-19 05:52:55 +00:00
|
|
|
type: 'host',
|
2018-04-11 13:05:09 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - WMI, SSH, SNMP',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Service - FTP(21)',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - FTP, Sensor',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Host - 192.168.1.103 - Geek Host',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - WMI, SSH, SNMP',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Service - MySQL(3306)',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - MySQL, PING',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Service - PostgreSQL(5555)',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - PostgreSQL, PING',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2018-04-11 12:26:51 +00:00
|
|
|
},
|
|
|
|
{
|
2018-04-11 13:05:09 +00:00
|
|
|
label: 'Zone - 192.168.10.0/24',
|
2018-04-11 12:26:51 +00:00
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
2018-04-11 13:05:09 +00:00
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Host - 192.168.10.106 - Snoop Host',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - WMI, SSH, SNMP',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Service - FTP(21)',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - FTP, Sensor',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Host - 192.168.10.103 - Geek Host',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - WMI, SSH, SNMP',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Service - MySQL(3306)',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - MySQL, PING',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Service - PostgreSQL(5555)',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: 'Sensors - PostgreSQL, PING',
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
expanded: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
2018-04-25 11:23:30 +00:00
|
|
|
|