From 07046522c7c316f7c1cb5db0d68c4ff0d2cd33fb Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 5 Apr 2018 19:03:26 +0900 Subject: [PATCH] fixed discovery result --- .../component/setting/setting.component.ts | 41 ++++++++++++++++++- src/packages/discovery/model/Host.ts | 1 + src/packages/discovery/model/Port.ts | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/packages/discovery/component/setting/setting.component.ts b/src/packages/discovery/component/setting/setting.component.ts index 30ffc2a..61df610 100644 --- a/src/packages/discovery/component/setting/setting.component.ts +++ b/src/packages/discovery/component/setting/setting.component.ts @@ -18,6 +18,8 @@ import * as DiscoverStore from '../../store/discover'; import * as RegistStore from '../../store/regist'; import { Host } from 'packages/discovery/model/Host'; +import { Port } from 'packages/discovery/model/Port'; +import { Service } from 'packages/discovery/model/Service'; import * as ProbeDetailStore from 'packages/probe/store'; import { Probe } from 'packages/probe/model'; @@ -254,6 +256,22 @@ export class SettingComponent implements OnInit, AfterContentInit { } + convertMapToList(map: Map): Array { + + if (undefined === map || null === map || map.size < 0) { + return null; + } + + const retArr = new Array(); + + map.forEach((v: any, k: any) => { + retArr.push(v); + }); + + return retArr; + } + + discoveryResultSave() { // console.log(this.checkedSet); @@ -267,11 +285,32 @@ export class SettingComponent implements OnInit, AfterContentInit { // FIXME: getHosts const hosts: Host[] = []; zone.hosts.forEach((h: Host, hKey: string) => { + + // if (h.ports !== undefined && h.ports !== null) { + // h.portList = []; + // h.ports.forEach((p: Port, pKey: number) => { + + // if (p.services !== undefined && p.services !== null) { + // p.serviceList = []; + + // p.services.forEach((s: Service, sKey: string) => { + // p.serviceList.push(s); + // }); + + // } + + // h.portList.push(p); + // }); + // } + hosts.push(h); }); if (hosts.length > 0) { - this.registStore.dispatch(new RegistStore.DiscoverySaveAllTarget({ hosts: hosts, probe: { id: 1 } })); + const sd: any = { hosts: hosts, probe: { id: 1 } }; + console.log(JSON.stringify(sd)); + console.log('--------'); + this.registStore.dispatch(new RegistStore.DiscoverySaveAllTarget(sd)); } } diff --git a/src/packages/discovery/model/Host.ts b/src/packages/discovery/model/Host.ts index 531761c..15f72df 100644 --- a/src/packages/discovery/model/Host.ts +++ b/src/packages/discovery/model/Host.ts @@ -11,4 +11,5 @@ export interface Host { target?: boolean; ports: Map | null; + portList: Port[] | null; } diff --git a/src/packages/discovery/model/Port.ts b/src/packages/discovery/model/Port.ts index fef7e14..6f11087 100644 --- a/src/packages/discovery/model/Port.ts +++ b/src/packages/discovery/model/Port.ts @@ -11,4 +11,5 @@ export interface Port { isTarget?: boolean; services: Map | null; + serviceList: Service[] | null; }