From 7e94b5eb30158521db24eb8e089877aab3356e5d Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 18 Sep 2018 03:10:51 +0900 Subject: [PATCH] ing --- src/app/pages/home/home-page.component.ts | 56 +++++++++++++++-------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/app/pages/home/home-page.component.ts b/src/app/pages/home/home-page.component.ts index 5ad1111..f8da59f 100644 --- a/src/app/pages/home/home-page.component.ts +++ b/src/app/pages/home/home-page.component.ts @@ -50,8 +50,8 @@ export class HomePageComponent implements OnInit, OnDestroy { private readonly maxScale: number; private readonly minScale: number; - hosts: Host[]; - ports: Port[]; + hosts: Map; + ports: Map>; resultMsg: Message[] = []; @@ -87,8 +87,8 @@ export class HomePageComponent implements OnInit, OnDestroy { ) { this.nodes = []; this.links = []; - this.hosts = []; - this.ports = []; + this.hosts = new Map(); + this.ports = new Map(); this.discoveryRequestID = null; @@ -511,6 +511,7 @@ export class HomePageComponent implements OnInit, OnDestroy { case 'zone': const zone: Zone = node.target; zone.hostList = []; + this.hosts.forEach(_host => { if (_host.zone.network === zone.network) { zone.hostList.push(_host); @@ -520,11 +521,11 @@ export class HomePageComponent implements OnInit, OnDestroy { case 'host': const host: Host = node.target; host.portList = []; - this.ports.forEach(port => { - if (port.host.address === host.address) { + if (this.ports.has(host.address)) { + this.ports.get(host.address).forEach(port => { host.portList.push(port); - } - }); + }); + } break; default: break; @@ -661,16 +662,22 @@ export class HomePageComponent implements OnInit, OnDestroy { @RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' }) public DiscoveredHost(host: Host) { console.log('DiscoveredHost', host); - let dup = false; - this.hosts.forEach((item) => { - if (item.address === host.address) { - dup = true; - return; - } - }); - if (!dup) { - this.hosts.push(host); - } + + // if (this.hosts.has(host.address)) { + + // } + + // let dup = false; + // this.hosts.forEach((item) => { + // if (item.address === host.address) { + // dup = true; + // return; + // } + // }); + // if (!dup) { + // this.hosts.push(host); + // } + this.hosts.set(host.address, host); const hostId = `${host.address}`; @@ -698,7 +705,16 @@ export class HomePageComponent implements OnInit, OnDestroy { @RPCSubscriber({ method: 'DiscoveryService.DiscoveredPort' }) public DiscoveredPort(port: Port) { console.log('DiscoveredPort', port); - this.ports.push(port); + + let _ports: Map; + if (!this.ports.has(port.host.address)) { + _ports = new Map(); + this.ports.set(port.host.address, _ports); + } else { + _ports = this.ports.get(port.host.address); + } + + _ports.set(port.portNumber, port); } /** @@ -708,7 +724,7 @@ export class HomePageComponent implements OnInit, OnDestroy { public DiscoveredService(service: Service) { console.log('DiscoveredService', service); const hostId = service.port.host.address; - const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.key}`; + const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.port.metaPortType.key}`; const hostNode = this.getNode(hostId); let serviceNode = this.getNode(serviceId);