diff --git a/src/ts/@overflow/sensor/api/service/SensorService.ts b/src/ts/@overflow/sensor/api/service/SensorService.ts index 17cf854..dd4f0c9 100644 --- a/src/ts/@overflow/sensor/api/service/SensorService.ts +++ b/src/ts/@overflow/sensor/api/service/SensorService.ts @@ -28,7 +28,7 @@ export class SensorService extends Service { } public read(id:number): Promise { - return null; + return this.send('read', [id]); } public remove(sensor:Sensor): Promise { diff --git a/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts b/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts index e69de29..059922c 100644 --- a/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts +++ b/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts @@ -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 ReadAllByProbeActions from '../action/read_all_by_probe'; +import ReadAllByProbePayload from '../payload/ReadAllByProbePayload'; + +function* readAllByProbe(action: Action): SagaIterator { + try { + const {probe} = 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.readAllByProbe}, probe); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ReadAllByProbeActions.requestSuccess(ret)); + } catch (e) { + yield put(ReadAllByProbeActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchReadAllByTarget(): SagaIterator { + yield takeLatest(ReadAllByProbeActions.REQUEST, readAllByProbe); +}