From 11c538ff8bb0f43206d0f9cdf5252073a4a5524a Mon Sep 17 00:00:00 2001 From: snoop Date: Tue, 22 Aug 2017 19:21:59 +0900 Subject: [PATCH] discovery result - create target --- .../discovery/api/model/DiscoveryStartInfo.ts | 11 +++++++ .../@overflow/discovery/react/Discovery.tsx | 4 +-- .../discovery/react/DiscoveryTree.tsx | 16 ++++++++-- .../discovery/react/components/Discovery.tsx | 5 +++- .../react/components/DiscoveryTable.tsx | 11 ++++--- .../react/components/DiscoveryTree.tsx | 30 ++++++++++++------- .../redux/action/infra_target_regist_all.ts | 10 +++++++ .../payload/InfraTargetRegistAllPayload.ts | 10 +++++++ .../redux/reducer/infra_target_regist_all.ts | 25 ++++++++++++++++ .../redux/state/InfraTargetRegistAll.ts | 12 ++++++++ .../target/react/components/TargetList.tsx | 4 +-- 11 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 src/ts/@overflow/discovery/api/model/DiscoveryStartInfo.ts create mode 100644 src/ts/@overflow/discovery/redux/action/infra_target_regist_all.ts create mode 100644 src/ts/@overflow/discovery/redux/payload/InfraTargetRegistAllPayload.ts create mode 100644 src/ts/@overflow/discovery/redux/reducer/infra_target_regist_all.ts create mode 100644 src/ts/@overflow/discovery/redux/state/InfraTargetRegistAll.ts diff --git a/src/ts/@overflow/discovery/api/model/DiscoveryStartInfo.ts b/src/ts/@overflow/discovery/api/model/DiscoveryStartInfo.ts new file mode 100644 index 0000000..1cff7ac --- /dev/null +++ b/src/ts/@overflow/discovery/api/model/DiscoveryStartInfo.ts @@ -0,0 +1,11 @@ + +interface DiscoveryStartInfo { + startIp: string; + endIP: string; + excludeIp: string; + startPort: string; + endPort: string; + selectedServices: Array; +} + +export default DiscoveryStartInfo; diff --git a/src/ts/@overflow/discovery/react/Discovery.tsx b/src/ts/@overflow/discovery/react/Discovery.tsx index 1446b40..6a937e1 100644 --- a/src/ts/@overflow/discovery/react/Discovery.tsx +++ b/src/ts/@overflow/discovery/react/Discovery.tsx @@ -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, }; } diff --git a/src/ts/@overflow/discovery/react/DiscoveryTree.tsx b/src/ts/@overflow/discovery/react/DiscoveryTree.tsx index 96aee40..9667aef 100644 --- a/src/ts/@overflow/discovery/react/DiscoveryTree.tsx +++ b/src/ts/@overflow/discovery/react/DiscoveryTree.tsx @@ -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): 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 f15669a..5343b20 100644 --- a/src/ts/@overflow/discovery/react/components/Discovery.tsx +++ b/src/ts/@overflow/discovery/react/components/Discovery.tsx @@ -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 { Discovery {/**/} - + diff --git a/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx b/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx index d4c6382..d7626f9 100644 --- a/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx +++ b/src/ts/@overflow/discovery/react/components/DiscoveryTable.tsx @@ -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 { } public discoveryStartHandler(event: React.SyntheticEvent, data: ButtonProps): void { - - let discoveryStartInfo: any = { + // Array + let convert: any = this.selectedServices; + let discoveryStartInfo: DiscoveryStartInfo = { ...this.state, - services: this.selectedServices, + services: convert, }; @@ -153,7 +156,7 @@ export class DiscoveryTable extends React.Component { , data: DropdownProps) => { - this.selectedServices = data.value; + this.selectedServices = data.value; }} /> diff --git a/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx b/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx index bf989ee..de930af 100644 --- a/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx +++ b/src/ts/@overflow/discovery/react/components/DiscoveryTree.tsx @@ -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; private selectedPortState: Map; private selectedServiceState: Map; + private discoveryHosts: Array; constructor(props: any, context: any) { super(props, context); @@ -59,7 +64,7 @@ export class DiscoveryTree extends React.Component , checkProps: CheckboxProps) => { { - this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedPortState, port); + this.onCheck(checkProps, this.state.checkPortState, key, 'checkPortState', this.selectedPortState, port); } }} /> Port @@ -174,7 +183,7 @@ export class DiscoveryTree extends React.Component, checkProps: CheckboxProps) => { { - this.onCheck(checkProps, this.state.checkHostState, key, 'checkHostState', this.selectedServiceState, service); + this.onCheck(checkProps, this.state.checkServiceState, key, 'checkServiceState', this.selectedServiceState, service); } }} /> Service @@ -195,9 +204,10 @@ export class DiscoveryTree extends React.Component

); diff --git a/src/ts/@overflow/discovery/redux/action/infra_target_regist_all.ts b/src/ts/@overflow/discovery/redux/action/infra_target_regist_all.ts new file mode 100644 index 0000000..59318d0 --- /dev/null +++ b/src/ts/@overflow/discovery/redux/action/infra_target_regist_all.ts @@ -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'; + diff --git a/src/ts/@overflow/discovery/redux/payload/InfraTargetRegistAllPayload.ts b/src/ts/@overflow/discovery/redux/payload/InfraTargetRegistAllPayload.ts new file mode 100644 index 0000000..70d3abd --- /dev/null +++ b/src/ts/@overflow/discovery/redux/payload/InfraTargetRegistAllPayload.ts @@ -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; diff --git a/src/ts/@overflow/discovery/redux/reducer/infra_target_regist_all.ts b/src/ts/@overflow/discovery/redux/reducer/infra_target_regist_all.ts new file mode 100644 index 0000000..070a251 --- /dev/null +++ b/src/ts/@overflow/discovery/redux/reducer/infra_target_regist_all.ts @@ -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): InfraTargetRegistAllState => { + return { + ...state, + isSuccess: true, + }; + }, + [InfraTargetRegistAllActionTypes.REQUEST_FAILURE]: (state: InfraTargetRegistAllState = infraTargetRegistAllDefaultState, + action: Action): InfraTargetRegistAllState => { + return { + ...state, + error: action.error, + }; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/discovery/redux/state/InfraTargetRegistAll.ts b/src/ts/@overflow/discovery/redux/state/InfraTargetRegistAll.ts new file mode 100644 index 0000000..b47a0ae --- /dev/null +++ b/src/ts/@overflow/discovery/redux/state/InfraTargetRegistAll.ts @@ -0,0 +1,12 @@ + +export interface State { + readonly isSuccess: boolean; + readonly error?: Error; +} + +export const defaultState: State = { + isSuccess: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/target/react/components/TargetList.tsx b/src/ts/@overflow/target/react/components/TargetList.tsx index 1b68dec..f823be4 100644 --- a/src/ts/@overflow/target/react/components/TargetList.tsx +++ b/src/ts/@overflow/target/react/components/TargetList.tsx @@ -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 { {/*Adding a Target*/} {/**/} - +