From b8e19b227a0fe0ca10177de49395528ed8a19b30 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 30 Mar 2018 19:37:49 +0900 Subject: [PATCH] end discovery result --- .../component/setting/setting.component.ts | 4 ++-- .../store/discover/discover.reducer.ts | 17 +++++++++-------- .../subscriber/discovery.subscriber.ts | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/packages/discovery/component/setting/setting.component.ts b/src/packages/discovery/component/setting/setting.component.ts index 1b07e01..30ffc2a 100644 --- a/src/packages/discovery/component/setting/setting.component.ts +++ b/src/packages/discovery/component/setting/setting.component.ts @@ -137,7 +137,7 @@ export class SettingComponent implements OnInit, AfterContentInit { return; } - console.log('convertTreeViewZone'); + // console.log('convertTreeViewZone'); const treeNodes: any[] = []; zones.forEach((value: Zone, key: string, map) => { @@ -332,7 +332,7 @@ export class SettingComponent implements OnInit, AfterContentInit { convertViewService(services): any[] { - if (services === undefined && services.size <= 0) { + if (services === undefined || services === null || services.size <= 0) { return null; } diff --git a/src/packages/discovery/store/discover/discover.reducer.ts b/src/packages/discovery/store/discover/discover.reducer.ts index 326f3bb..84af354 100644 --- a/src/packages/discovery/store/discover/discover.reducer.ts +++ b/src/packages/discovery/store/discover/discover.reducer.ts @@ -52,14 +52,15 @@ export function reducer(state = initialState, action: Actions): State { } if (undefined === zone) { - console.error(`Discovery.discoveredHost: Zone[${host.zone.network}] is not exist`); + // console.error(`Discovery.discoveredHost: Zone[${host.zone.network}] is not exist`); + zone = new Map(); } if (null === zone.hosts || undefined === zone.hosts) { zone.hosts = new Map(); zone.hosts.set(host.ip, host); } else { if (zone.hosts.has(host.ip) === false) { - zone.host.set(host.ip, host); + zone.hosts.set(host.ip, host); } } @@ -110,7 +111,7 @@ export function reducer(state = initialState, action: Actions): State { host = port.host; } - if (null === host.ports) { + if (null === host.ports || undefined === host.ports) { host.ports = new Map(); host.ports.set(port.portNumber, port); } else { @@ -163,20 +164,20 @@ export function reducer(state = initialState, action: Actions): State { // } const host: Host = zone.hosts.get(service.port.host.ip); - if (null === host.ports || undefined === host.ports.get(service.port.portNumber)) { - // console.error(`Discovery.DiscoveredPort: Port[${service.port.portNumber}] is not exist`); + if (null === host.ports || undefined === host.ports) { host.ports = new Map(); + host.ports.set(service.port.portNumber, service.port); } - host.ports.set(service.port.portNumber, service.port); - const port: Port = host.ports.get(service.port.portNumber); - if (null === port.services) { + if (null === port.services || undefined === port.services) { port.services = new Map(); } port.services.set(service.serviceName, service); + host.ports.set(service.port.portNumber, port); + zone.hosts.set(host.ip, host); zones.set(zone.network, zone); const newZones: Map = new Map(); diff --git a/src/packages/discovery/subscriber/discovery.subscriber.ts b/src/packages/discovery/subscriber/discovery.subscriber.ts index 1adfcc2..c2d341d 100644 --- a/src/packages/discovery/subscriber/discovery.subscriber.ts +++ b/src/packages/discovery/subscriber/discovery.subscriber.ts @@ -41,6 +41,7 @@ export class DiscoverySubscriber { } @RPCSubscriber({method: 'DiscoveryService.discoveredService'}) public discoveredService(service: Service): void { + this.loggerService.debug('DiscoverySubscriber.discoveredService service:', service); this.store.dispatch(new DiscoverStore.DiscoveredService(service)); } }