diff --git a/src/ts/@overflow/discovery/react/Discovery.tsx b/src/ts/@overflow/discovery/react/Discovery.tsx index ff7e8d0..176eb66 100644 --- a/src/ts/@overflow/discovery/react/Discovery.tsx +++ b/src/ts/@overflow/discovery/react/Discovery.tsx @@ -13,12 +13,19 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques export function mapStateToProps(state: any, props: any): DiscoveryStateProps { return { - probeId: props.probeId, + // probeId: props.probeId, + isSuccess: state.isSuccess, + // onRefreshList: props.onRefreshList, }; } export function mapDispatchToProps(dispatch: Dispatch): DiscoveryDispatchProps { 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))); + }, }; } diff --git a/src/ts/@overflow/discovery/react/DiscoveryTree.tsx b/src/ts/@overflow/discovery/react/DiscoveryTree.tsx index df13bb8..fcf9b12 100644 --- a/src/ts/@overflow/discovery/react/DiscoveryTree.tsx +++ b/src/ts/@overflow/discovery/react/DiscoveryTree.tsx @@ -16,16 +16,13 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques export function mapStateToProps(state: any, props: any): DiscoveryTreeStateProps { return { probeId: props.probeId, - isSuccess: state.isSuccess, + onSetTargetList: props.onSetTargetList, }; } export function mapDispatchToProps(dispatch: Dispatch): DiscoveryTreeDispatchProps { return { - onCreateTarget: (hosts: Host[], probe: Probe) => { - dispatch(asyncRequestActions.request('TargetDiscoveryService', 'saveAllTarget', - InfraTargetRegistAllActionTypes.REQUEST, JSON.stringify(hosts), JSON.stringify(probe))); - }, + }; } diff --git a/src/ts/@overflow/discovery/react/components/Discovery.tsx b/src/ts/@overflow/discovery/react/components/Discovery.tsx index 560dfe4..0ff024f 100644 --- a/src/ts/@overflow/discovery/react/components/Discovery.tsx +++ b/src/ts/@overflow/discovery/react/components/Discovery.tsx @@ -15,96 +15,101 @@ import Host from '@overflow/discovery/api/model/Host'; export interface StateProps { probeId?: Number; + open?: boolean; + isSuccess?: boolean; + onClosePopup?(bool: boolean): void; + onRefreshList?(): void; } export interface DispatchProps { - + onCreateTarget?(hosts: Host[], probe: Probe): void; } export type Props = StateProps & DispatchProps; export interface State { - startPopup:boolean; - probeTemp: any; + startPopup: boolean; + // 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 { private submitData: any; + private discoveryHosts: Array; public constructor(props: Props, context: State) { super(props, context); this.handleProbeChange.bind(this); this.state = { - startPopup:false, - probeTemp:null, + startPopup: false, }; } - public componentWillMount():void { - this.setState({probeTemp:probeTemp}); + public componentWillMount(): void { + // this.setState({probeTemp:probeTemp}); + } + + public componentWillReceiveProps?(nextProps: Readonly, 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 { console.log(obj); - this.setState({ startPopup:true }); - this.submitData = obj; + this.setState({ startPopup: true }); + // this.submitData = obj; } 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) => { - // this.props.onCreateTarget(hosts, probe); - // } + public onSetTargetList = (discoveryHosts: Array) => { + this.discoveryHosts = discoveryHosts; + } - public handleCancel= () => this.setState({ startPopup: false }); + public handleCancel = () => this.setState({ startPopup: false }); public handlePopupClose = () => this.setState({ startPopup: false }); - public render(): JSX.Element { + public render(): JSX.Element { return ( - -
Discovery Details
- {/**/} -
- + + + +
Discovery Details
+
+ - - Discovery - - {/**/} - - - - - - - + + Discovery + + + + + + + + + +
+
+ + + + +
-
); } diff --git a/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx b/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx index 4250c9d..0c6239a 100644 --- a/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx +++ b/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx @@ -8,7 +8,7 @@ import { Container, Label, Accordion, - Icon, + Icon, Header, List, Button, ListItemProps, CheckboxProps, @@ -25,11 +25,11 @@ import * as Utils from '@overflow/commons/util/Utils'; export interface DiscoveryTreeStateProps { probeId: number; - isSuccess: boolean; + onSetTargetList(discoveryHosts: Array): void; } export interface DiscoveryTreeDispatchProps { -onCreateTarget?(hosts: Host[], probe: Probe): void; + } export type DiscoveryTreeProps = DiscoveryTreeStateProps & DiscoveryTreeDispatchProps; @@ -65,7 +65,7 @@ export class DiscoveryTree extends React.Component + {/*
Discovery Result
*/} {this.renderDiscovery()} -

); } @@ -234,53 +225,223 @@ export class DiscoveryTree extends React.Component): InfraTargetRegistAllState => { + action: Action): InfraTargetRegistAllState => { return { ...state, - isSuccess: true, + isSuccess: action.payload, }; }, [InfraTargetRegistAllActionTypes.REQUEST_FAILURE]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState, diff --git a/src/ts/@overflow/sensor/react/SensorConfiguration.tsx b/src/ts/@overflow/sensor/react/SensorConfiguration.tsx index f394ee3..207467d 100644 --- a/src/ts/@overflow/sensor/react/SensorConfiguration.tsx +++ b/src/ts/@overflow/sensor/react/SensorConfiguration.tsx @@ -33,10 +33,10 @@ export function mapDispatchToProps(dispatch: Dispatch): SensorConfiguration }, // FIXME::how to sensor item? onReadMetaSensorItem: () => { - dispatch(SensorItemReadAllActions.request()); + // dispatch(SensorItemReadAllActions.request()); }, onSaveSensor: (sensor: Sensor) => { - dispatch(RegistActions.request(sensor)); + // dispatch(RegistActions.request(sensor)); }, }; } diff --git a/src/ts/@overflow/target/react/components/TargetChild.tsx b/src/ts/@overflow/target/react/components/TargetChild.tsx index a2166aa..6e219ca 100644 --- a/src/ts/@overflow/target/react/components/TargetChild.tsx +++ b/src/ts/@overflow/target/react/components/TargetChild.tsx @@ -260,7 +260,7 @@ export class TargetChild extends React.Component { NewTableDatas = [ { header: 'Host', - contents: infraChild.host.ip, + contents: Utils.int2ip(infraChild.host.ip), }, { header: 'Port', diff --git a/src/ts/@overflow/target/react/components/TargetList.tsx b/src/ts/@overflow/target/react/components/TargetList.tsx index 37c4cda..673f48d 100644 --- a/src/ts/@overflow/target/react/components/TargetList.tsx +++ b/src/ts/@overflow/target/react/components/TargetList.tsx @@ -15,9 +15,6 @@ export interface StateProps { infraList?: Infra[]; } - - - export interface DispatchProps { onReadAllByProbe?(probe: Probe): void; onReadAllByDomain?(domain: Domain): void; @@ -42,7 +39,10 @@ export class TargetList extends React.Component { } public componentWillMount(): void { + this.getTargetList(); + } + public getTargetList(): void { if (this.props.probeId === undefined) { // FIXME: get domain let domain: Domain = { @@ -55,8 +55,6 @@ export class TargetList extends React.Component { }; this.props.onReadAllByProbe(probe); } - - } public handleSelect(selectedTarget: any): void { @@ -81,6 +79,16 @@ export class TargetList extends React.Component { // }); } + public onClosePopup = (bool: boolean) => { + this.setState({ openAddTarget: bool }); + } + + public onRefreshList = () => { + console.log('onRefreshList'); + // this.setState({openAddTarget: false}); + this.getTargetList(); + } + public handleFilter(filterStr: string): void { // if (filterStr === null) { // this.setState({ @@ -130,20 +138,10 @@ export class TargetList extends React.Component { ))} - - {/**/} - {/*Adding a Target*/} - {/**/} - - - - - - - - + + + ; return (