discovery

This commit is contained in:
geek 2017-07-11 18:23:18 +09:00
parent 3cb82c50fd
commit cde1e4ac86
2 changed files with 84 additions and 15 deletions

View File

@ -1,14 +1,19 @@
import * as React from 'react'; import * as React from 'react';
import { Button, Modal, Checkbox } from 'semantic-ui-react';
import { DiscoveryProbe } from './DiscoveryProbe'; import { DiscoveryProbe } from './DiscoveryProbe';
import { DiscoveryTable } from './DiscoveryTable'; import { DiscoveryTable } from './DiscoveryTable';
export class DiscoveryDetails extends React.Component<any, any> { export class DiscoveryDetails extends React.Component<any, any> {
private probeTemp: any; private probeTemp: any;
private submitData: any;
constructor(props: any, context: any) { constructor(props: any, context: any) {
super(props, context); super(props, context);
this.state = {}; this.handleProbeChange.bind(this);
this.state = {
startPopup:false
};
} }
componentWillMount() { componentWillMount() {
@ -37,8 +42,18 @@ export class DiscoveryDetails extends React.Component<any, any> {
handleProbeChange(obj: any) { handleProbeChange(obj: any) {
console.log(obj) console.log(obj)
this.setState({ startPopup:true });
this.submitData = obj;
} }
handleSubmit() {
console.log(this.submitData)
}
handleCancel= () => this.setState({ startPopup: false });
handlePopupClose = () => this.setState({ startPopup: false });
render() { render() {
return ( return (
<div> <div>
@ -46,8 +61,20 @@ export class DiscoveryDetails extends React.Component<any, any> {
<DiscoveryProbe probe={this.probeTemp}/> <DiscoveryProbe probe={this.probeTemp}/>
</div> </div>
<div style={{ margin: '20px' }}> <div style={{ margin: '20px' }}>
<DiscoveryTable onProbeChange={this.handleProbeChange} /> <DiscoveryTable onProbeChange={this.handleProbeChange.bind(this)} />
</div> </div>
<Modal size='small' open={this.state.startPopup} onClose={this.handlePopupClose}>
<Modal.Header>Change your password Enter email address.</Modal.Header>
<Modal.Content >
<Checkbox label='IP' />
</Modal.Content>
<Modal.Actions>
<Button onClick={this.handleSubmit} basic color='blue' > Submit </Button>
<Button onClick={this.handleCancel}> Cancel </Button>
</Modal.Actions>
</Modal>
</div> </div>
); );

View File

@ -1,25 +1,67 @@
import * as React from 'react'; import * as React from 'react';
import { Table, Button, Input } from 'semantic-ui-react'; import {Table, Button, Input, InputProps, ButtonProps} from 'semantic-ui-react';
export class DiscoveryTable extends React.Component<any, any> { export class DiscoveryTable extends React.Component<any, any> {
constructor(props: any, context: any) { constructor(props: any, context: any) {
super(props, context); super(props, context);
this.state = { this.state = {
startIp: null,
endIP: null, endIP: null,
excludeIp: null,
startPort: null,
endPort: null
}; };
} }
handleEndIpInput(event: React.SyntheticEvent<HTMLAnchorElement>, data: any) { handleInput(event: React.SyntheticEvent<HTMLInputElement>, data: InputProps) {
console.log(data.value); // console.log( data.value);
this.setState({ // console.log( event.target);
endIP: data.value, // console.log(data.tabIndex);
});
let value: string = data.value;
switch (data.tabIndex) {
case '0':{
this.setState({
startIp: value,
});
break;
}
case '1':{
this.setState({
endIP: value,
});
break;
}
case '2':{
this.setState({
excludeIp: value,
});
break;
}
case '3':{
this.setState({
startPort: value,
});
break;
}
case '4':{
this.setState({
endPort: value,
});
break;
}
default:{
console.log("Error");
break;
}
}
console.log(this.state.startPort);
} }
discoveryStartHandler(event: React.SyntheticEvent<HTMLAnchorElement>, data: any) { discoveryStartHandler(event: React.SyntheticEvent<HTMLButtonElement>, data: ButtonProps) {
this.props.onProbeChange(data); this.props.onProbeChange(this.state);
} }
render() { render() {
@ -29,23 +71,23 @@ export class DiscoveryTable extends React.Component<any, any> {
<Table.Body> <Table.Body>
<Table.Row> <Table.Row>
<Table.Cell width='1'>Start IP</Table.Cell> <Table.Cell width='1'>Start IP</Table.Cell>
<Table.Cell width='6'><Input size='large' placeholder='Start IP' /></Table.Cell> <Table.Cell width='6'><Input tabIndex='0' size='large' placeholder='Start IP' onChange={this.handleInput.bind(this)} /></Table.Cell>
</Table.Row> </Table.Row>
<Table.Row> <Table.Row>
<Table.Cell>End IP</Table.Cell> <Table.Cell>End IP</Table.Cell>
<Table.Cell><Input size='large' placeholder='End IP' onChange={this.handleEndIpInput.bind(this)} /></Table.Cell> <Table.Cell><Input tabIndex='1' size='large' placeholder='End IP' onChange={this.handleInput.bind(this)} /></Table.Cell>
</Table.Row> </Table.Row>
<Table.Row> <Table.Row>
<Table.Cell>Exclude IP</Table.Cell> <Table.Cell>Exclude IP</Table.Cell>
<Table.Cell><Input size='large' placeholder='Exclude IP' /></Table.Cell> <Table.Cell><Input tabIndex='2' size='large' placeholder='Exclude IP' onChange={this.handleInput.bind(this)} /></Table.Cell>
</Table.Row> </Table.Row>
<Table.Row> <Table.Row>
<Table.Cell>Start Port</Table.Cell> <Table.Cell>Start Port</Table.Cell>
<Table.Cell><Input size='large' placeholder='Start Port' /></Table.Cell> <Table.Cell><Input tabIndex='3' size='large' placeholder='Start Port' onChange={this.handleInput.bind(this)} /></Table.Cell>
</Table.Row> </Table.Row>
<Table.Row> <Table.Row>
<Table.Cell>End Port</Table.Cell> <Table.Cell>End Port</Table.Cell>
<Table.Cell><Input size='large' placeholder='End Port' /></Table.Cell> <Table.Cell><Input tabIndex='4' size='large' placeholder='End Port' onChange={this.handleInput.bind(this)} /></Table.Cell>
</Table.Row> </Table.Row>
</Table.Body> </Table.Body>
</Table> </Table>