diff --git a/src/ts/@overflow/discovery/react/DiscoveryTable.tsx b/src/ts/@overflow/discovery/react/DiscoveryTable.tsx new file mode 100644 index 0000000..c564ade --- /dev/null +++ b/src/ts/@overflow/discovery/react/DiscoveryTable.tsx @@ -0,0 +1,20 @@ +import { connect, Dispatch } from 'react-redux'; +import { + DiscoveryTable, + StateProps as DiscoveryTableStateProps, + DispatchProps as DiscoveryTableDispatchProps, +} from './components/DiscoveryTable'; + + +export function mapStateToProps(state: any, props: any): DiscoveryTableStateProps { + return { + onProbeChange: props.onProbeChange, + }; +} + +export function mapDispatchToProps(dispatch: Dispatch): DiscoveryTableDispatchProps { + return { + }; +} + +export default connect(mapStateToProps, mapDispatchToProps)(DiscoveryTable); diff --git a/src/ts/@overflow/discovery/react/components/Discovery.tsx b/src/ts/@overflow/discovery/react/components/Discovery.tsx index b33f2c1..f15669a 100644 --- a/src/ts/@overflow/discovery/react/components/Discovery.tsx +++ b/src/ts/@overflow/discovery/react/components/Discovery.tsx @@ -7,7 +7,7 @@ import { Container, } from 'semantic-ui-react'; import { DiscoveryProbe } from './DiscoveryProbe'; -import { DiscoveryTable } from './DiscoveryTable'; +import DiscoveryTableContainer from '../DiscoveryTable'; import DiscoveryTreeContainer from '../DiscoveryTree'; export interface StateProps { @@ -81,7 +81,7 @@ export class Discovery extends React.Component {
Discovery Details
{/**/}
- + Discovery diff --git a/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx b/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx index e17f74a..d4c6382 100644 --- a/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx +++ b/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx @@ -8,13 +8,20 @@ import { Dropdown, Container, Header, + DropdownProps, } from 'semantic-ui-react'; +import * as _ from 'lodash'; -export interface Props { - onProbeChange?(state:object):void; +export interface StateProps { } +export interface DispatchProps { + onProbeChange?(state: object): void; +} + +export type Props = StateProps & DispatchProps; + export interface State { startIp: string; endIP: string; @@ -26,6 +33,7 @@ export interface State { export class DiscoveryTable extends React.Component { private serviceTemp: any; + private selectedServices: number | string | Array; constructor(props: Props, context: State) { super(props, context); @@ -38,7 +46,7 @@ export class DiscoveryTable extends React.Component { }; } - public componentWillMount():void { + public componentWillMount(): void { // super.componentWillMount(); this.serviceTemp = [ { key: 'http', text: 'HTTP', value: 'http' }, @@ -58,44 +66,44 @@ export class DiscoveryTable extends React.Component { ]; } - public handleInput(event: React.SyntheticEvent, data: InputProps):void { + public handleInput(event: React.SyntheticEvent, data: InputProps): void { // console.log( data.value); // console.log( event.target); // console.log(data.tabIndex); let value: string = data.value; switch (data.tabIndex) { - case '1':{ + case '1': { this.setState({ startIp: value, }); break; } - case '2':{ + case '2': { this.setState({ endIP: value, }); break; } - case '3':{ + case '3': { this.setState({ excludeIp: value, }); break; } - case '4':{ + case '4': { this.setState({ startPort: value, }); break; } - case '5':{ + case '5': { this.setState({ endPort: value, }); break; } - default:{ + default: { console.log('Error'); break; } @@ -105,7 +113,14 @@ export class DiscoveryTable extends React.Component { } public discoveryStartHandler(event: React.SyntheticEvent, data: ButtonProps): void { - this.props.onProbeChange(this.state); + + let discoveryStartInfo: any = { + ...this.state, + services: this.selectedServices, + }; + + + this.props.onProbeChange(discoveryStartInfo); } public render(): JSX.Element { @@ -129,26 +144,25 @@ export class DiscoveryTable extends React.Component {
Port Range
-    - +    +
Service
- + , data: DropdownProps) => { + this.selectedServices = data.value; + }} />
- -
End Port
- -
-