diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 684443e..2947777 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -5,6 +5,8 @@ import signInReducer from '@overflow/member/redux/reducer/signIn'; import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain'; import readProbeReducer from '@overflow/probe/redux/reducer/read'; +import readAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target'; + import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest'; // Container Configuration @@ -20,7 +22,7 @@ export interface RPCConfig { url: string; } const rpcConfig: RPCConfig = { - url: 'ws://127.0.0.1:18081/rpc', + url: 'ws://1127.0.0.1:18081/rpc', }; // Redux Configuration @@ -42,6 +44,7 @@ const reduxConfig: ReduxConfig = { signInReducer, readAllProbeReducer, readProbeReducer, + readAllByTargetReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/sensor/react/SensorDetailInfo.tsx b/src/ts/@overflow/sensor/react/SensorDetailInfo.tsx index ef38c04..9e81669 100644 --- a/src/ts/@overflow/sensor/react/SensorDetailInfo.tsx +++ b/src/ts/@overflow/sensor/react/SensorDetailInfo.tsx @@ -10,16 +10,18 @@ import * as ReadActions from '../redux/action/read'; import Target from '@overflow/target/api/model/Target'; import Sensor from '@overflow/sensor/api/model/Sensor'; -export function mapStateToProps(state: any): SensorDetailInfoStateProps { +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; + +export function mapStateToProps(state: any, props: any): SensorDetailInfoStateProps { return { - sensor:state.sensor, + sensorId:props.params.id, }; } export function mapDispatchToProps(dispatch: Dispatch): SensorDetailInfoDispatchProps { return { onRead: (id: number) => { - dispatch(ReadActions.request(id)); + dispatch(asyncRequestActions.request('SensorService', 'read', ReadActions.REQUEST, id)); }, }; } diff --git a/src/ts/@overflow/sensor/react/SensorDetailItems.tsx b/src/ts/@overflow/sensor/react/SensorDetailItems.tsx index 3ed8bce..e146eee 100644 --- a/src/ts/@overflow/sensor/react/SensorDetailItems.tsx +++ b/src/ts/@overflow/sensor/react/SensorDetailItems.tsx @@ -10,7 +10,7 @@ import * as ItemReadActions from '../redux/action/item_read'; export function mapStateToProps(state: any): SensorDetailItemsStateProps { return { - + sensorId: props.params.id, }; } diff --git a/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx b/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx index 705ec8b..6d7d510 100644 --- a/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx @@ -6,7 +6,7 @@ import Probe from '@overflow/probe/api/model/Probe'; export interface SensorDetailInfoStateProps { - sensor?: Sensor; + sensorId?: number; probe?: Probe; } diff --git a/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx b/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx index c04c30d..e0b3eb8 100644 --- a/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx @@ -5,7 +5,7 @@ import Sensor from '@overflow/sensor/api/model/Sensor'; import SensorItem from '@overflow/sensor/api/model/SensorItem'; export interface StateProps { - sensor?: Sensor; + sensorId?: number; } export interface DispatchProps { diff --git a/src/ts/@overflow/sensor/react/components/SensorList.tsx b/src/ts/@overflow/sensor/react/components/SensorList.tsx index 8c6f8c3..5d71311 100644 --- a/src/ts/@overflow/sensor/react/components/SensorList.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorList.tsx @@ -165,7 +165,7 @@ export class SensorList extends React.Component ); diff --git a/src/ts/@overflow/sensor/redux/reducer/read.ts b/src/ts/@overflow/sensor/redux/reducer/read.ts index 5c15c15..3b19626 100644 --- a/src/ts/@overflow/sensor/redux/reducer/read.ts +++ b/src/ts/@overflow/sensor/redux/reducer/read.ts @@ -1,3 +1,28 @@ /** * Created by geek on 17. 7. 3. */ + + +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import Sensor from '@overflow/sensor/api/model/Sensor'; + +import * as ReadtActionTypes from '../action/read'; +import ReadState, { defaultState as readDefaultState } from '../state/Read'; + +const reducer: ReducersMapObject = { + [ReadtActionTypes.REQUEST_SUCCESS]: + (state: ReadState = readDefaultState, action: Action): ReadState => { + console.log(action); + return { + ...state, + Sensor:action.payload, + }; + }, + [ReadtActionTypes.REQUEST_FAILURE]: + (state: ReadState = readDefaultState, action: Action): ReadState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/sensor/redux/state/Read.ts b/src/ts/@overflow/sensor/redux/state/Read.ts index 45212ae..c24a66e 100644 --- a/src/ts/@overflow/sensor/redux/state/Read.ts +++ b/src/ts/@overflow/sensor/redux/state/Read.ts @@ -1,12 +1,12 @@ import Sensor from '../../api/model/Sensor'; export interface State { - readonly isGetSensor: boolean; + readonly Sensor: Sensor; readonly error?: Error; } export const defaultState: State = { - isGetSensor: undefined, + Sensor: undefined, error: undefined, };