diff --git a/src/ts/@overflow/target/api/service/TargetService.ts b/src/ts/@overflow/target/api/service/TargetService.ts index 3ecd120..ff74536 100644 --- a/src/ts/@overflow/target/api/service/TargetService.ts +++ b/src/ts/@overflow/target/api/service/TargetService.ts @@ -23,7 +23,7 @@ export class TargetService extends Service { }); } - public readByProbe(probe:Probe): Promise { + public readAllByProbe(probe:Probe): Promise { return null; } diff --git a/src/ts/@overflow/target/redux/action/readByProbe.ts b/src/ts/@overflow/target/redux/action/readByProbe.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/target/redux/action/readByProbe.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ 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 new file mode 100644 index 0000000..ae30e31 --- /dev/null +++ b/src/ts/@overflow/target/redux/action/read_all_by_probe.ts @@ -0,0 +1,43 @@ +import Action from '@overflow/commons/redux/Action'; +import Target from '../../api/model/Target'; +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 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 = (probe: Probe) => Action; +export type requestSuccess = (targets: Target[]) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (probe: Probe): Action => { + return { + type: REQUEST, + payload: { + probe: probe, + }, + }; +}; + +export const requestSuccess: requestSuccess = (targets: Target[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: targets, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/target/redux/action/regist.ts b/src/ts/@overflow/target/redux/action/regist.ts index 8dca3c8..034390d 100644 --- a/src/ts/@overflow/target/redux/action/regist.ts +++ b/src/ts/@overflow/target/redux/action/regist.ts @@ -14,26 +14,25 @@ export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/regist/REQUEST export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/regist/REQUEST_FAILURE'; // Action Creater -export type request = (probe: Probe, infra: Infra) => Action; +export type request = (target: Target) => Action; export type requestSuccess = (target: Target) => Action; export type requestFailure = (error: Error) => Action; -export const request: request = (probe: Probe, infra: Infra): Action => { +export const request: request = (target: Target): Action => { return { type: REQUEST, payload: { - probe: probe, - infra: infra, + target: target, }, }; }; -export const requestSuccess: requestSuccess = (apiKey: ApiKey): Action => { +export const requestSuccess: requestSuccess = (target: Target): Action => { return { type: REQUEST_SUCCESS, - payload: apiKey, + payload: target, }; }; diff --git a/src/ts/@overflow/target/redux/action/remove.ts b/src/ts/@overflow/target/redux/action/remove.ts index 5c15c15..e12b89c 100644 --- a/src/ts/@overflow/target/redux/action/remove.ts +++ b/src/ts/@overflow/target/redux/action/remove.ts @@ -1,3 +1,42 @@ -/** - * Created by geek on 17. 7. 3. - */ +import Action from '@overflow/commons/redux/Action'; +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 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'; + +// Action Creater +export type request = (target: Target) => Action; +export type requestSuccess = () => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (target: Target): Action => { + return { + type: REQUEST, + payload: { + target: target, + }, + }; +}; + +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/payload/ReadAllByProbePayload.ts b/src/ts/@overflow/target/redux/payload/ReadAllByProbePayload.ts new file mode 100644 index 0000000..2f5901e --- /dev/null +++ b/src/ts/@overflow/target/redux/payload/ReadAllByProbePayload.ts @@ -0,0 +1,7 @@ +import Probe from '@overflow/probe/api/model/Probe'; + +interface ReadAllByProbePayload { + probe: Probe; +} + +export default ReadAllByProbePayload; diff --git a/src/ts/@overflow/target/redux/payload/ReadByProbePayload.ts b/src/ts/@overflow/target/redux/payload/ReadByProbePayload.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/target/redux/payload/ReadByProbePayload.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/target/redux/payload/ReadPayload.ts b/src/ts/@overflow/target/redux/payload/ReadPayload.ts index e69de29..a56fb77 100644 --- a/src/ts/@overflow/target/redux/payload/ReadPayload.ts +++ b/src/ts/@overflow/target/redux/payload/ReadPayload.ts @@ -0,0 +1,5 @@ +interface ReadPayload { + id: string; +} + +export default ReadPayload; diff --git a/src/ts/@overflow/target/redux/payload/RegistPayload.ts b/src/ts/@overflow/target/redux/payload/RegistPayload.ts index a11c90d..292d691 100644 --- a/src/ts/@overflow/target/redux/payload/RegistPayload.ts +++ b/src/ts/@overflow/target/redux/payload/RegistPayload.ts @@ -1,9 +1,7 @@ -import Infra from '@overflow/infra/api/model/Infra'; -import Probe from '@overflow/probe/api/model/Probe'; +import Target from '../../api/model/Target'; interface RegistPayload { - infra: Infra; - probe: Probe; + target: Target; } export default RegistPayload; diff --git a/src/ts/@overflow/target/redux/payload/Remove.ts b/src/ts/@overflow/target/redux/payload/Remove.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/target/redux/payload/Remove.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/target/redux/payload/RemovePayload.ts b/src/ts/@overflow/target/redux/payload/RemovePayload.ts new file mode 100644 index 0000000..8d706e2 --- /dev/null +++ b/src/ts/@overflow/target/redux/payload/RemovePayload.ts @@ -0,0 +1,7 @@ +import Target from '../../api/model/Target'; + +interface RemovePayload { + target: Target; +} + +export default RemovePayload; diff --git a/src/ts/@overflow/target/redux/saga/read.ts b/src/ts/@overflow/target/redux/saga/read.ts index 5c15c15..3f9c7d8 100644 --- a/src/ts/@overflow/target/redux/saga/read.ts +++ b/src/ts/@overflow/target/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 Target from '../../api/model/Target'; +import TargetService from '../../api/service/TargetService'; +import * as ReadActions from '../action/read'; +import ReadPayload from '../payload/ReadPayload'; + +function* read(action: Action): SagaIterator { + try { + const {target} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retTarget = yield call(AppContext.getService().regist, target); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(RegistActions.requestSuccess(retTarget)); + } catch (e) { + yield put(RegistActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchSignin(): SagaIterator { + yield takeLatest(RegistActions.REQUEST, regist); +} 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 new file mode 100644 index 0000000..897c87d --- /dev/null +++ b/src/ts/@overflow/target/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'; +import Action from '@overflow/commons/redux/Action'; + +import Target from '../../api/model/Target'; +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 { + try { + const {target} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retTarget = yield call(AppContext.getService().regist, target); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(RegistActions.requestSuccess(retTarget)); + } catch (e) { + yield put(RegistActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchSignin(): SagaIterator { + yield takeLatest(RegistActions.REQUEST, regist); +} diff --git a/src/ts/@overflow/target/redux/saga/read_by_probe.ts b/src/ts/@overflow/target/redux/saga/read_by_probe.ts deleted file mode 100644 index 5c15c15..0000000 --- a/src/ts/@overflow/target/redux/saga/read_by_probe.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by geek on 17. 7. 3. - */ diff --git a/src/ts/@overflow/target/redux/saga/regist.ts b/src/ts/@overflow/target/redux/saga/regist.ts index e69de29..b308497 100644 --- a/src/ts/@overflow/target/redux/saga/regist.ts +++ b/src/ts/@overflow/target/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 Target from '../../api/model/Target'; +import TargetService from '../../api/service/TargetService'; +import * as RegistActions from '../action/regist'; +import RegistPayload from '../payload/RegistPayload'; + +function* regist(action: Action): SagaIterator { + try { + const {target} = action.payload; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + const retTarget = yield call(AppContext.getService().regist, target); + + // if (responseBody.token === undefined) { + // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); + // } + yield put(RegistActions.requestSuccess(retTarget)); + } catch (e) { + yield put(RegistActions.requestFailure(e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } +} + +export function* watchSignin(): SagaIterator { + yield takeLatest(RegistActions.REQUEST, regist); +}