Discovery
This commit is contained in:
		
							parent
							
								
									d4ea194612
								
							
						
					
					
						commit
						bd89cfdae6
					
				| @ -13,12 +13,19 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques | |||||||
| 
 | 
 | ||||||
| export function mapStateToProps(state: any, props: any): DiscoveryStateProps { | export function mapStateToProps(state: any, props: any): DiscoveryStateProps { | ||||||
|   return { |   return { | ||||||
|     probeId: props.probeId, |     // probeId: props.probeId,
 | ||||||
|  |     isSuccess: state.isSuccess, | ||||||
|  |     // onRefreshList: props.onRefreshList,
 | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function mapDispatchToProps(dispatch: Dispatch<any>): DiscoveryDispatchProps { | export function mapDispatchToProps(dispatch: Dispatch<any>): DiscoveryDispatchProps { | ||||||
|   return { |   return { | ||||||
|  |     onCreateTarget: (hosts: Host[], probe: Probe) => { | ||||||
|  |       console.log('hosts size : ' + JSON.stringify(hosts).length); | ||||||
|  |       dispatch(asyncRequestActions.request('TargetDiscoveryService', 'saveAllTarget', | ||||||
|  |                                            InfraTargetRegistAllActionTypes.REQUEST, JSON.stringify(hosts), JSON.stringify(probe))); | ||||||
|  |     }, | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,16 +16,13 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques | |||||||
| export function mapStateToProps(state: any, props: any): DiscoveryTreeStateProps { | export function mapStateToProps(state: any, props: any): DiscoveryTreeStateProps { | ||||||
|   return { |   return { | ||||||
|     probeId: props.probeId, |     probeId: props.probeId, | ||||||
|     isSuccess: state.isSuccess, |     onSetTargetList: props.onSetTargetList, | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function mapDispatchToProps(dispatch: Dispatch<any>): DiscoveryTreeDispatchProps { | export function mapDispatchToProps(dispatch: Dispatch<any>): DiscoveryTreeDispatchProps { | ||||||
|   return { |   return { | ||||||
|     onCreateTarget: (hosts: Host[], probe: Probe) => { | 
 | ||||||
|       dispatch(asyncRequestActions.request('TargetDiscoveryService', 'saveAllTarget', |  | ||||||
|                                            InfraTargetRegistAllActionTypes.REQUEST, JSON.stringify(hosts), JSON.stringify(probe))); |  | ||||||
|     }, |  | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -15,70 +15,66 @@ import Host from '@overflow/discovery/api/model/Host'; | |||||||
| 
 | 
 | ||||||
| export interface StateProps { | export interface StateProps { | ||||||
|   probeId?: Number; |   probeId?: Number; | ||||||
|  |   open?: boolean; | ||||||
|  |   isSuccess?: boolean; | ||||||
|  |   onClosePopup?(bool: boolean): void; | ||||||
|  |   onRefreshList?(): void; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface DispatchProps { | export interface DispatchProps { | ||||||
| 
 |   onCreateTarget?(hosts: Host[], probe: Probe): void; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export type Props = StateProps & DispatchProps; | export type Props = StateProps & DispatchProps; | ||||||
| 
 | 
 | ||||||
| export interface State { | export interface State { | ||||||
|   startPopup: boolean; |   startPopup: boolean; | ||||||
|   probeTemp: any; |   // probeTemp: any;
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const probeTemp:Object = { |  | ||||||
|   'id': '11', |  | ||||||
|   'metaProbeStatus': { |  | ||||||
|     'name': 'STARTED', |  | ||||||
|   }, |  | ||||||
|   'domain': { |  | ||||||
|     'name': 'overFlow\'s domain111', |  | ||||||
|   }, |  | ||||||
|   'host': { |  | ||||||
|     'ip': '192.168.1.103', |  | ||||||
|     'mac': '44:8a:5b:44:8c:e8', |  | ||||||
|     'os': 'Ubuntu 17.04', |  | ||||||
|     'name': '?????', |  | ||||||
|   }, |  | ||||||
|   'createAt': '2017-07-12', |  | ||||||
|   'probeKey': 'AGBLKDFJ2452ASDGFL2KWJLKSDJ', |  | ||||||
|   'description': 'description1111111111', |  | ||||||
|   'lastPollingAt': '2017-07-12 14:20', |  | ||||||
|   'nextPollingAt': '2017-07-12 14:30', |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| export class Discovery extends React.Component<Props, State> { | export class Discovery extends React.Component<Props, State> { | ||||||
| 
 | 
 | ||||||
|   private submitData: any; |   private submitData: any; | ||||||
|  |   private discoveryHosts: Array<Host>; | ||||||
| 
 | 
 | ||||||
|   public constructor(props: Props, context: State) { |   public constructor(props: Props, context: State) { | ||||||
|     super(props, context); |     super(props, context); | ||||||
|     this.handleProbeChange.bind(this); |     this.handleProbeChange.bind(this); | ||||||
|     this.state = { |     this.state = { | ||||||
|       startPopup: false, |       startPopup: false, | ||||||
|       probeTemp:null, |  | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public componentWillMount(): void { |   public componentWillMount(): void { | ||||||
|     this.setState({probeTemp:probeTemp}); |     // this.setState({probeTemp:probeTemp});
 | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public componentWillReceiveProps?(nextProps: Readonly<Props>, nextContext: any): void { | ||||||
|  |     if (this.props.isSuccess === undefined || this.props.isSuccess === false) { | ||||||
|  |       if (nextProps.isSuccess === true) { | ||||||
|  |         // this.props.onClosePopup(false);
 | ||||||
|  |         this.props.onRefreshList(); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public handleProbeChange(obj: Object): void { |   public handleProbeChange(obj: Object): void { | ||||||
|     console.log(obj); |     console.log(obj); | ||||||
|     this.setState({ startPopup: true }); |     this.setState({ startPopup: true }); | ||||||
|     this.submitData = obj; |     // this.submitData = obj;
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public handleSubmit(): void { |   public handleSubmit(): void { | ||||||
|     console.log(this.submitData); |     // console.log(this.discoveryHosts);
 | ||||||
|  |     this.setState({startPopup:false}); | ||||||
|  |     this.props.onCreateTarget(this.discoveryHosts, { id: Number(this.props.probeId) }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // public onPropsCreateTarget = (hosts: Host[], probe: Probe) => {
 |   public onSetTargetList = (discoveryHosts: Array<Host>) => { | ||||||
|   //   this.props.onCreateTarget(hosts, probe);
 |     this.discoveryHosts = discoveryHosts; | ||||||
|   // }
 |   } | ||||||
| 
 | 
 | ||||||
|   public handleCancel = () => this.setState({ startPopup: false }); |   public handleCancel = () => this.setState({ startPopup: false }); | ||||||
| 
 | 
 | ||||||
| @ -86,17 +82,19 @@ export class Discovery extends React.Component<Props, State> { | |||||||
| 
 | 
 | ||||||
|   public render(): JSX.Element { |   public render(): JSX.Element { | ||||||
|     return ( |     return ( | ||||||
|  |       <Modal | ||||||
|  |         open={this.props.open} | ||||||
|  |       > | ||||||
|  |         <Modal.Content> | ||||||
|           <Container fluid> |           <Container fluid> | ||||||
|             <Header as='h3' dividing> Discovery Details</Header> |             <Header as='h3' dividing> Discovery Details</Header> | ||||||
|         {/*<DiscoveryProbe probe={this.state.probeTemp}/>*/} |  | ||||||
|             <br /> |             <br /> | ||||||
|             <DiscoveryTableContainer onProbeChange={this.handleProbeChange.bind(this)} /> |             <DiscoveryTableContainer onProbeChange={this.handleProbeChange.bind(this)} /> | ||||||
| 
 | 
 | ||||||
|             <Modal size='small' open={this.state.startPopup} onClose={this.handlePopupClose}> |             <Modal size='small' open={this.state.startPopup} onClose={this.handlePopupClose}> | ||||||
|               <Modal.Header>Discovery</Modal.Header> |               <Modal.Header>Discovery</Modal.Header> | ||||||
|               <Modal.Content > |               <Modal.Content > | ||||||
|             {/*<Checkbox label='IP' />*/} |                 <DiscoveryTreeContainer probeId={this.props.probeId} onSetTargetList={this.onSetTargetList.bind(this)} /> | ||||||
|             <DiscoveryTreeContainer probeId={this.props.probeId} /> |  | ||||||
|               </Modal.Content> |               </Modal.Content> | ||||||
|               <Modal.Actions> |               <Modal.Actions> | ||||||
|                 <Button onClick={this.handleCancel}>              Cancel      </Button> |                 <Button onClick={this.handleCancel}>              Cancel      </Button> | ||||||
| @ -105,6 +103,13 @@ export class Discovery extends React.Component<Props, State> { | |||||||
|             </Modal> |             </Modal> | ||||||
| 
 | 
 | ||||||
|           </Container> |           </Container> | ||||||
|  |         </Modal.Content> | ||||||
|  |         <Modal.Actions> | ||||||
|  |           <Button onClick={() => this.props.onClosePopup(false)}>Cancel</Button> | ||||||
|  |           <Button primary >Done</Button> | ||||||
|  |         </Modal.Actions> | ||||||
|  |       </Modal> | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ import { | |||||||
|   Container, |   Container, | ||||||
|   Label, |   Label, | ||||||
|   Accordion, |   Accordion, | ||||||
|   Icon, |   Icon, Header, | ||||||
|   List, Button, |   List, Button, | ||||||
|   ListItemProps, |   ListItemProps, | ||||||
|   CheckboxProps, |   CheckboxProps, | ||||||
| @ -25,11 +25,11 @@ import * as Utils from '@overflow/commons/util/Utils'; | |||||||
| 
 | 
 | ||||||
| export interface DiscoveryTreeStateProps { | export interface DiscoveryTreeStateProps { | ||||||
|   probeId: number; |   probeId: number; | ||||||
|   isSuccess: boolean; |   onSetTargetList(discoveryHosts: Array<Host>): void; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface DiscoveryTreeDispatchProps { | export interface DiscoveryTreeDispatchProps { | ||||||
| onCreateTarget?(hosts: Host[], probe: Probe): void; | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export type DiscoveryTreeProps = DiscoveryTreeStateProps & DiscoveryTreeDispatchProps; | export type DiscoveryTreeProps = DiscoveryTreeStateProps & DiscoveryTreeDispatchProps; | ||||||
| @ -65,7 +65,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery | |||||||
|     this.selectedHostState = new Map; |     this.selectedHostState = new Map; | ||||||
|     this.selectedPortState = new Map; |     this.selectedPortState = new Map; | ||||||
|     this.selectedServiceState = new Map; |     this.selectedServiceState = new Map; | ||||||
|     this.discoveryHosts = hostListJsonMini; |     this.discoveryHosts = hostListJson; | ||||||
|     // fs.readFile('../../../../../dh.json', this.handlJSONFile);
 |     // fs.readFile('../../../../../dh.json', this.handlJSONFile);
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -98,7 +98,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery | |||||||
|       let checkObj: any = selectedObj; |       let checkObj: any = selectedObj; | ||||||
|       checkObj.target = checkProps.checked; |       checkObj.target = checkProps.checked; | ||||||
|     } |     } | ||||||
| 
 |     this.props.onSetTargetList(this.discoveryHosts); | ||||||
|     // if(selectedObj instanceof Host) {
 |     // if(selectedObj instanceof Host) {
 | ||||||
|     //   console.log(selectedObj);
 |     //   console.log(selectedObj);
 | ||||||
|     // }
 |     // }
 | ||||||
| @ -199,21 +199,12 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery | |||||||
| 
 | 
 | ||||||
|   public render(): JSX.Element { |   public render(): JSX.Element { | ||||||
| 
 | 
 | ||||||
|     if(this.props.isSuccess !== undefined) { |  | ||||||
|       alert('infra created'); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return ( |     return ( | ||||||
|       <Container fluid> |       <Container fluid> | ||||||
|  |         {/*<Header as='h3' dividing> Discovery Result</Header>*/} | ||||||
|         <List selection> |         <List selection> | ||||||
|           {this.renderDiscovery()} |           {this.renderDiscovery()} | ||||||
|         </List> |         </List> | ||||||
|         <Button primary floated='right' onClick={() => { |  | ||||||
|           this.props.onCreateTarget(this.discoveryHosts, {id: this.props.probeId}); |  | ||||||
|           {/*console.log(this.selectedHostState); |  | ||||||
|           console.log(this.selectedPortState); |  | ||||||
|           console.log(this.selectedServiceState);*/} |  | ||||||
|         }}>Test</Button><br /><br /> |  | ||||||
|       </Container> |       </Container> | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| @ -450,3 +441,57 @@ const hostListJsonMini: any = [ | |||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | const hostListJsonMini2: any = [{ | ||||||
|  |   'firstScanRange': 1, | ||||||
|  |   'lastScanRange': 10000, | ||||||
|  |   'name': '', | ||||||
|  |   'ip': 3232235781, | ||||||
|  |   'mac': 91754660625, | ||||||
|  |   'os': 'Windows', | ||||||
|  |   'ports': [{ | ||||||
|  |     'createDate': -62135596800000, | ||||||
|  |     'updateDate': -62135596800000, | ||||||
|  |     'services': [{ | ||||||
|  |       'createDate': -62135596800000, | ||||||
|  |       'updateDate': -62135596800000, | ||||||
|  |       'portType': 'TCP', | ||||||
|  |       'serviceName': 'SSH', | ||||||
|  |     }], | ||||||
|  |     'portType': 'TCP', | ||||||
|  |     'portNumber': 22, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     'createDate': -62135596800000, | ||||||
|  |     'updateDate': -62135596800000, | ||||||
|  |     'services': [{ | ||||||
|  |       'createDate': -62135596800000, | ||||||
|  |       'updateDate': -62135596800000, | ||||||
|  |       'portType': 'TCP', | ||||||
|  |       'serviceName': 'HTTP', | ||||||
|  |     }], | ||||||
|  |     'portType': 'TCP', | ||||||
|  |     'portNumber': 80, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     'createDate': -62135596800000, | ||||||
|  |     'updateDate': -62135596800000, | ||||||
|  |     'services': [{ | ||||||
|  |       'createDate': -62135596800000, | ||||||
|  |       'updateDate': -62135596800000, | ||||||
|  |       'portType': 'TCP', | ||||||
|  |       'serviceName': 'HTTP', | ||||||
|  |     }], | ||||||
|  |     'portType': 'TCP', | ||||||
|  |     'portNumber': 1936, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     'createDate': -62135596800000, | ||||||
|  |     'updateDate': -62135596800000, | ||||||
|  |     'services': null, | ||||||
|  |     'portType': 'TCP', | ||||||
|  |     'portNumber': 443, | ||||||
|  |   }], | ||||||
|  |   'createDate': 1498470178000, | ||||||
|  |   'updateDate': 1498470178000, | ||||||
|  | }, | ||||||
|  | ]; | ||||||
|  | |||||||
| @ -7,10 +7,10 @@ import InfraTargetRegistAllState, { defaultState as infraTargetRegistAllDefaultS | |||||||
| 
 | 
 | ||||||
| const reducer: ReducersMapObject = { | const reducer: ReducersMapObject = { | ||||||
|   [InfraTargetRegistAllActionTypes.REQUEST_SUCCESS]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState, |   [InfraTargetRegistAllActionTypes.REQUEST_SUCCESS]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState, | ||||||
|                                                       action: Action<void>): InfraTargetRegistAllState => { |                                                       action: Action<boolean>): InfraTargetRegistAllState => { | ||||||
|     return { |     return { | ||||||
|       ...state, |       ...state, | ||||||
|       isSuccess: true, |       isSuccess: action.payload, | ||||||
|     }; |     }; | ||||||
|   }, |   }, | ||||||
|   [InfraTargetRegistAllActionTypes.REQUEST_FAILURE]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState, |   [InfraTargetRegistAllActionTypes.REQUEST_FAILURE]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState, | ||||||
|  | |||||||
| @ -33,10 +33,10 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfiguration | |||||||
|     }, |     }, | ||||||
|     // FIXME::how to sensor item?
 |     // FIXME::how to sensor item?
 | ||||||
|     onReadMetaSensorItem: () => { |     onReadMetaSensorItem: () => { | ||||||
|       dispatch(SensorItemReadAllActions.request()); |       // dispatch(SensorItemReadAllActions.request());
 | ||||||
|     }, |     }, | ||||||
|     onSaveSensor: (sensor: Sensor) => { |     onSaveSensor: (sensor: Sensor) => { | ||||||
|       dispatch(RegistActions.request(sensor)); |       // dispatch(RegistActions.request(sensor));
 | ||||||
|     }, |     }, | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  | |||||||
| @ -260,7 +260,7 @@ export class TargetChild extends React.Component<Props, State> { | |||||||
|     NewTableDatas = [ |     NewTableDatas = [ | ||||||
|       { |       { | ||||||
|         header: 'Host', |         header: 'Host', | ||||||
|         contents: infraChild.host.ip, |         contents: Utils.int2ip(infraChild.host.ip), | ||||||
|       }, |       }, | ||||||
|       { |       { | ||||||
|         header: 'Port', |         header: 'Port', | ||||||
|  | |||||||
| @ -15,9 +15,6 @@ export interface StateProps { | |||||||
|   infraList?: Infra[]; |   infraList?: Infra[]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| export interface DispatchProps { | export interface DispatchProps { | ||||||
|   onReadAllByProbe?(probe: Probe): void; |   onReadAllByProbe?(probe: Probe): void; | ||||||
|   onReadAllByDomain?(domain: Domain): void; |   onReadAllByDomain?(domain: Domain): void; | ||||||
| @ -42,7 +39,10 @@ export class TargetList extends React.Component<Props, State> { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public componentWillMount(): void { |   public componentWillMount(): void { | ||||||
|  |     this.getTargetList(); | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|  |   public getTargetList(): void { | ||||||
|     if (this.props.probeId === undefined) { |     if (this.props.probeId === undefined) { | ||||||
|       // FIXME: get domain
 |       // FIXME: get domain
 | ||||||
|       let domain: Domain = { |       let domain: Domain = { | ||||||
| @ -55,8 +55,6 @@ export class TargetList extends React.Component<Props, State> { | |||||||
|       }; |       }; | ||||||
|       this.props.onReadAllByProbe(probe); |       this.props.onReadAllByProbe(probe); | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public handleSelect(selectedTarget: any): void { |   public handleSelect(selectedTarget: any): void { | ||||||
| @ -81,6 +79,16 @@ export class TargetList extends React.Component<Props, State> { | |||||||
|     // });
 |     // });
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   public onClosePopup = (bool: boolean) => { | ||||||
|  |     this.setState({ openAddTarget: bool }); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public onRefreshList = () => { | ||||||
|  |     console.log('onRefreshList'); | ||||||
|  |     // this.setState({openAddTarget: false});
 | ||||||
|  |     this.getTargetList(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   public handleFilter(filterStr: string): void { |   public handleFilter(filterStr: string): void { | ||||||
|     // if (filterStr === null) {
 |     // if (filterStr === null) {
 | ||||||
|     //   this.setState({
 |     //   this.setState({
 | ||||||
| @ -130,20 +138,10 @@ export class TargetList extends React.Component<Props, State> { | |||||||
|             ))} |             ))} | ||||||
|           </Table.Body> |           </Table.Body> | ||||||
|         </Table> |         </Table> | ||||||
|         <Modal | 
 | ||||||
|           open={this.state.openAddTarget} |         <DiscoveryContainer probeId={1} open={this.state.openAddTarget} | ||||||
|         > |          onClosePopup={this.onClosePopup.bind(this)} onRefreshList={this.onRefreshList} /> | ||||||
|           {/*<Modal.Header>*/} | 
 | ||||||
|           {/*Adding a Target*/} |  | ||||||
|           {/*</Modal.Header>*/} |  | ||||||
|           <Modal.Content> |  | ||||||
|             <DiscoveryContainer probeId={1}/> |  | ||||||
|           </Modal.Content> |  | ||||||
|           <Modal.Actions> |  | ||||||
|             <Button onClick={() => this.setState({ openAddTarget: false })}>Cancel</Button> |  | ||||||
|             <Button primary >Done</Button> |  | ||||||
|           </Modal.Actions> |  | ||||||
|         </Modal> |  | ||||||
|       </Container>; |       </Container>; | ||||||
|     return ( |     return ( | ||||||
|       <ListContainer |       <ListContainer | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user