diff --git a/src/packages/infra/component/map/map.component.html b/src/packages/infra/component/map/map.component.html index 8885b52..a72d518 100644 --- a/src/packages/infra/component/map/map.component.html +++ b/src/packages/infra/component/map/map.component.html @@ -5,9 +5,15 @@ - + + +
+ + +
+ diff --git a/src/packages/infra/component/map/map.component.ts b/src/packages/infra/component/map/map.component.ts index 19b042e..c429fc5 100644 --- a/src/packages/infra/component/map/map.component.ts +++ b/src/packages/infra/component/map/map.component.ts @@ -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 + } + ] + } + ] + } + ] + } + ] + } +];