diff --git a/src/ts/@overflow/discovery/api/model/Host.ts b/src/ts/@overflow/discovery/api/model/Host.ts index b7c32f6..3783f60 100644 --- a/src/ts/@overflow/discovery/api/model/Host.ts +++ b/src/ts/@overflow/discovery/api/model/Host.ts @@ -1,4 +1,5 @@ import Port from './Port'; +import Zone from './Zone'; interface Host { id?: number; @@ -9,6 +10,7 @@ interface Host { os: string; target: boolean; ports?: Port[]; + zone?: Zone; } export default Host; diff --git a/src/ts/@overflow/discovery/api/model/Zone.ts b/src/ts/@overflow/discovery/api/model/Zone.ts index 27460be..c60435b 100644 --- a/src/ts/@overflow/discovery/api/model/Zone.ts +++ b/src/ts/@overflow/discovery/api/model/Zone.ts @@ -1,11 +1,14 @@ +import Host from './Host'; + export interface Zone { - id: number; - network: string; - ip: string; - iface: string; - mac: string; - firstScanRange: number; - lastScanRange: number; + id?: number; + network?: string; + ip?: string; + iface?: string; + mac?: string; + firstScanRange?: number; + lastScanRange?: number; + hosts?: Host[]; } export default Zone; diff --git a/src/ts/@overflow/discovery/react/components/Discovery.tsx b/src/ts/@overflow/discovery/react/components/Discovery.tsx index 3554bfe..8b832a5 100644 --- a/src/ts/@overflow/discovery/react/components/Discovery.tsx +++ b/src/ts/@overflow/discovery/react/components/Discovery.tsx @@ -14,6 +14,7 @@ import Probe from '@overflow/probe/api/model/Probe'; import Host from '@overflow/discovery/api/model/Host'; import Port from '@overflow/discovery/api/model/Port'; import Service from '@overflow/discovery/api/model/Service'; +import Zone from '@overflow/discovery/api/model/Zone'; import * as _ from 'lodash'; export interface StateProps { @@ -93,6 +94,7 @@ export class Discovery extends React.Component { let idx: number = Math.floor(Math.random() * (max - min + 1) + min); + idx = 2; switch(idx) { case 1: this.testHost(); @@ -121,6 +123,21 @@ export class Discovery extends React.Component { host.ports = null; } + // let zId: number = host.id / 2; + + // zId += 1; + // let z: Zone = { + // id: zId, + // network: '192.168.1.205/24', + // ip: '192.168.1.209', + // iface: 'iface', + // mac: 'macaddress', + // firstScanRange: 1, + // lastScanRange: 254, + // }; + + // host.zone = z; + this.props.onTestDiscovery('1', host); } public testPort(): void { diff --git a/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx b/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx index 9f06788..3bed8a3 100644 --- a/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx +++ b/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx @@ -18,6 +18,7 @@ import { import Host from '@overflow/discovery/api/model/Host'; import Port from '@overflow/discovery/api/model/Port'; import Service from '@overflow/discovery/api/model/Service'; +import Zone from '@overflow/discovery/api/model/Zone'; import Probe from '@overflow/probe/api/model/Probe'; import * as Utils from '@overflow/commons/util/Utils'; @@ -26,6 +27,7 @@ import * as Utils from '@overflow/commons/util/Utils'; export interface DiscoveryTreeStateProps { probeId: number; hostList: Host[]; + zoneList: Zone[]; onSetTargetList(discoveryHosts: Array): void; } @@ -105,6 +107,74 @@ export class DiscoveryTree extends React.Component + + + + , checkProps: CheckboxProps) => { + { + this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedHostState, host); + } + }} /> + + Host + {zone.hosts ? (this.state.portState[key] ? this.renderHost(zone.hosts, key) : null) : null} + + , + ); + + } + + return null; + } + + public renderHost(hostList: Host[], zoneKey: string): JSX.Element[] { + + let elems: JSX.Element[] = new Array(); + + let host: Host; + for (let index: number = 0; index < hostList.length; ++index) { + host = hostList[index]; + let key: string = String(host.ip); + elems.push( + + + + + , checkProps: CheckboxProps) => { + { + this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedHostState, host); + } + }} /> + + Host + {host.ports ? (this.state.portState[key] ? this.renderPort(host.ports, key) : null) : null} + + , + ); + } + return elems; + } + public renderDiscovery(): JSX.Element[] { if(this.props.hostList === undefined) { diff --git a/src/ts/@overflow/discovery/redux/reducer/ing.ts b/src/ts/@overflow/discovery/redux/reducer/ing.ts index a07e449..d66cbf6 100644 --- a/src/ts/@overflow/discovery/redux/reducer/ing.ts +++ b/src/ts/@overflow/discovery/redux/reducer/ing.ts @@ -124,6 +124,7 @@ const reducer: ReducersMapObject = { } + return { ...state, hostList: hostList, @@ -283,8 +284,9 @@ const reducer: ReducersMapObject = { function removeArray(array: any[], obj: any): any[] { let dIdx: number = array.indexOf(obj, 0); + if(dIdx > -1) { - array.slice(dIdx, 1); + array.splice(dIdx, 1 ); } return array;