added sensor regist

This commit is contained in:
snoop 2017-08-25 15:04:19 +09:00
parent 90be19289a
commit b310a37a00
6 changed files with 63 additions and 7 deletions

View File

@ -25,6 +25,7 @@ import sensorReadAllByDomainReducer from '@overflow/sensor/redux/reducer/read_al
import SensorReadReducer from '@overflow/sensor/redux/reducer/read'; import SensorReadReducer from '@overflow/sensor/redux/reducer/read';
import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/item_read_all_by_sensor'; import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/item_read_all_by_sensor';
import readAllTargetByInfraReducer from '@overflow/sensor/redux/reducer/read_all_by_infra'; import readAllTargetByInfraReducer from '@overflow/sensor/redux/reducer/read_all_by_infra';
import SensorRegistSensorConfigReducer from '@overflow/sensor/redux/reducer/regist_sensor_config';
import readMachineReducer from '@overflow/infra/redux/reducer/machine_read'; import readMachineReducer from '@overflow/infra/redux/reducer/machine_read';
import readHostReducer from '@overflow/infra/redux/reducer/host_read'; import readHostReducer from '@overflow/infra/redux/reducer/host_read';
@ -110,6 +111,7 @@ const reduxConfig: ReduxConfig = {
readAllTargetByInfraReducer, readAllTargetByInfraReducer,
InfraReadServiceReducer, InfraReadServiceReducer,
HistoryTypeReadAllReducer, HistoryTypeReadAllReducer,
SensorRegistSensorConfigReducer,
], ],
sagaWatchers: [ sagaWatchers: [
AsyncRequest, AsyncRequest,

View File

@ -8,12 +8,12 @@ import {
import Target from '@overflow/target/api/model/Target'; import Target from '@overflow/target/api/model/Target';
import Sensor from '@overflow/sensor/api/model/Sensor'; import Sensor from '@overflow/sensor/api/model/Sensor';
import SensorItem from '@overflow/sensor/api/model/SensorItem';
import Domain from '@overflow/domain/api/model/Domain'; import Domain from '@overflow/domain/api/model/Domain';
import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem';
import * as CrawlerReadAllByTargetActions from '@overflow/meta/redux/action/crawler_read_all_by_target';
import * as SensorItemReadAllActions from '@overflow/meta/redux/action/sensor_item_read_all'; import * as RegistSensorConfigActions from '../redux/action/regist_sensor_config';
import * as RegistActions from '../redux/action/regist';
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
import * as targetListActions from '@overflow/target/redux/action/read_all_by_probe'; import * as targetListActions from '@overflow/target/redux/action/read_all_by_probe';
@ -28,6 +28,10 @@ export function mapStateToProps(state: any, props: any): SensorConfigStepperStat
export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigStepperDispatchProps { export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigStepperDispatchProps {
return { return {
onRegistSensorConfig: (sensor: Sensor, sensorItemList: SensorItem[]) => {
dispatch(asyncRequestActions.request('SensorService', 'registSensorConfig', RegistSensorConfigActions.REQUEST,
JSON.stringify(sensor), JSON.stringify(sensorItemList)));
},
}; };
} }

View File

@ -47,7 +47,7 @@ export interface SensorConfigStepperStateProps {
} }
export interface SensorConfigStepperDispatchProps { export interface SensorConfigStepperDispatchProps {
onRegistSensorConfig?(sensor: Sensor, sensorItemList: SensorItem[]): void;
} }
export type SensorConfigStepperProps = SensorConfigStepperStateProps & SensorConfigStepperDispatchProps; export type SensorConfigStepperProps = SensorConfigStepperStateProps & SensorConfigStepperDispatchProps;
@ -132,6 +132,8 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
console.log(sensor); console.log(sensor);
console.log(siList); console.log(siList);
this.props.onRegistSensorConfig(sensor, siList);
} }
public showContent(): any { public showContent(): any {

View File

@ -0,0 +1,9 @@
// Action Type
export type REQUEST = '@overflow/sensor/regist_sensor_config/REQUEST';
export type REQUEST_SUCCESS = '@overflow/sensor/regist_sensor_config/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/sensor/regist_sensor_config/REQUEST/FAILURE';
export const REQUEST: REQUEST = '@overflow/sensor/regist_sensor_config/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/regist_sensor_config/REQUEST/SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/regist_sensor_config/REQUEST/FAILURE';

View File

@ -0,0 +1,26 @@
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import Sensor from '@overflow/sensor/api/model/Sensor';
import * as RegistSensorConfigActionTypes from '../action/regist_sensor_config';
import RegistSensorConfigState, { defaultState as RegistSensorConfigDefaultState } from '../state/RegistSensorConfig';
const reducer: ReducersMapObject = {
[RegistSensorConfigActionTypes.REQUEST_SUCCESS]:
(state: RegistSensorConfigState = RegistSensorConfigDefaultState, action: Action<boolean>): RegistSensorConfigState => {
console.log(action);
return {
...state,
isSensorRegistSuccess:<boolean>action.payload,
};
},
[RegistSensorConfigActionTypes.REQUEST_FAILURE]:
(state: RegistSensorConfigState = RegistSensorConfigDefaultState, action: Action<Error>):
RegistSensorConfigState => {
return state;
},
};
export default reducer;

View File

@ -0,0 +1,13 @@
export interface State {
readonly isSensorRegistSuccess: boolean;
readonly error?: Error;
}
export const defaultState: State = {
isSensorRegistSuccess: undefined,
error: undefined,
};
export default State;