added sensor
This commit is contained in:
parent
1db8caeebb
commit
14aa79e8fc
|
@ -28,7 +28,7 @@ export class SensorService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public read(id:number): Promise<Sensor> {
|
public read(id:number): Promise<Sensor> {
|
||||||
return null;
|
return this.send<Sensor>('read', [id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public remove(sensor:Sensor): Promise<Sensor> {
|
public remove(sensor:Sensor): Promise<Sensor> {
|
||||||
|
|
|
@ -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<ReadAllByProbePayload>): 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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user