discovery result - create target
This commit is contained in:
parent
b2fb18cd26
commit
11c538ff8b
11
src/ts/@overflow/discovery/api/model/DiscoveryStartInfo.ts
Normal file
11
src/ts/@overflow/discovery/api/model/DiscoveryStartInfo.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
interface DiscoveryStartInfo {
|
||||
startIp: string;
|
||||
endIP: string;
|
||||
excludeIp: string;
|
||||
startPort: string;
|
||||
endPort: string;
|
||||
selectedServices: Array<number | string>;
|
||||
}
|
||||
|
||||
export default DiscoveryStartInfo;
|
|
@ -6,9 +6,9 @@ import {
|
|||
} from './components/Discovery';
|
||||
|
||||
|
||||
export function mapStateToProps(state: any): DiscoveryStateProps {
|
||||
export function mapStateToProps(state: any, props: any): DiscoveryStateProps {
|
||||
return {
|
||||
|
||||
probeId: props.probeId,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,15 +6,25 @@ import {
|
|||
} from './components/DiscoveryTree';
|
||||
|
||||
|
||||
export function mapStateToProps(state: any): DiscoveryTreeStateProps {
|
||||
return {
|
||||
|
||||
import Host from '@overflow/discovery/api/model/Host';
|
||||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
|
||||
import * as InfraTargetRegistAllActionTypes from '../redux/action/infra_target_regist_all';
|
||||
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
||||
|
||||
export function mapStateToProps(state: any, props: any): DiscoveryTreeStateProps {
|
||||
return {
|
||||
probeId: props.probeId,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapDispatchToProps(dispatch: Dispatch<any>): DiscoveryTreeDispatchProps {
|
||||
return {
|
||||
|
||||
onCreateTarget: (hosts: Host[], probe: Probe) => {
|
||||
dispatch(asyncRequestActions.request('TargetDiscoveryService', 'saveAllTarget',
|
||||
InfraTargetRegistAllActionTypes.REQUEST, JSON.stringify(hosts), JSON.stringify(probe)));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@ import { DiscoveryProbe } from './DiscoveryProbe';
|
|||
import DiscoveryTableContainer from '../DiscoveryTable';
|
||||
import DiscoveryTreeContainer from '../DiscoveryTree';
|
||||
|
||||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
|
||||
export interface StateProps {
|
||||
probeId?: Number;
|
||||
}
|
||||
|
||||
export interface DispatchProps {
|
||||
|
@ -87,7 +90,7 @@ export class Discovery extends React.Component<Props, State> {
|
|||
<Modal.Header>Discovery</Modal.Header>
|
||||
<Modal.Content >
|
||||
{/*<Checkbox label='IP' />*/}
|
||||
<DiscoveryTreeContainer />
|
||||
<DiscoveryTreeContainer probeId={this.props.probeId}/>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button onClick={this.handleCancel}> Cancel </Button>
|
||||
|
|
|
@ -13,6 +13,8 @@ import {
|
|||
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import DiscoveryStartInfo from '../../api/model/DiscoveryStartInfo';
|
||||
|
||||
export interface StateProps {
|
||||
}
|
||||
|
||||
|
@ -113,10 +115,11 @@ export class DiscoveryTable extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
public discoveryStartHandler(event: React.SyntheticEvent<HTMLButtonElement>, data: ButtonProps): void {
|
||||
|
||||
let discoveryStartInfo: any = {
|
||||
// Array<number | string>
|
||||
let convert: any = this.selectedServices;
|
||||
let discoveryStartInfo: DiscoveryStartInfo = {
|
||||
...this.state,
|
||||
services: this.selectedServices,
|
||||
services: convert,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -18,13 +18,17 @@ 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 Probe from '@overflow/probe/api/model/Probe';
|
||||
|
||||
import * as Utils from '@overflow/commons/util/Utils';
|
||||
|
||||
|
||||
export interface DiscoveryTreeStateProps {
|
||||
probeId: number;
|
||||
}
|
||||
|
||||
export interface DiscoveryTreeDispatchProps {
|
||||
onCreateTarget?(hosts: Host[], probe: Probe): void;
|
||||
}
|
||||
|
||||
export type DiscoveryTreeProps = DiscoveryTreeStateProps & DiscoveryTreeDispatchProps;
|
||||
|
@ -44,6 +48,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
private selectedHostState: Map<string, boolean>;
|
||||
private selectedPortState: Map<string, boolean>;
|
||||
private selectedServiceState: Map<string, boolean>;
|
||||
private discoveryHosts: Array<Host>;
|
||||
|
||||
constructor(props: any, context: any) {
|
||||
super(props, context);
|
||||
|
@ -59,7 +64,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
this.selectedHostState = new Map;
|
||||
this.selectedPortState = new Map;
|
||||
this.selectedServiceState = new Map;
|
||||
|
||||
this.discoveryHosts = hostListJson;
|
||||
// fs.readFile('../../../../../dh.json', this.handlJSONFile);
|
||||
}
|
||||
|
||||
|
@ -83,10 +88,14 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
state[stateKey] = newCheckState;
|
||||
this.setState(state);
|
||||
|
||||
if (checkProps.checked) {
|
||||
selectedMap[key] = selectedObj;
|
||||
} else {
|
||||
delete selectedMap[key];
|
||||
// if (checkProps.checked) {
|
||||
// selectedMap[key] = selectedObj;
|
||||
// } else {
|
||||
// delete selectedMap[key];
|
||||
// }
|
||||
if(stateKey !== 'checkPortState') {
|
||||
let checkObj: any = selectedObj;
|
||||
checkObj.target = checkProps.checked;
|
||||
}
|
||||
|
||||
// if(selectedObj instanceof Host) {
|
||||
|
@ -98,7 +107,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
|
||||
let elems: JSX.Element[] = new Array();
|
||||
|
||||
let hostList: Host[] = hostListJson;
|
||||
let hostList: Host[] = this.discoveryHosts;
|
||||
let host: Host;
|
||||
for (let index: number = 0; index < hostList.length; ++index) {
|
||||
host = hostList[index];
|
||||
|
@ -145,7 +154,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
<List.Header> <Checkbox label={port.portNumber + ' ' + port.portType} checked={this.state.checkHostState[key]} onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, checkProps: CheckboxProps) => {
|
||||
{
|
||||
this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedPortState, port);
|
||||
this.onCheck(checkProps, this.state.checkPortState, key, 'checkPortState', this.selectedPortState, port);
|
||||
}
|
||||
}} /></List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Port</List.Description>
|
||||
|
@ -174,7 +183,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
checked={this.state.checkHostState[key]} onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, checkProps: CheckboxProps) => {
|
||||
{
|
||||
this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedServiceState, service);
|
||||
this.onCheck(checkProps, this.state.checkServiceState, key, 'checkServiceState', this.selectedServiceState, service);
|
||||
}
|
||||
}} /></List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Service</List.Description>
|
||||
|
@ -195,9 +204,10 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
{this.renderDiscovery()}
|
||||
</List>
|
||||
<Button primary floated='right' onClick={() => {
|
||||
console.log(this.selectedHostState);
|
||||
this.props.onCreateTarget(this.discoveryHosts, {id: this.props.probeId});
|
||||
{/*console.log(this.selectedHostState);
|
||||
console.log(this.selectedPortState);
|
||||
console.log(this.selectedServiceState);
|
||||
console.log(this.selectedServiceState);*/}
|
||||
}}>Test</Button><br /><br />
|
||||
</Container>
|
||||
);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/discovery/infra_target_regist_all/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/discovery/infra_target_regist_all/REQUEST/SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/discovery/infra_target_regist_all/REQUEST/FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/discovery/infra_target_regist_all/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/discovery/infra_target_regist_all/REQUEST/SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/discovery/infra_target_regist_all/REQUEST/FAILURE';
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
import Host from '@overflow/discovery/api/model/Host';
|
||||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
|
||||
interface InfraTargetRegistAllPayload {
|
||||
hosts: Host[];
|
||||
probe: Probe;
|
||||
}
|
||||
|
||||
export default InfraTargetRegistAllPayload;
|
|
@ -0,0 +1,25 @@
|
|||
import Action from '@overflow/commons/redux/Action';
|
||||
import { ReducersMapObject } from 'redux';
|
||||
|
||||
|
||||
import * as InfraTargetRegistAllActionTypes from '../action/infra_target_regist_all';
|
||||
import InfraTargetRegistAllState, { defaultState as infraTargetRegistAllDefaultState } from '../state/InfraTargetRegistAll';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[InfraTargetRegistAllActionTypes.REQUEST_SUCCESS]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState,
|
||||
action: Action<void>): InfraTargetRegistAllState => {
|
||||
return {
|
||||
...state,
|
||||
isSuccess: true,
|
||||
};
|
||||
},
|
||||
[InfraTargetRegistAllActionTypes.REQUEST_FAILURE]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState,
|
||||
action: Action<Error>): InfraTargetRegistAllState => {
|
||||
return {
|
||||
...state,
|
||||
error: action.error,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default reducer;
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
export interface State {
|
||||
readonly isSuccess: boolean;
|
||||
readonly error?: Error;
|
||||
}
|
||||
|
||||
export const defaultState: State = {
|
||||
isSuccess: undefined,
|
||||
error: undefined,
|
||||
};
|
||||
|
||||
export default State;
|
|
@ -5,7 +5,7 @@ import Infra from '@overflow/infra/api/model/Infra';
|
|||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
import Domain from '@overflow/domain/api/model/Domain';
|
||||
import { ListContainer } from '@overflow/commons/react/component/ListContainer';
|
||||
import { Discovery } from '../../../discovery/react/components/Discovery';
|
||||
import DiscoveryContainer from '../../../discovery/react/Discovery';
|
||||
|
||||
import * as Utils from '@overflow/commons/util/Utils';
|
||||
|
||||
|
@ -133,7 +133,7 @@ export class TargetList extends React.Component<Props, State> {
|
|||
{/*Adding a Target*/}
|
||||
{/*</Modal.Header>*/}
|
||||
<Modal.Content>
|
||||
<Discovery />
|
||||
<DiscoveryContainer probeId={Number(this.props.probeId)}/>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button onClick={() => this.setState({ openAddTarget: false })}>Cancel</Button>
|
||||
|
|
Loading…
Reference in New Issue
Block a user