dicoveryIng bug fix
This commit is contained in:
parent
adc99dc29a
commit
d2b83563f4
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Props, State> {
|
|||
|
||||
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<Props, State> {
|
|||
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 {
|
||||
|
|
|
@ -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<Host>): void;
|
||||
}
|
||||
|
||||
|
@ -105,6 +107,74 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
// }
|
||||
}
|
||||
|
||||
public renderZone(): JSX.Element[] {
|
||||
if(this.props.zoneList === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let elems: JSX.Element[] = new Array();
|
||||
|
||||
let zoneList: Zone[] = this.props.zoneList;
|
||||
let zone: Zone;
|
||||
|
||||
for (let index: number = 0; index < zoneList.length; ++index) {
|
||||
zone = zoneList[index];
|
||||
|
||||
let key: string = String(zone.ip) + 'zone';
|
||||
elems.push(
|
||||
<List.Item key={key + String(index)} >
|
||||
<List.Icon name={zone.ip ? (this.state.portState[key] ? 'chevron up' : 'chevron down') : 'file'}
|
||||
onClick={this.onClickHost.bind(this, key)} />
|
||||
<List.Content>
|
||||
<List.Header>
|
||||
<Checkbox label={zone.ip} checked={this.state.checkHostState[key]} onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, checkProps: CheckboxProps) => {
|
||||
{
|
||||
this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedHostState, host);
|
||||
}
|
||||
}} />
|
||||
</List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Host</List.Description>
|
||||
{zone.hosts ? (this.state.portState[key] ? this.renderHost(zone.hosts, key) : null) : null}
|
||||
</List.Content>
|
||||
</List.Item>,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
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(
|
||||
<List.Item key={key + String(index)} >
|
||||
<List.Icon name={host.ports ? (this.state.portState[key] ? 'chevron up' : 'chevron down') : 'file'}
|
||||
onClick={this.onClickHost.bind(this, key)} />
|
||||
<List.Content>
|
||||
<List.Header>
|
||||
<Checkbox label={Utils.int2ip(host.ip) + ' ' + host.os} checked={this.state.checkHostState[key]} onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, checkProps: CheckboxProps) => {
|
||||
{
|
||||
this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedHostState, host);
|
||||
}
|
||||
}} />
|
||||
</List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Host</List.Description>
|
||||
{host.ports ? (this.state.portState[key] ? this.renderPort(host.ports, key) : null) : null}
|
||||
</List.Content>
|
||||
</List.Item>,
|
||||
);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
public renderDiscovery(): JSX.Element[] {
|
||||
|
||||
if(this.props.hostList === undefined) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user