This commit is contained in:
snoop 2017-07-04 15:37:49 +09:00
commit ebe4703c01
15 changed files with 226 additions and 29 deletions

View File

@ -23,7 +23,7 @@ export class TargetService extends Service {
});
}
public readByProbe(probe:Probe): Promise<Target> {
public readAllByProbe(probe:Probe): Promise<Target[]> {
return null;
}

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/

View File

@ -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<ReadAllByProbePayload>;
export type requestSuccess = (targets: Target[]) => Action<Target[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (probe: Probe): Action<ReadAllByProbePayload> => {
return {
type: REQUEST,
payload: {
probe: probe,
},
};
};
export const requestSuccess: requestSuccess = (targets: Target[]): Action<Target[]> => {
return {
type: REQUEST_SUCCESS,
payload: targets,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<RegistPayload>;
export type request = (target: Target) => Action<RegistPayload>;
export type requestSuccess = (target: Target) => Action<Target>;
export type requestFailure = (error: Error) => Action;
export const request: request = (probe: Probe, infra: Infra): Action<RegistPayload> => {
export const request: request = (target: Target): Action<RegistPayload> => {
return {
type: REQUEST,
payload: {
probe: probe,
infra: infra,
target: target,
},
};
};
export const requestSuccess: requestSuccess = (apiKey: ApiKey): Action<ApiKey> => {
export const requestSuccess: requestSuccess = (target: Target): Action<Target> => {
return {
type: REQUEST_SUCCESS,
payload: apiKey,
payload: target,
};
};

View File

@ -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<RemovePayload>;
export type requestSuccess = () => Action<void>;
export type requestFailure = (error: Error) => Action;
export const request: request = (target: Target): Action<RemovePayload> => {
return {
type: REQUEST,
payload: {
target: target,
},
};
};
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,
};
};

View File

@ -0,0 +1,7 @@
import Probe from '@overflow/probe/api/model/Probe';
interface ReadAllByProbePayload {
probe: Probe;
}
export default ReadAllByProbePayload;

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/

View File

@ -0,0 +1,5 @@
interface ReadPayload {
id: string;
}
export default ReadPayload;

View File

@ -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;

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/

View File

@ -0,0 +1,7 @@
import Target from '../../api/model/Target';
interface RemovePayload {
target: Target;
}
export default RemovePayload;

View File

@ -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<RegistPayload>): SagaIterator {
try {
const {target} = action.payload;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const retTarget = yield call(AppContext.getService<TargetService>().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);
}

View File

@ -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<RegistPayload>): SagaIterator {
try {
const {target} = action.payload;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const retTarget = yield call(AppContext.getService<TargetService>().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);
}

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/

View File

@ -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<RegistPayload>): SagaIterator {
try {
const {target} = action.payload;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const retTarget = yield call(AppContext.getService<TargetService>().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);
}