fixed discovery

This commit is contained in:
snoop 2018-04-11 22:05:09 +09:00
parent b52cdaa384
commit ac85f81d24
2 changed files with 197 additions and 151 deletions

View File

@ -5,9 +5,15 @@
<of-discovery-setting></of-discovery-setting>
</p-dialog>
<button type="text" (click)="showDialog()" pButton icon="fa-external-link-square" label="Show"></button>
<button type="text" (click)="showDialog()" pButton icon="fa-external-link-square" label="Discovery"></button>
<div style="margin-top: 8px">
<button pButton type="button" label="Expand all" (click)="expandAll()"></button>
<button pButton type="button" label="Collapse all" (click)="collapseAll()"></button>
</div>
<p-tree [value]="infraTree" [style]="{width: '360px'}" selectionMode="single" [(selection)]="selectedTree" ></p-tree>

View File

@ -1,177 +1,217 @@
import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild } from '@angular/core';
import {
Component,
OnInit,
AfterViewInit,
AfterContentInit,
ViewChild
} from '@angular/core';
import { Router } from '@angular/router';
import { TreeNode } from 'primeng/primeng';
@Component({
selector: 'of-infra-map',
templateUrl: './map.component.html',
templateUrl: './map.component.html'
})
export class MapComponent implements OnInit, AfterContentInit {
infraTree: TreeNode[] = testInfraList;
display = false;
constructor(
private router: Router,
) {
}
constructor(private router: Router) {}
ngAfterContentInit() {
ngAfterContentInit() {}
}
ngOnInit() {
}
ngOnInit() {}
showDialog() {
this.display = true;
}
}
expandAll() {
this.infraTree.forEach(node => {
this.expandRecursive(node, true);
});
}
collapseAll() {
this.infraTree.forEach(node => {
this.expandRecursive(node, false);
});
}
private expandRecursive(node: TreeNode, isExpand: boolean) {
node.expanded = isExpand;
if (node.children) {
node.children.forEach(childNode => {
this.expandRecursive(childNode, isExpand);
});
}
}
}
const testInfraList = [{
label: 'Infra',
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
expanded : true,
children: [{
label: 'Zone - 192.168.1.0/24',
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
expanded : true,
children: [{
label: 'Host - 192.168.1.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.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,
},
],
}],
}],
},
const testInfraList = [
{
label: 'Zone - 192.168.10.0/24',
label: 'Infra',
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
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',
expanded: true,
children: [
{
label: 'Zone - 192.168.1.0/24',
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
expanded : true,
expanded: true,
children: [
{
label: 'Host - 192.168.1.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.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
}
]
}
]
}
]
},
{
label: 'Service - FTP(21)',
label: 'Zone - 192.168.10.0/24',
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,
},
],
}],
}],
}],
}];
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
}
]
}
]
}
]
}
]
}
];