fixed sensorlist

This commit is contained in:
snoop 2017-07-21 16:36:41 +09:00
parent a63f1c013d
commit dd488c8919
6 changed files with 114 additions and 0 deletions

View File

@ -7,8 +7,12 @@ import {
import State from '../redux/state/ReadAllByTarget';
import * as ReadAllByTargetActions from '../redux/action/read_all_by_target';
import * as ReadAllByProbeActions from '../redux/action/read_all_by_probe';
import * as ReadAllByDomainActions from '../redux/action/read_all_by_domain';
import Target from '@overflow/target/api/model/Target';
import Sensor from '@overflow/sensor/api/model/Sensor';
import Probe from '@overflow/probe/api/model/Probe';
import Domain from '@overflow/domain/api/model/Domain';
export function mapStateToProps(state: any): SensorListStateProps {
return {
@ -20,6 +24,12 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): SensorListDispatchP
onReadAllByTarget: (target: Target) => {
dispatch(ReadAllByTargetActions.request(target));
},
onReadAllByProbe: (probe: Probe) => {
dispatch(ReadAllByProbeActions.request(probe));
},
onReadAllByDomain: (domain: Domain) => {
dispatch(ReadAllByDomainActions.request(domain));
},
};
}

View File

@ -5,13 +5,17 @@ import SensorDetailContainer from '../SensorDetail';
import Probe from '@overflow/probe/api/model/Probe';
import Sensor from '@overflow/sensor/api/model/Sensor';
import Target from '@overflow/target/api/model/Target';
import Domain from '@overflow/domain/api/model/Domain';
export interface StateProps {
probe?: Probe;
target?: Target;
}
export interface DispatchProps {
onReadAllByTarget?(target: Target): void;
onReadAllByProbe?(probe: Probe): void;
onReadAllByDomain?(domain: Domain): void;
}
export type SensorListProps = StateProps & DispatchProps;

View File

@ -0,0 +1,43 @@
import Action from '@overflow/commons/redux/Action';
import Sensor from '../../api/model/Sensor';
import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload';
import Domain from '@overflow/domain/api/model/Domain';
// Action Type
export type REQUEST = '@overflow/sensor/read_all_by_domain/REQUEST';
export type REQUEST_SUCCESS = '@overflow/sensor/read_all_by_domain/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/sensor/read_all_by_domain/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/sensor/read_all_by_domain/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/read_all_by_domain/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/read_all_by_domain/REQUEST_FAILURE';
// Action Creater
export type request = (domain: Domain) => Action<ReadAllByDomainPayload>;
export type requestSuccess = (sensors: Sensor[]) => Action<Sensor[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (domain: Domain): Action<ReadAllByDomainPayload> => {
return {
type: REQUEST,
payload: {
domain: domain,
},
};
};
export const requestSuccess: requestSuccess = (sensors: Sensor[]): Action<Sensor[]> => {
return {
type: REQUEST_SUCCESS,
payload: sensors,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,43 @@
import Action from '@overflow/commons/redux/Action';
import Sensor from '../../api/model/Sensor';
import ReadAllByProbePayload from '../payload/ReadAllByProbePayload';
import Probe from '@overflow/probe/api/model/Probe';
// Action Type
export type REQUEST = '@overflow/sensor/read_all_by_probe/REQUEST';
export type REQUEST_SUCCESS = '@overflow/sensor/read_all_by_probe/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/sensor/read_all_by_probe/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/sensor/read_all_by_probe/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/read_all_by_probe/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/read_all_by_probe/REQUEST_FAILURE';
// Action Creater
export type request = (probe: Probe) => Action<ReadAllByProbePayload>;
export type requestSuccess = (sensors: Sensor[]) => Action<Sensor[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (probe: Probe): Action<ReadAllByProbePayload> => {
return {
type: REQUEST,
payload: {
probe: probe,
},
};
};
export const requestSuccess: requestSuccess = (sensors: Sensor[]): Action<Sensor[]> => {
return {
type: REQUEST_SUCCESS,
payload: sensors,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,7 @@
import Domain from '@overflow/domain/api/model/Domain';
interface ReadAllByDomainPayload {
domain: Domain;
}
export default ReadAllByDomainPayload;

View File

@ -0,0 +1,7 @@
import Probe from '@overflow/probe/api/model/Probe';
interface ReadAllByProbePayload {
probe: Probe;
}
export default ReadAllByProbePayload;