add sensor list
This commit is contained in:
parent
4bbf0f270e
commit
0acc9791dc
|
@ -2,6 +2,8 @@
|
|||
import Service from '@overflow/commons/api/Service';
|
||||
import Sensor from '../model/Sensor';
|
||||
import Target from '@overflow/target/api/model/Target';
|
||||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
import Domain from '@overflow/domain/api/model/Domain';
|
||||
|
||||
export class SensorService extends Service {
|
||||
|
||||
|
@ -17,6 +19,14 @@ export class SensorService extends Service {
|
|||
return null;
|
||||
}
|
||||
|
||||
public readAllByProbe(probe: Probe): Promise<Sensor[]> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public readAllByDomain(domain: Domain): Promise<Sensor[]> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public read(id:number): Promise<Sensor> {
|
||||
return null;
|
||||
}
|
||||
|
|
25
src/ts/@overflow/sensor/redux/reducer/read_all_by_target.ts
Normal file
25
src/ts/@overflow/sensor/redux/reducer/read_all_by_target.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Created by geek on 17. 7. 3.
|
||||
*/
|
||||
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
import { ReducersMapObject } from 'redux';
|
||||
import Target from '@overflow/target/api/model/Target';
|
||||
|
||||
import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain';
|
||||
import ReadAllByTargetState, { defaultState as readAllByTargetDefaultState } from '../state/ReadAllByTarget';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[ReadAllByDomainActionTypes.REQUEST_SUCCESS]:
|
||||
(state: ReadAllByTargetState = readAllByTargetDefaultState, action: Action<Target>):
|
||||
ReadAllByTargetState => {
|
||||
return state;
|
||||
},
|
||||
[ReadAllByDomainActionTypes.REQUEST_FAILURE]:
|
||||
(state: ReadAllByTargetState = readAllByTargetDefaultState, action: Action<Error>):
|
||||
ReadAllByTargetState => {
|
||||
return state;
|
||||
},
|
||||
};
|
||||
|
||||
export default reducer;
|
|
@ -1,3 +0,0 @@
|
|||
/**
|
||||
* Created by geek on 17. 7. 3.
|
||||
*/
|
38
src/ts/@overflow/sensor/redux/saga/read_all_by_domain.ts
Normal file
38
src/ts/@overflow/sensor/redux/saga/read_all_by_domain.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { SagaIterator } from 'redux-saga';
|
||||
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
import AppContext from '@overflow/commons/context/AppContext';
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
|
||||
import Sensor from '../../api/model/Sensor';
|
||||
import SensorService from '../../api/service/SensorService';
|
||||
import * as ReadAllByDomainActions from '../action/read_all_by_domain';
|
||||
import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload';
|
||||
|
||||
function* readAllByDomain(action: Action<ReadAllByDomainPayload>): SagaIterator {
|
||||
try {
|
||||
const {domain} = action.payload;
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
let sensorService = AppContext.getInstance().getPouch(SensorService);
|
||||
const ret = yield call({context: sensorService, fn: sensorService.readAllByDomain}, domain);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
// }
|
||||
yield put(ReadAllByDomainActions.requestSuccess(ret));
|
||||
} catch (e) {
|
||||
yield put(ReadAllByDomainActions.requestFailure(e));
|
||||
} finally {
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: false},
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchReadAllByTarget(): SagaIterator {
|
||||
yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain);
|
||||
}
|
Loading…
Reference in New Issue
Block a user