diff --git a/src/ts/@overflow/probe/api/service/ProbeService.ts b/src/ts/@overflow/probe/api/service/ProbeService.ts index 31a5162..c3a12da 100644 --- a/src/ts/@overflow/probe/api/service/ProbeService.ts +++ b/src/ts/@overflow/probe/api/service/ProbeService.ts @@ -1,5 +1,6 @@ import Service from '@overflow/commons/api/Service'; import Probe from '../model/Probe'; +import Domain from '@overflow/domain/api/model/Domain'; export class ProbeService extends Service { @@ -7,13 +8,18 @@ export class ProbeService extends Service { super('ProbeService'); } - public regist(probe:Probe): void { + public regist(probe: Probe): Promise { return null; } - public remove(probeKey:string): Promise { + public readAllByDomain(domain: Domain): Promise { return null; } + + public readByProbeKey(probeKey: string): Promise { + return null; + } + } -export default ProbeService; \ No newline at end of file +export default ProbeService; diff --git a/src/ts/@overflow/probe/api/service/ProbeTaskService.ts b/src/ts/@overflow/probe/api/service/ProbeTaskService.ts index cdcf016..5030ab3 100644 --- a/src/ts/@overflow/probe/api/service/ProbeTaskService.ts +++ b/src/ts/@overflow/probe/api/service/ProbeTaskService.ts @@ -12,10 +12,9 @@ export class ProbeTaskService extends Service { return null; } - // Todo List - public readAllByProbe(probe:Probe): Promise { + public readAllByProbe(probe:Probe): Promise { return null; } } -export default ProbeTaskService; \ No newline at end of file +export default ProbeTaskService; diff --git a/src/ts/@overflow/probe/redux/action/probe_regist.ts b/src/ts/@overflow/probe/redux/action/probe_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/probe/redux/action/probe_remove.ts b/src/ts/@overflow/probe/redux/action/probe_remove.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/action/probe_remove.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/action/probe_task_read_all_by_probe.ts b/src/ts/@overflow/probe/redux/action/probe_task_read_all_by_probe.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/action/probe_task_read_all_by_probe.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/action/probe_task_regist.ts b/src/ts/@overflow/probe/redux/action/probe_task_regist.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/action/probe_task_regist.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/action/read_all_by_domain.ts b/src/ts/@overflow/probe/redux/action/read_all_by_domain.ts new file mode 100644 index 0000000..c5e9ece --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/read_all_by_domain.ts @@ -0,0 +1,43 @@ +import Action from '@overflow/commons/redux/Action'; +import Probe from '../../api/model/Probe'; +import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload'; +import Domain from '@overflow/domain/api/model/Domain'; + +// Action Type +export type REQUEST = '@overflow/probe/read_all_by_domain/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/probe/read_all_by_domain/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/probe/read_all_by_domain/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/probe/read_all_by_domain/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/read_all_by_domain/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/read_all_by_domain/REQUEST_FAILURE'; + +// Action Creater +export type request = (domain: Domain) => Action; +export type requestSuccess = (probes: Probe[]) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (domain: Domain): Action => { + return { + type: REQUEST, + payload: { + domain: domain, + }, + }; +}; + +export const requestSuccess: requestSuccess = (probes: Probe[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: probes, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/probe/redux/action/read_by_probekey.ts b/src/ts/@overflow/probe/redux/action/read_by_probekey.ts new file mode 100644 index 0000000..ad0af15 --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/read_by_probekey.ts @@ -0,0 +1,43 @@ +import Action from '@overflow/commons/redux/Action'; +import Probe from '../../api/model/Probe'; +import ReadByProbeKeyPayload from '../payload/ReadByProbeKeyPayload'; +import Domain from '@overflow/domain/api/model/Domain'; + +// Action Type +export type REQUEST = '@overflow/probe/read_by_probekey/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/probe/read_by_probekey/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/probe/read_by_probekey/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/probe/read_by_probekey/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/read_by_probekey/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/read_by_probekey/REQUEST_FAILURE'; + +// Action Creater +export type request = (probeKey: string) => Action; +export type requestSuccess = (probe: Probe) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (probeKey: string): Action => { + return { + type: REQUEST, + payload: { + probeKey: probeKey, + }, + }; +}; + +export const requestSuccess: requestSuccess = (probe: Probe): Action => { + return { + type: REQUEST_SUCCESS, + payload: probe, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/probe/redux/action/regist.ts b/src/ts/@overflow/probe/redux/action/regist.ts new file mode 100644 index 0000000..b461b87 --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/regist.ts @@ -0,0 +1,42 @@ +import Action from '@overflow/commons/redux/Action'; +import Probe from '../../api/model/Probe'; +import RegistPayload from '../payload/RegistPayload'; + +// Action Type +export type REQUEST = '@overflow/probe/regist/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/probe/regist/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/probe/regist/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/probe/regist/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/regist/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/regist/REQUEST_FAILURE'; + +// Action Creater +export type request = (probe: Probe) => Action; +export type requestSuccess = (probe: Probe) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (probe: Probe): Action => { + return { + type: REQUEST, + payload: { + probe: probe, + }, + }; +}; + +export const requestSuccess: requestSuccess = (probe: Probe): Action => { + return { + type: REQUEST_SUCCESS, + payload: probe, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/probe/redux/action/task_read_all_by_probe.ts b/src/ts/@overflow/probe/redux/action/task_read_all_by_probe.ts new file mode 100644 index 0000000..f1d57b4 --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/task_read_all_by_probe.ts @@ -0,0 +1,41 @@ +import Action from '@overflow/commons/redux/Action'; +import Probe from '../../api/model/Probe'; +import ProbeTask from '../../api/model/ProbeTask'; +import TaskReadAllByProbePayload from '../payload/TaskReadAllByProbePayload'; + +// Action Type +export type REQUEST = '@overflow/probe/task_read_all_by_probe/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/probe/task_read_all_by_probe/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/probe/task_read_all_by_probe/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/probe/task_read_all_by_probe/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/task_read_all_by_probe/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/task_read_all_by_probe/REQUEST_FAILURE'; + +// Action Creater +export type request = (probe: Probe) => Action; +export type requestSuccess = (probeTasks: ProbeTask[]) => Action; +export type requestFailure = (error: Error) => Action; + +export const request: request = (probe: Probe): Action => { + return { + type: REQUEST, + payload: { + probe: probe, + }, + }; +}; + +export const requestSuccess: requestSuccess = (probeTasks: ProbeTask[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: probeTasks, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/probe/redux/action/task_regist.ts b/src/ts/@overflow/probe/redux/action/task_regist.ts new file mode 100644 index 0000000..0268ec0 --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/task_regist.ts @@ -0,0 +1,42 @@ +import Action from '@overflow/commons/redux/Action'; +import ProbeTask from '../../api/model/ProbeTask'; +import TaskRegistPayload from '../payload/TaskRegistPayload'; + +// Action Type +export type REQUEST = '@overflow/probe/task_regist/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/probe/task_regist/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/probe/task_regist/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/probe/task_regist/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/task_regist/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/task_regist/REQUEST_FAILURE'; + +// Action Creater +export type request = (probeTask: ProbeTask) => Action; +export type requestSuccess = (probeTask: ProbeTask) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (probeTask: ProbeTask): Action => { + return { + type: REQUEST, + payload: { + probeTask: probeTask, + }, + }; +}; + +export const requestSuccess: requestSuccess = (probeTask: ProbeTask): Action => { + return { + type: REQUEST_SUCCESS, + payload: probeTask, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/probe/redux/payload/ProbeRegistPayload.ts b/src/ts/@overflow/probe/redux/payload/ProbeRegistPayload.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/probe/redux/payload/ProbeRemovePayload.ts b/src/ts/@overflow/probe/redux/payload/ProbeRemovePayload.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/payload/ProbeRemovePayload.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/payload/ProbeTaskReadAllByProbePayload.ts b/src/ts/@overflow/probe/redux/payload/ProbeTaskReadAllByProbePayload.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/payload/ProbeTaskReadAllByProbePayload.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/payload/ProbeTaskRegist.ts b/src/ts/@overflow/probe/redux/payload/ProbeTaskRegist.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/payload/ProbeTaskRegist.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/payload/ReadAllByDomainPayload.ts b/src/ts/@overflow/probe/redux/payload/ReadAllByDomainPayload.ts new file mode 100644 index 0000000..0db8562 --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/ReadAllByDomainPayload.ts @@ -0,0 +1,7 @@ +import Domain from '@overflow/domain/api/model/Domain'; + +interface ProbeReadAllByDomainPayload { + domain: Domain; +} + +export default ProbeReadAllByDomainPayload; diff --git a/src/ts/@overflow/probe/redux/payload/ReadByProbeKeyPayload.ts b/src/ts/@overflow/probe/redux/payload/ReadByProbeKeyPayload.ts new file mode 100644 index 0000000..8bf8ad3 --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/ReadByProbeKeyPayload.ts @@ -0,0 +1,5 @@ +interface ProbeReadByProbeKeyPayload { + probeKey: string; +} + +export default ProbeReadByProbeKeyPayload; diff --git a/src/ts/@overflow/probe/redux/payload/RegistPayload.ts b/src/ts/@overflow/probe/redux/payload/RegistPayload.ts new file mode 100644 index 0000000..c3f402d --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/RegistPayload.ts @@ -0,0 +1,7 @@ +import Probe from '../../api/model/Probe'; + +interface ProbeRegistPayload { + probe: Probe; +} + +export default ProbeRegistPayload; diff --git a/src/ts/@overflow/probe/redux/payload/TaskReadAllByProbePayload.ts b/src/ts/@overflow/probe/redux/payload/TaskReadAllByProbePayload.ts new file mode 100644 index 0000000..56ff13d --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/TaskReadAllByProbePayload.ts @@ -0,0 +1,7 @@ +import Probe from '../../api/model/Probe'; + +interface TaskReadAllByProbePayload { + probe: Probe; +} + +export default TaskReadAllByProbePayload; diff --git a/src/ts/@overflow/probe/redux/payload/TaskRegistPayload.ts b/src/ts/@overflow/probe/redux/payload/TaskRegistPayload.ts new file mode 100644 index 0000000..aad31e2 --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/TaskRegistPayload.ts @@ -0,0 +1,7 @@ +import ProbeTask from '../../api/model/ProbeTask'; + +interface TaskRegistPayload { + probeTask: ProbeTask; +} + +export default TaskRegistPayload; diff --git a/src/ts/@overflow/probe/redux/saga/probe_regist.ts b/src/ts/@overflow/probe/redux/saga/probe_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/probe/redux/saga/probe_remove.ts b/src/ts/@overflow/probe/redux/saga/probe_remove.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/saga/probe_remove.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/saga/probe_task_read_all_by_probe.ts b/src/ts/@overflow/probe/redux/saga/probe_task_read_all_by_probe.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/saga/probe_task_read_all_by_probe.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/saga/probe_task_regist.ts b/src/ts/@overflow/probe/redux/saga/probe_task_regist.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/probe/redux/saga/probe_task_regist.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts b/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts new file mode 100644 index 0000000..e4c1f95 --- /dev/null +++ b/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts @@ -0,0 +1,37 @@ +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 ProbeService from '../../api/service/ProbeService'; +import * as ReadAllByDomainActions from '../action/read_all_by_domain'; +import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload'; + +function* readAllByDomain(action: Action): SagaIterator { + try { + const {domain} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const ret = yield call(AppContext.getService().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* watchReadAllByDomain(): SagaIterator { + yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain); +} diff --git a/src/ts/@overflow/probe/redux/saga/read_by_probekey.ts b/src/ts/@overflow/probe/redux/saga/read_by_probekey.ts new file mode 100644 index 0000000..cc3a5e8 --- /dev/null +++ b/src/ts/@overflow/probe/redux/saga/read_by_probekey.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 Probe from '../../api/model/Probe'; +import ProbeService from '../../api/service/ProbeService'; +import * as ReadByProbeKeyActions from '../action/read_by_probekey'; +import ReadByProbeKeyPayload from '../payload/ReadByProbeKeyPayload'; + +function* readByProbeKey(action: Action): SagaIterator { + try { + const {probeKey} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const ret = yield call(AppContext.getService().readByProbeKey, probeKey); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(ReadByProbeKeyActions.requestSuccess(ret)); + } catch (e) { + yield put(ReadByProbeKeyActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchReadByProbeKey(): SagaIterator { + yield takeLatest(ReadByProbeKeyActions.REQUEST, readByProbeKey); +} diff --git a/src/ts/@overflow/probe/redux/saga/regist.ts b/src/ts/@overflow/probe/redux/saga/regist.ts new file mode 100644 index 0000000..c865c89 --- /dev/null +++ b/src/ts/@overflow/probe/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 Probe from '../../api/model/Probe'; +import ProbeService from '../../api/service/ProbeService'; +import * as RegistActions from '../action/regist'; +import RegistPayload from '../payload/RegistPayload'; + +function* regist(action: Action): SagaIterator { + try { + const {probe} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const ret = yield call(AppContext.getService().regist, probe); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(RegistActions.requestSuccess(ret)); + } 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/probe/redux/saga/task_read_all_by_probe.ts b/src/ts/@overflow/probe/redux/saga/task_read_all_by_probe.ts new file mode 100644 index 0000000..9d69c97 --- /dev/null +++ b/src/ts/@overflow/probe/redux/saga/task_read_all_by_probe.ts @@ -0,0 +1,37 @@ +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 ProbeTaskService from '../../api/service/ProbeTaskService'; +import * as TaskReadAllByProbeActions from '../action/task_read_all_by_probe'; +import TaskReadAllByProbePayload from '../payload/TaskReadAllByProbePayload'; + +function* readAllTaskByProbe(action: Action): SagaIterator { + try { + const {probe} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const ret = yield call(AppContext.getService().readAllByProbe, probe); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(TaskReadAllByProbeActions.requestSuccess(ret)); + } catch (e) { + yield put(TaskReadAllByProbeActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchReadAllTaskByProbe(): SagaIterator { + yield takeLatest(TaskReadAllByProbeActions.REQUEST, readAllTaskByProbe); +} diff --git a/src/ts/@overflow/probe/redux/saga/task_regist.ts b/src/ts/@overflow/probe/redux/saga/task_regist.ts new file mode 100644 index 0000000..b6ddd72 --- /dev/null +++ b/src/ts/@overflow/probe/redux/saga/task_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 ProbeTask from '../../api/model/ProbeTask'; +import ProbeTaskService from '../../api/service/ProbeTaskService'; +import * as TaskRegistActions from '../action/task_regist'; +import TaskRegistPayload from '../payload/TaskRegistPayload'; + +function* registTask(action: Action): SagaIterator { + try { + const {probeTask} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const ret = yield call(AppContext.getService().regist, probeTask); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(TaskRegistActions.requestSuccess(ret)); + } catch (e) { + yield put(TaskRegistActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchRegistTask(): SagaIterator { + yield takeLatest(TaskRegistActions.REQUEST, registTask); +} diff --git a/src/ts/@overflow/sensor/redux/saga/item_read.ts b/src/ts/@overflow/sensor/redux/saga/item_read.ts index 4a4923d..5c3f38d 100644 --- a/src/ts/@overflow/sensor/redux/saga/item_read.ts +++ b/src/ts/@overflow/sensor/redux/saga/item_read.ts @@ -17,12 +17,12 @@ function* readItem(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().read, id); + const ret = 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)); + yield put(ItemReadActions.requestSuccess(ret)); } catch (e) { yield put(ItemReadActions.requestFailure(e)); } finally { 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 af57fc4..2bee7e1 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 @@ -17,12 +17,12 @@ function* readAllItemBySensor(action: Action) // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().readAllBySensor, sensor); + const ret = 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)); + yield put(ItemReadAllBySensorActions.requestSuccess(ret)); } catch (e) { yield put(ItemReadAllBySensorActions.requestFailure(e)); } finally { diff --git a/src/ts/@overflow/sensor/redux/saga/item_regist.ts b/src/ts/@overflow/sensor/redux/saga/item_regist.ts index 7aec82a..f1f6603 100644 --- a/src/ts/@overflow/sensor/redux/saga/item_regist.ts +++ b/src/ts/@overflow/sensor/redux/saga/item_regist.ts @@ -17,12 +17,12 @@ function* registItem(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().regist, sensorItem); + const ret = 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)); + yield put(ItemRegistActions.requestSuccess(ret)); } catch (e) { yield put(ItemRegistActions.requestFailure(e)); } finally { diff --git a/src/ts/@overflow/sensor/redux/saga/read.ts b/src/ts/@overflow/sensor/redux/saga/read.ts index 913c0a6..ce444eb 100644 --- a/src/ts/@overflow/sensor/redux/saga/read.ts +++ b/src/ts/@overflow/sensor/redux/saga/read.ts @@ -17,12 +17,12 @@ function* read(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().read, id); + const ret = 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)); + yield put(ReadActions.requestSuccess(ret)); } catch (e) { yield put(ReadActions.requestFailure(e)); } finally { 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 index 44e20e1..eb3dd23 100644 --- a/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts +++ b/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts @@ -17,12 +17,12 @@ function* readAllByTarget(action: Action): SagaIterator // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().readAllByTarget, target); + const ret = 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)); + yield put(ReadAllByTargetActions.requestSuccess(ret)); } catch (e) { yield put(ReadAllByTargetActions.requestFailure(e)); } finally { diff --git a/src/ts/@overflow/sensor/redux/saga/regist.ts b/src/ts/@overflow/sensor/redux/saga/regist.ts index a9a2426..e2fd438 100644 --- a/src/ts/@overflow/sensor/redux/saga/regist.ts +++ b/src/ts/@overflow/sensor/redux/saga/regist.ts @@ -17,12 +17,12 @@ function* regist(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().regist, sensor); + const ret = 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)); + yield put(RegistActions.requestSuccess(ret)); } catch (e) { yield put(RegistActions.requestFailure(e)); } finally { diff --git a/src/ts/@overflow/sensor/redux/saga/start.ts b/src/ts/@overflow/sensor/redux/saga/start.ts index 9df6edd..604e7ac 100644 --- a/src/ts/@overflow/sensor/redux/saga/start.ts +++ b/src/ts/@overflow/sensor/redux/saga/start.ts @@ -17,12 +17,12 @@ function* start(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().start, sensor); + const ret = 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)); + yield put(StartActions.requestSuccess(ret)); } catch (e) { yield put(StartActions.requestFailure(e)); } finally { diff --git a/src/ts/@overflow/sensor/redux/saga/stop.ts b/src/ts/@overflow/sensor/redux/saga/stop.ts index 5fb1cb4..6619c1f 100644 --- a/src/ts/@overflow/sensor/redux/saga/stop.ts +++ b/src/ts/@overflow/sensor/redux/saga/stop.ts @@ -17,12 +17,12 @@ function* stop(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const retSensor = yield call(AppContext.getService().stop, sensor); + const ret = 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)); + yield put(StopActions.requestSuccess(ret)); } catch (e) { yield put(StopActions.requestFailure(e)); } finally { diff --git a/src/ts/@overflow/target/api/service/TargetDiscoveryService.ts b/src/ts/@overflow/target/api/service/TargetDiscoveryService.ts index 501d4fe..5cecd9c 100644 --- a/src/ts/@overflow/target/api/service/TargetDiscoveryService.ts +++ b/src/ts/@overflow/target/api/service/TargetDiscoveryService.ts @@ -2,17 +2,16 @@ import Service from '@overflow/commons/api/Service'; import Probe from '@overflow/probe/api/model/Probe'; import Host from '@overflow/discovery/api/model/Host'; -export class TargetService extends Service { +export class TargetDiscoveryService extends Service { public constructor() { - super('TargetService'); + super('TargetDiscoveryService'); } - // Todo List - public remove(host:Host, probe:Probe): void { + public saveAllTarget(hosts:Host[], probe:Probe): void { return null; } } -export default TargetService; +export default TargetDiscoveryService;