diff --git a/src/ts/@overflow/sensor/api/service/SensorItemService.ts b/src/ts/@overflow/sensor/api/service/SensorItemService.ts index aa9c0b9..6f23aa5 100644 --- a/src/ts/@overflow/sensor/api/service/SensorItemService.ts +++ b/src/ts/@overflow/sensor/api/service/SensorItemService.ts @@ -12,8 +12,7 @@ export class SensorItemService extends Service { return null; } - // Todo List - public readAllBySensor(sensor:Sensor): Promise { + public readAllBySensor(sensor:Sensor): Promise { return null; } diff --git a/src/ts/@overflow/sensor/api/service/SensorService.ts b/src/ts/@overflow/sensor/api/service/SensorService.ts index 589fc7a..527da98 100644 --- a/src/ts/@overflow/sensor/api/service/SensorService.ts +++ b/src/ts/@overflow/sensor/api/service/SensorService.ts @@ -13,8 +13,7 @@ export class SensorService extends Service { return null; } - // Todo List - public readAllByTarget(target:Target): Promise { + public readAllByTarget(target:Target): Promise { return null; } diff --git a/src/ts/@overflow/sensor/redux/action/item_read.ts b/src/ts/@overflow/sensor/redux/action/item_read.ts index 5c15c15..05b35bc 100644 --- a/src/ts/@overflow/sensor/redux/action/item_read.ts +++ b/src/ts/@overflow/sensor/redux/action/item_read.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import SensorItem from '../../api/model/SensorItem'; +import ItemReadPayload from '../payload/ItemReadPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor_item/read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor_item/read/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor_item/read/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor_item/read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor_item/read/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor_item/read/REQUEST_FAILURE'; + +// Action Creater +export type request = (id: string) => Action; +export type requestSuccess = (sensorItem: SensorItem) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (id: string): Action => { + return { + type: REQUEST, + payload: { + id: id, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensorItem: SensorItem): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensorItem, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/item_read_all_by_sensor.ts b/src/ts/@overflow/sensor/redux/action/item_read_all_by_sensor.ts new file mode 100644 index 0000000..c74f7b1 --- /dev/null +++ b/src/ts/@overflow/sensor/redux/action/item_read_all_by_sensor.ts @@ -0,0 +1,43 @@ +import Action from '@overflow/commons/redux/Action'; +import SensorItem from '../../api/model/SensorItem'; +import Sensor from '../../api/model/Sensor'; +import ItemReadAllBySensorPayload from '../payload/ItemReadAllBySensorPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor_item/item_read_all_by_sensor/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor_item/item_read_all_by_sensor/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor_item/item_read_all_by_sensor/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor_item/item_read_all_by_sensor/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor_item/item_read_all_by_sensor/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor_item/item_read_all_by_sensor/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensor: Sensor) => Action; +export type requestSuccess = (sensorItems: SensorItem[]) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensor: Sensor): Action => { + return { + type: REQUEST, + payload: { + sensor: sensor, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensorItems: SensorItem[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensorItems, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/item_read_by_sensor.ts b/src/ts/@overflow/sensor/redux/action/item_read_by_sensor.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/sensor/redux/action/item_read_by_sensor.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/sensor/redux/action/item_regist.ts b/src/ts/@overflow/sensor/redux/action/item_regist.ts index 5c15c15..8482a04 100644 --- a/src/ts/@overflow/sensor/redux/action/item_regist.ts +++ b/src/ts/@overflow/sensor/redux/action/item_regist.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import SensorItem from '../../api/model/SensorItem'; +import ItemRegistPayload from '../payload/ItemRegistPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor_item/regist/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor_item/regist/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor_item/regist/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor_item/regist/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor_item/regist/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor_item/regist/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensorItem: SensorItem) => Action; +export type requestSuccess = (sensorItem: SensorItem) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensorItem: SensorItem): Action => { + return { + type: REQUEST, + payload: { + sensorItem: sensorItem, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensorItem: SensorItem): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensorItem, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/item_remove.ts b/src/ts/@overflow/sensor/redux/action/item_remove.ts index 5c15c15..bb9a803 100644 --- a/src/ts/@overflow/sensor/redux/action/item_remove.ts +++ b/src/ts/@overflow/sensor/redux/action/item_remove.ts @@ -1,3 +1,41 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import SensorItem from '../../api/model/SensorItem'; +import ItemRemovePayload from '../payload/ItemRemovePayload'; + +// Action Type +export type REQUEST = '@overflow/sensor_item/remove/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor_item/remove/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor_item/remove/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor_item/remove/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor_item/remove/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor_item/remove/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensorItem: SensorItem) => Action; +export type requestSuccess = () => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensorItem: SensorItem): Action => { + return { + type: REQUEST, + payload: { + sensorItem: sensorItem, + }, + }; +}; + +export const requestSuccess: requestSuccess = (): Action => { + return { + type: REQUEST_SUCCESS, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/read.ts b/src/ts/@overflow/sensor/redux/action/read.ts index 5c15c15..ae43d5d 100644 --- a/src/ts/@overflow/sensor/redux/action/read.ts +++ b/src/ts/@overflow/sensor/redux/action/read.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import Sensor from '../../api/model/Sensor'; +import ReadPayload from '../payload/ReadPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor/read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor/read/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor/read/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor/read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/read/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/read/REQUEST_FAILURE'; + +// Action Creater +export type request = (id: string) => Action; +export type requestSuccess = (sensor: Sensor) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (id: string): Action => { + return { + type: REQUEST, + payload: { + id: id, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensor: Sensor): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensor, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/read_all_by_target.ts b/src/ts/@overflow/sensor/redux/action/read_all_by_target.ts new file mode 100644 index 0000000..add5511 --- /dev/null +++ b/src/ts/@overflow/sensor/redux/action/read_all_by_target.ts @@ -0,0 +1,43 @@ +import Action from '@overflow/commons/redux/Action'; +import Sensor from '../../api/model/Sensor'; +import ReadAllByTargetPayload from '../payload/ReadAllByTargetPayload'; +import Target from '@overflow/target/api/model/Target'; + +// Action Type +export type REQUEST = '@overflow/sensor/read_all_by_target/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor/read_all_by_target/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor/read_all_by_target/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor/read_all_by_target/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/read_all_by_target/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/read_all_by_target/REQUEST_FAILURE'; + +// Action Creater +export type request = (target: Target) => Action; +export type requestSuccess = (sensors: Sensor[]) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (target: Target): Action => { + return { + type: REQUEST, + payload: { + target: target, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensors: Sensor[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensors, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/read_by_target.ts b/src/ts/@overflow/sensor/redux/action/read_by_target.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/sensor/redux/action/read_by_target.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/sensor/redux/action/regist.ts b/src/ts/@overflow/sensor/redux/action/regist.ts index e69de29..ed3f58f 100644 --- a/src/ts/@overflow/sensor/redux/action/regist.ts +++ b/src/ts/@overflow/sensor/redux/action/regist.ts @@ -0,0 +1,42 @@ +import Action from '@overflow/commons/redux/Action'; +import Sensor from '../../api/model/Sensor'; +import RegistPayload from '../payload/RegistPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor/regist/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor/regist/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor/regist/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor/regist/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/regist/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/regist/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensor: Sensor) => Action; +export type requestSuccess = (sensor: Sensor) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensor: Sensor): Action => { + return { + type: REQUEST, + payload: { + sensor: sensor, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensor: Sensor): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensor, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/remove.ts b/src/ts/@overflow/sensor/redux/action/remove.ts index 5c15c15..b8240b3 100644 --- a/src/ts/@overflow/sensor/redux/action/remove.ts +++ b/src/ts/@overflow/sensor/redux/action/remove.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import Sensor from '../../api/model/Sensor'; +import RemovePayload from '../payload/RemovePayload'; + +// Action Type +export type REQUEST = '@overflow/sensor/remove/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor/remove/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor/remove/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor/remove/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/remove/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/remove/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensor: Sensor) => Action; +export type requestSuccess = (sensor: Sensor) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensor: Sensor): Action => { + return { + type: REQUEST, + payload: { + sensor: sensor, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensor: Sensor): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensor, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/start.ts b/src/ts/@overflow/sensor/redux/action/start.ts index 5c15c15..99459b3 100644 --- a/src/ts/@overflow/sensor/redux/action/start.ts +++ b/src/ts/@overflow/sensor/redux/action/start.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import Sensor from '../../api/model/Sensor'; +import StartPayload from '../payload/StartPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor/start/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor/start/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor/start/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor/start/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/start/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/start/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensor: Sensor) => Action; +export type requestSuccess = (sensor: Sensor) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensor: Sensor): Action => { + return { + type: REQUEST, + payload: { + sensor: sensor, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensor: Sensor): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensor, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/action/stop.ts b/src/ts/@overflow/sensor/redux/action/stop.ts index 5c15c15..90f20c1 100644 --- a/src/ts/@overflow/sensor/redux/action/stop.ts +++ b/src/ts/@overflow/sensor/redux/action/stop.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +import Sensor from '../../api/model/Sensor'; +import StopPayload from '../payload/StopPayload'; + +// Action Type +export type REQUEST = '@overflow/sensor/stop/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/sensor/stop/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/sensor/stop/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/sensor/stop/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/sensor/stop/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/sensor/stop/REQUEST_FAILURE'; + +// Action Creater +export type request = (sensor: Sensor) => Action; +export type requestSuccess = (sensor: Sensor) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (sensor: Sensor): Action => { + return { + type: REQUEST, + payload: { + sensor: sensor, + }, + }; +}; + +export const requestSuccess: requestSuccess = (sensor: Sensor): Action => { + return { + type: REQUEST_SUCCESS, + payload: sensor, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/sensor/redux/payload/ItemReadAllBySensorPayload.ts b/src/ts/@overflow/sensor/redux/payload/ItemReadAllBySensorPayload.ts new file mode 100644 index 0000000..e5a4064 --- /dev/null +++ b/src/ts/@overflow/sensor/redux/payload/ItemReadAllBySensorPayload.ts @@ -0,0 +1,7 @@ +import Sensor from '../../api/model/Sensor'; + +interface ItemReadAllBySensorPayload { + sensor: Sensor; +} + +export default ItemReadAllBySensorPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/ItemReadBySensorPayload.ts b/src/ts/@overflow/sensor/redux/payload/ItemReadBySensorPayload.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/sensor/redux/payload/ItemReadBySensorPayload.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/sensor/redux/payload/ItemReadPayload.ts b/src/ts/@overflow/sensor/redux/payload/ItemReadPayload.ts index 5c15c15..72b5a5d 100644 --- a/src/ts/@overflow/sensor/redux/payload/ItemReadPayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/ItemReadPayload.ts @@ -1,3 +1,5 @@ -/** - * Created by geek on 17. 7. 3. - */ +interface ItemReadPayload { + id: string; +} + +export default ItemReadPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/ItemRegistPayload.ts b/src/ts/@overflow/sensor/redux/payload/ItemRegistPayload.ts index 5c15c15..3f1115a 100644 --- a/src/ts/@overflow/sensor/redux/payload/ItemRegistPayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/ItemRegistPayload.ts @@ -1,3 +1,7 @@ -/** - * Created by geek on 17. 7. 3. - */ +import SensorItem from '../../api/model/SensorItem'; + +interface ItemRegistPayload { + sensorItem: SensorItem; +} + +export default ItemRegistPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/ItemRemovePayload.ts b/src/ts/@overflow/sensor/redux/payload/ItemRemovePayload.ts index 5c15c15..3db0f10 100644 --- a/src/ts/@overflow/sensor/redux/payload/ItemRemovePayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/ItemRemovePayload.ts @@ -1,3 +1,7 @@ -/** - * Created by geek on 17. 7. 3. - */ +import SensorItem from '../../api/model/SensorItem'; + +interface ItemRemovePayload { + sensorItem: SensorItem; +} + +export default ItemRemovePayload; diff --git a/src/ts/@overflow/sensor/redux/payload/ReadAllByTargetPayload.ts b/src/ts/@overflow/sensor/redux/payload/ReadAllByTargetPayload.ts new file mode 100644 index 0000000..1f5f29d --- /dev/null +++ b/src/ts/@overflow/sensor/redux/payload/ReadAllByTargetPayload.ts @@ -0,0 +1,7 @@ +import Target from '@overflow/target/api/model/Target'; + +interface ReadAllByTargetPayload { + target: Target; +} + +export default ReadAllByTargetPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/ReadByTargetPayload.ts b/src/ts/@overflow/sensor/redux/payload/ReadByTargetPayload.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts b/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts index 5c15c15..a56fb77 100644 --- a/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/ReadPayload.ts @@ -1,3 +1,5 @@ -/** - * Created by geek on 17. 7. 3. - */ +interface ReadPayload { + id: string; +} + +export default ReadPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/RegistPayload.ts b/src/ts/@overflow/sensor/redux/payload/RegistPayload.ts index 5c15c15..7bd82ab 100644 --- a/src/ts/@overflow/sensor/redux/payload/RegistPayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/RegistPayload.ts @@ -1,3 +1,7 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Sensor from '../../api/model/Sensor'; + +interface RegistPayload { + sensor: Sensor; +} + +export default RegistPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/RemovePayload.ts b/src/ts/@overflow/sensor/redux/payload/RemovePayload.ts index 5c15c15..a5d7aad 100644 --- a/src/ts/@overflow/sensor/redux/payload/RemovePayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/RemovePayload.ts @@ -1,3 +1,7 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Sensor from '../../api/model/Sensor'; + +interface RemovePayload { + sensor: Sensor; +} + +export default RemovePayload; diff --git a/src/ts/@overflow/sensor/redux/payload/SatartPayload.ts b/src/ts/@overflow/sensor/redux/payload/SatartPayload.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/sensor/redux/payload/SatartPayload.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/sensor/redux/payload/StartPayload.ts b/src/ts/@overflow/sensor/redux/payload/StartPayload.ts new file mode 100644 index 0000000..81af7e3 --- /dev/null +++ b/src/ts/@overflow/sensor/redux/payload/StartPayload.ts @@ -0,0 +1,7 @@ +import Sensor from '../../api/model/Sensor'; + +interface StartPayload { + sensor: Sensor; +} + +export default StartPayload; diff --git a/src/ts/@overflow/sensor/redux/payload/StopPayload.ts b/src/ts/@overflow/sensor/redux/payload/StopPayload.ts index 5c15c15..bd9cacf 100644 --- a/src/ts/@overflow/sensor/redux/payload/StopPayload.ts +++ b/src/ts/@overflow/sensor/redux/payload/StopPayload.ts @@ -1,3 +1,7 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Sensor from '../../api/model/Sensor'; + +interface StopPayload { + sensor: Sensor; +} + +export default StopPayload; diff --git a/src/ts/@overflow/sensor/redux/saga/item_read.ts b/src/ts/@overflow/sensor/redux/saga/item_read.ts index 5c15c15..4a4923d 100644 --- a/src/ts/@overflow/sensor/redux/saga/item_read.ts +++ b/src/ts/@overflow/sensor/redux/saga/item_read.ts @@ -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 SensorItem from '../../api/model/SensorItem'; +import SensorItemService from '../../api/service/SensorItemService'; +import * as ItemReadActions from '../action/item_read'; +import ItemReadPayload from '../payload/ItemReadPayload'; + +function* readItem(action: Action): SagaIterator { + try { + const {id} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().read, id); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ItemReadActions.requestSuccess(retSensor)); + } catch (e) { + yield put(ItemReadActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchReadItem(): SagaIterator { + yield takeLatest(ItemReadActions.REQUEST, readItem); +} diff --git a/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts b/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts index 5c15c15..af57fc4 100644 --- a/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts +++ b/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts @@ -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 SensorItem from '../../api/model/SensorItem'; +import SensorItemService from '../../api/service/SensorItemService'; +import * as ItemReadAllBySensorActions from '../action/item_read_all_by_sensor'; +import ItemReadAllBySensorActionsPayload from '../payload/ItemReadAllBySensorPayload'; + +function* readAllItemBySensor(action: Action): SagaIterator { + try { + const {sensor} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().readAllBySensor, sensor); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ItemReadAllBySensorActions.requestSuccess(retSensor)); + } catch (e) { + yield put(ItemReadAllBySensorActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchReadAllItemBySensor(): SagaIterator { + yield takeLatest(ItemReadAllBySensorActions.REQUEST, readAllItemBySensor); +} diff --git a/src/ts/@overflow/sensor/redux/saga/item_regist.ts b/src/ts/@overflow/sensor/redux/saga/item_regist.ts index 5c15c15..7aec82a 100644 --- a/src/ts/@overflow/sensor/redux/saga/item_regist.ts +++ b/src/ts/@overflow/sensor/redux/saga/item_regist.ts @@ -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 SensorItem from '../../api/model/SensorItem'; +import SensorItemService from '../../api/service/SensorItemService'; +import * as ItemRegistActions from '../action/item_regist'; +import ItemRegistPayload from '../payload/ItemRegistPayload'; + +function* registItem(action: Action): SagaIterator { + try { + const {sensorItem} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().regist, sensorItem); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ItemRegistActions.requestSuccess(retSensor)); + } catch (e) { + yield put(ItemRegistActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchRegistItem(): SagaIterator { + yield takeLatest(ItemRegistActions.REQUEST, registItem); +} diff --git a/src/ts/@overflow/sensor/redux/saga/item_remove.ts b/src/ts/@overflow/sensor/redux/saga/item_remove.ts index 5c15c15..922edc1 100644 --- a/src/ts/@overflow/sensor/redux/saga/item_remove.ts +++ b/src/ts/@overflow/sensor/redux/saga/item_remove.ts @@ -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 SensorItem from '../../api/model/SensorItem'; +import SensorItemService from '../../api/service/SensorItemService'; +import * as ItemRemoveActions from '../action/item_remove'; +import ItemRemovePayload from '../payload/ItemRemovePayload'; + +function* removeItem(action: Action): SagaIterator { + try { + const {sensorItem} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + yield call(AppContext.getService().remove, sensorItem); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ItemRemoveActions.requestSuccess()); + } catch (e) { + yield put(ItemRemoveActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchRemoveItem(): SagaIterator { + yield takeLatest(ItemRemoveActions.REQUEST, removeItem); +} diff --git a/src/ts/@overflow/sensor/redux/saga/read.ts b/src/ts/@overflow/sensor/redux/saga/read.ts index 5c15c15..913c0a6 100644 --- a/src/ts/@overflow/sensor/redux/saga/read.ts +++ b/src/ts/@overflow/sensor/redux/saga/read.ts @@ -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 Sensor from '../../api/model/Sensor'; +import SensorService from '../../api/service/SensorService'; +import * as ReadActions from '../action/read'; +import ReadPayload from '../payload/ReadPayload'; + +function* read(action: Action): SagaIterator { + try { + const {id} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().read, id); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ReadActions.requestSuccess(retSensor)); + } catch (e) { + yield put(ReadActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchRead(): SagaIterator { + yield takeLatest(ReadActions.REQUEST, read); +} diff --git a/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts b/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts new file mode 100644 index 0000000..44e20e1 --- /dev/null +++ b/src/ts/@overflow/sensor/redux/saga/read_all_by_target.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'; +import Action from '@overflow/commons/redux/Action'; + +import Sensor from '../../api/model/Sensor'; +import SensorService from '../../api/service/SensorService'; +import * as ReadAllByTargetActions from '../action/read_all_by_target'; +import ReadAllByTargetPayload from '../payload/ReadAllByTargetPayload'; + +function* readAllByTarget(action: Action): SagaIterator { + try { + const {target} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().readAllByTarget, target); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ReadAllByTargetActions.requestSuccess(retSensor)); + } catch (e) { + yield put(ReadAllByTargetActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchReadAllByTarget(): SagaIterator { + yield takeLatest(ReadAllByTargetActions.REQUEST, readAllByTarget); +} diff --git a/src/ts/@overflow/sensor/redux/saga/read_by_target.ts b/src/ts/@overflow/sensor/redux/saga/read_by_target.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/sensor/redux/saga/read_by_target.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/sensor/redux/saga/regist.ts b/src/ts/@overflow/sensor/redux/saga/regist.ts index e69de29..a9a2426 100644 --- a/src/ts/@overflow/sensor/redux/saga/regist.ts +++ b/src/ts/@overflow/sensor/redux/saga/regist.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'; +import Action from '@overflow/commons/redux/Action'; + +import Sensor from '../../api/model/Sensor'; +import SensorService from '../../api/service/SensorService'; +import * as RegistActions from '../action/regist'; +import RegistPayload from '../payload/RegistPayload'; + +function* regist(action: Action): SagaIterator { + try { + const {sensor} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().regist, sensor); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(RegistActions.requestSuccess(retSensor)); + } catch (e) { + yield put(RegistActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchRegist(): SagaIterator { + yield takeLatest(RegistActions.REQUEST, regist); +} diff --git a/src/ts/@overflow/sensor/redux/saga/remove.ts b/src/ts/@overflow/sensor/redux/saga/remove.ts index 5c15c15..c1f5039 100644 --- a/src/ts/@overflow/sensor/redux/saga/remove.ts +++ b/src/ts/@overflow/sensor/redux/saga/remove.ts @@ -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 Sensor from '../../api/model/Sensor'; +import SensorService from '../../api/service/SensorService'; +import * as RemoveActions from '../action/remove'; +import RemovePayload from '../payload/RemovePayload'; + +function* remove(action: Action): SagaIterator { + try { + const {sensor} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().remove, sensor); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(RemoveActions.requestSuccess(retSensor)); + } 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); +} diff --git a/src/ts/@overflow/sensor/redux/saga/start.ts b/src/ts/@overflow/sensor/redux/saga/start.ts index 5c15c15..9df6edd 100644 --- a/src/ts/@overflow/sensor/redux/saga/start.ts +++ b/src/ts/@overflow/sensor/redux/saga/start.ts @@ -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 Sensor from '../../api/model/Sensor'; +import SensorService from '../../api/service/SensorService'; +import * as StartActions from '../action/start'; +import StartPayload from '../payload/StartPayload'; + +function* start(action: Action): SagaIterator { + try { + const {sensor} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().start, sensor); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(StartActions.requestSuccess(retSensor)); + } catch (e) { + yield put(StartActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchStart(): SagaIterator { + yield takeLatest(StartActions.REQUEST, start); +} diff --git a/src/ts/@overflow/sensor/redux/saga/stop.ts b/src/ts/@overflow/sensor/redux/saga/stop.ts index 5c15c15..5fb1cb4 100644 --- a/src/ts/@overflow/sensor/redux/saga/stop.ts +++ b/src/ts/@overflow/sensor/redux/saga/stop.ts @@ -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 Sensor from '../../api/model/Sensor'; +import SensorService from '../../api/service/SensorService'; +import * as StopActions from '../action/stop'; +import StopPayload from '../payload/StopPayload'; + +function* stop(action: Action): SagaIterator { + try { + const {sensor} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retSensor = yield call(AppContext.getService().stop, sensor); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(StopActions.requestSuccess(retSensor)); + } catch (e) { + yield put(StopActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchStop(): SagaIterator { + yield takeLatest(StopActions.REQUEST, stop); +} diff --git a/src/ts/@overflow/target/redux/action/read.ts b/src/ts/@overflow/target/redux/action/read.ts index 5c15c15..0f92c50 100644 --- a/src/ts/@overflow/target/redux/action/read.ts +++ b/src/ts/@overflow/target/redux/action/read.ts @@ -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; +export type requestSuccess = (target: Target) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (id: string): Action => { + return { + type: REQUEST, + payload: { + id: id, + }, + }; +}; + +export const requestSuccess: requestSuccess = (target: Target): Action => { + return { + type: REQUEST_SUCCESS, + payload: target, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/target/redux/action/read_all_by_probe.ts b/src/ts/@overflow/target/redux/action/read_all_by_probe.ts index ae30e31..9ca5b4a 100644 --- a/src/ts/@overflow/target/redux/action/read_all_by_probe.ts +++ b/src/ts/@overflow/target/redux/action/read_all_by_probe.ts @@ -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; diff --git a/src/ts/@overflow/target/redux/action/regist.ts b/src/ts/@overflow/target/redux/action/regist.ts index 034390d..9f705f7 100644 --- a/src/ts/@overflow/target/redux/action/regist.ts +++ b/src/ts/@overflow/target/redux/action/regist.ts @@ -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'; diff --git a/src/ts/@overflow/target/redux/action/remove.ts b/src/ts/@overflow/target/redux/action/remove.ts index e12b89c..056d967 100644 --- a/src/ts/@overflow/target/redux/action/remove.ts +++ b/src/ts/@overflow/target/redux/action/remove.ts @@ -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; @@ -27,10 +27,9 @@ export const request: request = (target: Target): Action => { }; }; -export const requestSuccess: requestSuccess = (target: Target): Action => { +export const requestSuccess: requestSuccess = (): Action => { return { type: REQUEST_SUCCESS, - payload: target, }; }; diff --git a/src/ts/@overflow/target/redux/saga/read.ts b/src/ts/@overflow/target/redux/saga/read.ts index 3f9c7d8..8dca236 100644 --- a/src/ts/@overflow/target/redux/saga/read.ts +++ b/src/ts/@overflow/target/redux/saga/read.ts @@ -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): SagaIterator { +function* read(action: Action): 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().regist, target); + const retTarget = yield call(AppContext.getService().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): SagaIterator { } } -export function* watchSignin(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); +export function* watchRead(): SagaIterator { + yield takeLatest(ReadActions.REQUEST, read); } diff --git a/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts b/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts index 897c87d..bd2cabb 100644 --- a/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts +++ b/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts @@ -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): SagaIterator { +function* readAllByProbe(action: Action): 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().regist, target); + const retTargets = yield call(AppContext.getService().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): SagaIterator { } } -export function* watchSignin(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); +export function* watchReadAllByProbe(): SagaIterator { + yield takeLatest(ReadAllByProbeActions.REQUEST, readAllByProbe); } diff --git a/src/ts/@overflow/target/redux/saga/regist.ts b/src/ts/@overflow/target/redux/saga/regist.ts index b308497..7bc1753 100644 --- a/src/ts/@overflow/target/redux/saga/regist.ts +++ b/src/ts/@overflow/target/redux/saga/regist.ts @@ -33,6 +33,6 @@ function* regist(action: Action): SagaIterator { } } -export function* watchSignin(): SagaIterator { +export function* watchRegist(): SagaIterator { yield takeLatest(RegistActions.REQUEST, regist); } diff --git a/src/ts/@overflow/target/redux/saga/remove.ts b/src/ts/@overflow/target/redux/saga/remove.ts index 5c15c15..3908a26 100644 --- a/src/ts/@overflow/target/redux/saga/remove.ts +++ b/src/ts/@overflow/target/redux/saga/remove.ts @@ -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): SagaIterator { + try { + const {target} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + yield call(AppContext.getService().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); +}