diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index dda9a62..22b9edb 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -7,6 +7,7 @@ import signUpReducer from '@overflow/member/redux/reducer/signUp'; import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain'; import readProbeReducer from '@overflow/probe/redux/reducer/read'; import readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe'; +import readTargetReducer from '@overflow/target/redux/reducer/read'; import readAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target'; import SensorReadReducer from '@overflow/sensor/redux/reducer/read'; @@ -55,6 +56,7 @@ const reduxConfig: ReduxConfig = { signUpReducer, SensorItemReadAllBySensorReducer, readAllTargetByProbeReducer, + readTargetReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx b/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx index 30ff9aa..b199237 100644 --- a/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx +++ b/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx @@ -10,7 +10,7 @@ class TargetDetail extends React.Component, object> public render(): JSX.Element { return ( - + ); } } diff --git a/src/ts/@overflow/infra/react/components/InfraDetail.tsx b/src/ts/@overflow/infra/react/components/InfraDetail.tsx index 8c81f79..7297b64 100644 --- a/src/ts/@overflow/infra/react/components/InfraDetail.tsx +++ b/src/ts/@overflow/infra/react/components/InfraDetail.tsx @@ -13,7 +13,6 @@ import InfraOS from '@overflow/infra/api/model/InfraOS'; import * as Utils from '@overflow/commons/util/Utils'; export interface StateProps { - target?: Target; infra?: Infra; } @@ -41,15 +40,7 @@ export class InfraDetail extends React.Component { } public componentWillMount(): void { - // todo. getting infra and child infra - - // this.getInfraChild(); - - this.setState({ - childInfra: InfraHostJson, - }); - - + this.getInfraChild(); } public getInfraChild = () => { diff --git a/src/ts/@overflow/target/react/TargetDetail.tsx b/src/ts/@overflow/target/react/TargetDetail.tsx index 54d99b4..c8e3ea8 100644 --- a/src/ts/@overflow/target/react/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/TargetDetail.tsx @@ -6,17 +6,19 @@ import { } from './components/TargetDetail'; import * as targetDetailActions from '../redux/action/read'; +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; -export function mapStateToProps(state: any): StateProps { +export function mapStateToProps(state: any, props: any): StateProps { return { - // probe: state.probe, + id: props.params.id, + infra: state.infra, }; } export function mapDispatchToProps(dispatch: Dispatch): DispatchProps { return { onRead: (id: string) => { - dispatch(targetDetailActions.request(id)); + dispatch(asyncRequestActions.request('InfraService', 'read', targetDetailActions.REQUEST, id)); }, }; } diff --git a/src/ts/@overflow/target/react/TargetList.tsx b/src/ts/@overflow/target/react/TargetList.tsx index 1a4cc87..ea38d5b 100644 --- a/src/ts/@overflow/target/react/TargetList.tsx +++ b/src/ts/@overflow/target/react/TargetList.tsx @@ -13,7 +13,7 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques export function mapStateToProps(state: any, props: any): StateProps { return { probeId: props.params.id, - targetList: state.targetList, + infraList: state.infraList, }; } diff --git a/src/ts/@overflow/target/react/components/TargetDetail.tsx b/src/ts/@overflow/target/react/components/TargetDetail.tsx index edc2005..055e4c0 100644 --- a/src/ts/@overflow/target/react/components/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/components/TargetDetail.tsx @@ -3,20 +3,21 @@ import { Button, Table, Header, Container } from 'semantic-ui-react'; import { DetailContainer } from '@overflow/commons/react/component/DetailContainer'; import { TargetDetailInfra } from './TargetDetailInfra'; import InfraDetailContainer from '@overflow/infra/react/InfraDetail'; -import Target from '@overflow/target/api/model/Target'; +import Infra from '@overflow/infra/api/model/Infra'; export interface StateProps { + id: string; + infra: Infra; } export interface DispatchProps { + onRead(id: string): void; } export type Props = StateProps & DispatchProps; export interface State { - target: any; // todo. fix to Target - infra: any; } @@ -25,30 +26,11 @@ export class TargetDetail extends React.Component { constructor(props: Props, context: State) { super(props, context); this.state = { - target: null, - infra: null, }; } public componentWillMount(): void { - let data = { - 'id': '1', - 'createDate': '2017-01-01', - 'displayName': '192.168.1.105', - 'description': '', - 'sensorCount': 'todo.', - }; - let infra = { - 'id': '1', - 'createDate': '2017-01-01', - 'childId': '111', - 'type': 'Host', - }; - - this.setState({ - target: data, - infra: infra, - }); + this.props.onRead(this.props.id); } public handleRemoveTarget(): void { @@ -56,11 +38,14 @@ export class TargetDetail extends React.Component { } public render(): JSX.Element { + if (this.props.infra === undefined) { + return null; + } return ( - +
- +
@@ -70,8 +55,7 @@ export class TargetDetail extends React.Component { export interface TargetBasicInfoProps { - target?: any; // todo. fix to Target - infra: any; + infra?: Infra; } export interface TargetBasicInfoState { @@ -95,7 +79,7 @@ export class TargetBasicInfo extends React.ComponentName - {this.props.target.displayName} + {this.props.infra.target.displayName} @@ -104,7 +88,7 @@ export class TargetBasicInfo extends React.ComponentDescription - {this.props.target.description} + {this.props.infra.target.description} @@ -113,7 +97,7 @@ export class TargetBasicInfo extends React.ComponentSensor Count - {this.props.target.sensorCount} + TODO @@ -122,7 +106,7 @@ export class TargetBasicInfo extends React.ComponentCreated at - {this.props.target.createDate} + {this.props.infra.target.createDate} @@ -131,7 +115,7 @@ export class TargetBasicInfo extends React.ComponentType - {this.props.infra.type} + {this.props.infra.infraType.name} diff --git a/src/ts/@overflow/target/react/components/TargetList.tsx b/src/ts/@overflow/target/react/components/TargetList.tsx index 02e4ea5..4710e3f 100644 --- a/src/ts/@overflow/target/react/components/TargetList.tsx +++ b/src/ts/@overflow/target/react/components/TargetList.tsx @@ -1,14 +1,14 @@ import * as React from 'react'; import { Table, Button, Modal, Input, Header, Container, InputOnChangeData, ButtonProps } from 'semantic-ui-react'; import { TargetDetail } from './TargetDetail'; -import Target from '@overflow/target/api/model/Target'; +import Infra from '@overflow/infra/api/model/Infra'; import Probe from '@overflow/probe/api/model/Probe'; import { ListContainer } from '@overflow/commons/react/component/ListContainer'; import { Discovery } from '../../../discovery/react/components/Discovery'; export interface StateProps { probeId: string; - targetList: Target[]; + infraList: Infra[]; } export interface DispatchProps { @@ -19,7 +19,7 @@ export interface DispatchProps { export type Props = StateProps & DispatchProps; export interface State { - selected: Target; + selected: Infra; openAddTarget: boolean; } @@ -34,8 +34,8 @@ export class TargetList extends React.Component { } public componentWillMount(): void { - const probe: Probe = { - id: 1, + let probe: Probe = { + id: Number(this.props.probeId), }; this.props.onReadAllByProbe(probe); } @@ -56,7 +56,7 @@ export class TargetList extends React.Component { }); } - public handleSearch(result: Target[]): void { + public handleSearch(result: Infra[]): void { // this.setState({ // list: result, // }); @@ -81,12 +81,11 @@ export class TargetList extends React.Component { } public render(): JSX.Element { - if(this.props.targetList === undefined) { + if(this.props.infraList === undefined) { return null; } let targetList = - {/*search bar */}