sensor/sensorItem
This commit is contained in:
@@ -1,3 +1,43 @@
|
||||
/**
|
||||
* Created by geek on 17. 7. 3.
|
||||
*/
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
import Target from '../../api/model/Target';
|
||||
|
||||
import ReadPayload from '../payload/ReadPayload';
|
||||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/target/read/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/read/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/read/REQUEST_FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/target/read/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/read/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/read/REQUEST_FAILURE';
|
||||
|
||||
// Action Creater
|
||||
export type request = (id: string) => Action<ReadPayload>;
|
||||
export type requestSuccess = (target: Target) => Action<Target>;
|
||||
export type requestFailure = (error: Error) => Action;
|
||||
|
||||
|
||||
|
||||
export const request: request = (id: string): Action<ReadPayload> => {
|
||||
return {
|
||||
type: REQUEST,
|
||||
payload: {
|
||||
id: id,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const requestSuccess: requestSuccess = (target: Target): Action<Target> => {
|
||||
return {
|
||||
type: REQUEST_SUCCESS,
|
||||
payload: target,
|
||||
};
|
||||
};
|
||||
|
||||
export const requestFailure: requestFailure = (error: Error): Action => {
|
||||
return {
|
||||
type: REQUEST_FAILURE,
|
||||
error: error,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,13 +4,13 @@ import Probe from '@overflow/probe/api/model/Probe';
|
||||
import ReadAllByProbePayload from '../payload/ReadAllByProbePayload';
|
||||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/target/read/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/read/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/read/REQUEST_FAILURE';
|
||||
export type REQUEST = '@overflow/target/read_all_by_probe/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST_FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/target/read/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/read/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/read/REQUEST_FAILURE';
|
||||
export const REQUEST: REQUEST = '@overflow/target/read_all_by_probe/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST_FAILURE';
|
||||
|
||||
// Action Creater
|
||||
export type request = (probe: Probe) => Action<ReadAllByProbePayload>;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
import Target from '../../api/model/Target';
|
||||
import RegistPayload from '../payload/RegistPayload';
|
||||
import Infra from '@overflow/infra/api/model/Infra';
|
||||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/target/regist/REQUEST';
|
||||
|
||||
@@ -3,13 +3,13 @@ import Target from '../../api/model/Target';
|
||||
import RemovePayload from '../payload/RemovePayload';
|
||||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/target/regist/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/regist/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/regist/REQUEST_FAILURE';
|
||||
export type REQUEST = '@overflow/target/remove/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/remove/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/remove/REQUEST_FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/target/regist/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/regist/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/regist/REQUEST_FAILURE';
|
||||
export const REQUEST: REQUEST = '@overflow/target/remove/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/remove/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/remove/REQUEST_FAILURE';
|
||||
|
||||
// Action Creater
|
||||
export type request = (target: Target) => Action<RemovePayload>;
|
||||
@@ -27,10 +27,9 @@ export const request: request = (target: Target): Action<RemovePayload> => {
|
||||
};
|
||||
};
|
||||
|
||||
export const requestSuccess: requestSuccess = (target: Target): Action<Target> => {
|
||||
export const requestSuccess: requestSuccess = (): Action<void> => {
|
||||
return {
|
||||
type: REQUEST_SUCCESS,
|
||||
payload: target,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -9,22 +9,22 @@ import TargetService from '../../api/service/TargetService';
|
||||
import * as ReadActions from '../action/read';
|
||||
import ReadPayload from '../payload/ReadPayload';
|
||||
|
||||
function* read(action: Action<RegistPayload>): SagaIterator {
|
||||
function* read(action: Action<ReadPayload>): SagaIterator {
|
||||
try {
|
||||
const {target} = action.payload;
|
||||
const {id} = action.payload;
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
|
||||
const retTarget = yield call(AppContext.getService<TargetService>().regist, target);
|
||||
const retTarget = yield call(AppContext.getService<TargetService>().read, id);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
// }
|
||||
yield put(RegistActions.requestSuccess(retTarget));
|
||||
yield put(ReadActions.requestSuccess(retTarget));
|
||||
} catch (e) {
|
||||
yield put(RegistActions.requestFailure(e));
|
||||
yield put(ReadActions.requestFailure(e));
|
||||
} finally {
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
@@ -33,6 +33,6 @@ function* read(action: Action<RegistPayload>): SagaIterator {
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchSignin(): SagaIterator {
|
||||
yield takeLatest(RegistActions.REQUEST, regist);
|
||||
export function* watchRead(): SagaIterator {
|
||||
yield takeLatest(ReadActions.REQUEST, read);
|
||||
}
|
||||
|
||||
@@ -9,22 +9,22 @@ import TargetService from '../../api/service/TargetService';
|
||||
import * as ReadAllByProbeActions from '../action/read_all_by_probe';
|
||||
import ReadAllByProbePayload from '../payload/ReadAllByProbePayload';
|
||||
|
||||
function* regist(action: Action<RegistPayload>): SagaIterator {
|
||||
function* readAllByProbe(action: Action<ReadAllByProbePayload>): SagaIterator {
|
||||
try {
|
||||
const {target} = action.payload;
|
||||
const {probe} = action.payload;
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
|
||||
const retTarget = yield call(AppContext.getService<TargetService>().regist, target);
|
||||
const retTargets = yield call(AppContext.getService<TargetService>().readAllByProbe, probe);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
// }
|
||||
yield put(RegistActions.requestSuccess(retTarget));
|
||||
yield put(ReadAllByProbeActions.requestSuccess(retTargets));
|
||||
} catch (e) {
|
||||
yield put(RegistActions.requestFailure(e));
|
||||
yield put(ReadAllByProbeActions.requestFailure(e));
|
||||
} finally {
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
@@ -33,6 +33,6 @@ function* regist(action: Action<RegistPayload>): SagaIterator {
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchSignin(): SagaIterator {
|
||||
yield takeLatest(RegistActions.REQUEST, regist);
|
||||
export function* watchReadAllByProbe(): SagaIterator {
|
||||
yield takeLatest(ReadAllByProbeActions.REQUEST, readAllByProbe);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,6 @@ function* regist(action: Action<RegistPayload>): SagaIterator {
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchSignin(): SagaIterator {
|
||||
export function* watchRegist(): SagaIterator {
|
||||
yield takeLatest(RegistActions.REQUEST, regist);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,38 @@
|
||||
/**
|
||||
* Created by geek on 17. 7. 3.
|
||||
*/
|
||||
import { SagaIterator } from 'redux-saga';
|
||||
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
import AppContext from '@overflow/commons/context';
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
|
||||
import Target from '../../api/model/Target';
|
||||
import TargetService from '../../api/service/TargetService';
|
||||
import * as RemoveActions from '../action/remove';
|
||||
import RemovePayload from '../payload/RemovePayload';
|
||||
|
||||
function* remove(action: Action<RemovePayload>): SagaIterator {
|
||||
try {
|
||||
const {target} = action.payload;
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
|
||||
yield call(AppContext.getService<TargetService>().remove, target);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
// }
|
||||
yield put(RemoveActions.requestSuccess());
|
||||
} catch (e) {
|
||||
yield put(RemoveActions.requestFailure(e));
|
||||
} finally {
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: false},
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchRemove(): SagaIterator {
|
||||
yield takeLatest(RemoveActions.REQUEST, remove);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user