From 9bec53200009b8a7475d5003c558d61d88be276f Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 20 Jul 2017 17:12:24 +0900 Subject: [PATCH] add container sensor --- .../sensor/api/service/SensorService.ts | 2 +- .../@overflow/sensor/react/SensorDetail.tsx | 27 +++++++++++++++++++ .../{SensorDetails.tsx => SensorDetail.tsx} | 13 ++++++--- .../sensor/react/components/SensorList.tsx | 4 +-- src/ts/@overflow/sensor/redux/action/read.ts | 4 +-- .../sensor/redux/payload/ReadPayload.ts | 2 +- 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 src/ts/@overflow/sensor/react/SensorDetail.tsx rename src/ts/@overflow/sensor/react/components/{SensorDetails.tsx => SensorDetail.tsx} (91%) diff --git a/src/ts/@overflow/sensor/api/service/SensorService.ts b/src/ts/@overflow/sensor/api/service/SensorService.ts index 527da98..47906c6 100644 --- a/src/ts/@overflow/sensor/api/service/SensorService.ts +++ b/src/ts/@overflow/sensor/api/service/SensorService.ts @@ -17,7 +17,7 @@ export class SensorService extends Service { return null; } - public read(id:string): Promise { + public read(id:number): Promise { return null; } diff --git a/src/ts/@overflow/sensor/react/SensorDetail.tsx b/src/ts/@overflow/sensor/react/SensorDetail.tsx new file mode 100644 index 0000000..f2d3754 --- /dev/null +++ b/src/ts/@overflow/sensor/react/SensorDetail.tsx @@ -0,0 +1,27 @@ +import { connect, Dispatch } from 'react-redux'; +import { + SensorDetail, + SensorDetailStateProps, + SensorDetailDispatchProps, +} from './components/SensorDetail'; +import State from '../redux/state/ReadAllByTarget'; + +import * as ReadAllByTargetActions from '../redux/action/read_all_by_target'; +import Target from '@overflow/target/api/model/Target'; +import Sensor from '@overflow/sensor/api/model/Sensor'; + +export function mapStateToProps(state: any): SensorDetailStateProps { + return { + }; +} + +export function mapDispatchToProps(dispatch: Dispatch): SensorDetailDispatchProps { + return { + onReadAllByTarget: (target: Target) => { + dispatch(ReadAllByTargetActions.request(target)); + }, + }; +} + + +export default connect(mapStateToProps, mapDispatchToProps)(SensorDetail); diff --git a/src/ts/@overflow/sensor/react/components/SensorDetails.tsx b/src/ts/@overflow/sensor/react/components/SensorDetail.tsx similarity index 91% rename from src/ts/@overflow/sensor/react/components/SensorDetails.tsx rename to src/ts/@overflow/sensor/react/components/SensorDetail.tsx index 3a89280..9e76b40 100644 --- a/src/ts/@overflow/sensor/react/components/SensorDetails.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorDetail.tsx @@ -5,19 +5,26 @@ import { SensorItems } from './SensorItems'; import Sensor from '@overflow/sensor/api/model/Sensor'; import Probe from '@overflow/probe/api/model/Probe'; -export interface SensorDetailsProps { +export interface SensorDetailStateProps { sensor?: Sensor; probe?: Probe; } +export interface SensorDetailDispatchProps { + +} + + +export type SensorDetailProps = SensorDetailStateProps & SensorDetailDispatchProps; + export interface SensorDetailsState { } -export class SensorDetails extends React.Component { +export class SensorDetail extends React.Component { - constructor(props: SensorDetailsProps, context: SensorDetailsState) { + constructor(props: SensorDetailProps, context: SensorDetailsState) { super(props, context); this.state = { }; diff --git a/src/ts/@overflow/sensor/react/components/SensorList.tsx b/src/ts/@overflow/sensor/react/components/SensorList.tsx index 52bce85..c594645 100644 --- a/src/ts/@overflow/sensor/react/components/SensorList.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorList.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { Table, Button, Header, Container } from 'semantic-ui-react'; -import { SensorDetails } from './SensorDetails'; +import { SensorDetail } from './SensorDetail'; import Probe from '@overflow/probe/api/model/Probe'; import Sensor from '@overflow/sensor/api/model/Sensor'; @@ -116,7 +116,7 @@ export class SensorList extends React.Component { public render(): JSX.Element { if (this.state.isDetail) { - return ; + return ; } return ( diff --git a/src/ts/@overflow/sensor/redux/action/read.ts b/src/ts/@overflow/sensor/redux/action/read.ts index ae43d5d..b3a2d68 100644 --- a/src/ts/@overflow/sensor/redux/action/read.ts +++ b/src/ts/@overflow/sensor/redux/action/read.ts @@ -12,13 +12,13 @@ export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/read/REQUEST_S export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/read/REQUEST_FAILURE'; // Action Creater -export type request = (id: string) => Action; +export type request = (id: number) => Action; export type requestSuccess = (sensor: Sensor) => Action; export type requestFailure = (error: Error) => Action; -export const request: request = (id: string): Action => { +export const request: request = (id: number): Action => { return { type: REQUEST, payload: { diff --git a/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts b/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts index a56fb77..140f684 100644 --- a/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts @@ -1,5 +1,5 @@ interface ReadPayload { - id: string; + id: number; } export default ReadPayload;