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> <of-discovery-setting></of-discovery-setting>
</p-dialog> </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> <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 { Router } from '@angular/router';
import { TreeNode } from 'primeng/primeng'; import { TreeNode } from 'primeng/primeng';
@Component({ @Component({
selector: 'of-infra-map', selector: 'of-infra-map',
templateUrl: './map.component.html', templateUrl: './map.component.html'
}) })
export class MapComponent implements OnInit, AfterContentInit { export class MapComponent implements OnInit, AfterContentInit {
infraTree: TreeNode[] = testInfraList; infraTree: TreeNode[] = testInfraList;
display = false; display = false;
constructor( constructor(private router: Router) {}
private router: Router,
) {
}
ngAfterContentInit() { ngAfterContentInit() {}
} ngOnInit() {}
ngOnInit() {
}
showDialog() { showDialog() {
this.display = true; 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 = [
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,
},
],
}],
}],
},
{ {
label: 'Zone - 192.168.10.0/24', label: 'Infra',
expandedIcon: 'fa-folder-open', expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder', collapsedIcon: 'fa-folder',
expanded : true, expanded: true,
children: [{ children: [
label: 'Host - 192.168.10.106 - Snoop Host', {
expandedIcon: 'fa-folder-open', label: 'Zone - 192.168.1.0/24',
collapsedIcon: 'fa-folder',
expanded : true,
children: [{
label: 'Sensors - WMI, SSH, SNMP',
expandedIcon: 'fa-folder-open', expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder', 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', expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder', collapsedIcon: 'fa-folder',
expanded : true, expanded: true,
children: [{ children: [
label: 'Sensors - FTP, Sensor', {
expandedIcon: 'fa-folder-open', label: 'Host - 192.168.10.106 - Snoop Host',
collapsedIcon: 'fa-folder', expandedIcon: 'fa-folder-open',
expanded : true, collapsedIcon: 'fa-folder',
}, expanded: true,
], children: [
}], {
}, label: 'Sensors - WMI, SSH, SNMP',
{ expandedIcon: 'fa-folder-open',
label: 'Host - 192.168.10.103 - Geek Host', collapsedIcon: 'fa-folder',
expandedIcon: 'fa-folder-open', expanded: true
collapsedIcon: 'fa-folder', },
expanded : true, {
children: [{ label: 'Service - FTP(21)',
label: 'Sensors - WMI, SSH, SNMP', expandedIcon: 'fa-folder-open',
expandedIcon: 'fa-folder-open', collapsedIcon: 'fa-folder',
collapsedIcon: 'fa-folder', expanded: true,
expanded : true, children: [
}, {
{ label: 'Sensors - FTP, Sensor',
label: 'Service - MySQL(3306)', expandedIcon: 'fa-folder-open',
expandedIcon: 'fa-folder-open', collapsedIcon: 'fa-folder',
collapsedIcon: 'fa-folder', expanded: true
expanded : true, }
children: [{ ]
label: 'Sensors - MySQL, PING', }
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,
label: 'Service - PostgreSQL(5555)', children: [
expandedIcon: 'fa-folder-open', {
collapsedIcon: 'fa-folder', label: 'Sensors - WMI, SSH, SNMP',
expanded : true, expandedIcon: 'fa-folder-open',
children: [{ collapsedIcon: 'fa-folder',
label: 'Sensors - PostgreSQL, PING', expanded: true
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
}
]
}
]
}
]
}
]
}
];