This commit is contained in:
snoop 2017-07-04 16:49:00 +09:00
commit bd0e31ecdb
54 changed files with 1150 additions and 53 deletions

View File

@ -5,11 +5,124 @@ import Signin from '../views/member/Signin';
const routes = (
<Switch>
<Route exact path='/' />
<Route path='/signin' component={Signin} />
<Route path='/'>
</Route>
<Route component={NoMatch}/>
</Switch>
);
export default routes;
const _routes = [
{
path: '/signin',
component: Signin,
},
{
path: '/signup',
component: Signup,
},
{
path: '/forgot_password',
component: ForgotPassword,
},
{
path: '/email_confirm',
component: EmailConfirm,
},
{
path: '/',
component: Home,
routes: [
{
path: '/monitoring',
component: Monitoring,
routes: [
{
path: '/probe',
component: Probe,
routes: [
{
path: '/list',
component: Probe,
},
{
path: '/noauth',
component: NoAuthProbe,
},
{
path: '/setup',
component: ProbeSetup,
},
],
},
{
path: '/sensor',
component: Sensor,
},
],
},
{
path: '/infrastructure',
component: ,
routes: [
{
path: '/maps',
component: InfrastructureMaps,
},
{
path: '/targets',
component: Targets,
},
],
},
{
path: '/dashboard',
component: Dashboard,
},
{
path: '/metrics',
component: Metrics,
},
{
path: '/alerts',
component: Alerts,
},
{
path: '/history',
component: History,
},
{
path: '/settings',
component: Settings,
},
{
path: '/notifications',
component: Notifications,
},
{
path: '/account',
component: ,
routes: [
{
path: '/signout',
component: Signout,
},
{
path: '/profile',
component: Profile,
},
{
path: '/preferences',
component: Preferences,
},
{
path: '/help',
component: Help,
},
],
},
],
},
];

View File

@ -1,13 +1,256 @@
export type OnConnectFunc = () => void;
export type OnWebsocketDisconnectFunc = () => void;
export type OnWebsocketNativeMessageFunc = (websocketMessage: string) => void;
export type OnMessageFunc = (message: any) => void;
enum MessageType {
STRING = 1,
INT,
BOOLEAN,
JSON,
}
class Client {
private wss: WebSocket;
private conn: WebSocket;
private isReady: boolean;
// events listeners
private connectListeners: OnConnectFunc[] = [];
private disconnectListeners: OnWebsocketDisconnectFunc[] = [];
private nativeMessageListeners: OnWebsocketNativeMessageFunc[] = [];
private messageListeners: { [event: string]: OnMessageFunc[] } = {};
constructor(endpoint: string, protocols?: string[]) {
// if (!window.WebSocket) {
// return;
// }
if (endpoint.indexOf('ws') === -1) {
endpoint = 'ws://' + endpoint;
}
if (protocols != null && protocols.length > 0) {
this.conn = new WebSocket(endpoint, protocols);
} else {
this.conn = new WebSocket(endpoint);
}
this.conn.onopen = ((evt: Event): any => {
this.fireConnect();
this.isReady = true;
return null;
});
this.conn.onclose = ((evt: Event): any => {
this.fireDisconnect();
return null;
});
this.conn.onmessage = ((evt: MessageEvent) => {
this.messageReceivedFromConn(evt);
});
this.conn.onerror = ((evt: MessageEvent) => {
this.errorReceivedFromConn(evt);
});
}
public OnConnect(fn: OnConnectFunc): void {
if (this.isReady) {
fn();
}
this.connectListeners.push(fn);
}
public OnDisconnect(fn: OnWebsocketDisconnectFunc): void {
this.disconnectListeners.push(fn);
}
public OnMessage(cb: OnWebsocketNativeMessageFunc): void {
this.nativeMessageListeners.push(cb);
}
public On(event: string, cb: OnMessageFunc): void {
if (this.messageListeners[event] == null || this.messageListeners[event] === undefined) {
this.messageListeners[event] = [];
}
this.messageListeners[event].push(cb);
}
//
// Ws Actions
public Disconnect(): void {
this.conn.close();
}
// EmitMessage sends a native websocket message
public EmitMessage(websocketMessage: string): void {
this.conn.send(websocketMessage);
}
protected fireConnect(): void {
for (let i = 0; i < this.connectListeners.length; i++) {
this.connectListeners[i]();
}
}
protected fireDisconnect(): void {
for (let i = 0; i < this.disconnectListeners.length; i++) {
this.disconnectListeners[i]();
}
}
protected fireNativeMessage(websocketMessage: string): void {
for (let i = 0; i < this.nativeMessageListeners.length; i++) {
this.nativeMessageListeners[i](websocketMessage);
}
}
protected fireMessage(event: string, message: any): void {
for (let key in this.messageListeners) {
if (this.messageListeners.hasOwnProperty(key)) {
if (key === event) {
for (let i = 0; i < this.messageListeners[key].length; i++) {
this.messageListeners[key][i](message);
}
}
}
}
}
// utils
private isNumber(obj: any): boolean {
return !isNaN(obj - 0) && obj !== null && obj !== '' && obj !== false;
}
private isString(obj: any): boolean {
return Object.prototype.toString.call(obj) === '[object String]';
}
private isBoolean(obj: any): boolean {
return typeof obj === 'boolean' ||
(typeof obj === 'object' && typeof obj.valueOf() === 'boolean');
}
private isJSON(obj: any): boolean {
return typeof obj === 'object';
}
//
// messages
private _msg(event: string, messageType: MessageType, dataMessage: string): string {
return websocketMessagePrefix + event + websocketMessageSeparator + String(websocketMessageType) + websocketMessageSeparator + dataMessage;
}
private encodeMessage(event: string, data: any): string {
let m = '';
let t: MessageType = MessageType.STRING;
if (this.isNumber(data)) {
t = MessageType.INT;
m = data.toString();
} else if (this.isBoolean(data)) {
t = MessageType.BOOLEAN;
m = data.toString();
} else if (this.isString(data)) {
t = MessageType.STRING;
m = data.toString();
} else if (this.isJSON(data)) {
// propably json-object
t = MessageType.JSON;
m = JSON.stringify(data);
} else {
console.log('Invalid, javascript-side should contains an empty second parameter.');
}
return this._msg(event, t, m);
}
private decodeMessage<T>(event: string, websocketMessage: string): T | any {
// q-websocket-message;user;4;themarshaledstringfromajsonstruct
let skipLen = websocketMessagePrefixLen + websocketMessageSeparatorLen + event.length + 2;
if (websocketMessage.length < skipLen + 1) {
return null;
}
let websocketMessageType = parseInt(websocketMessage.charAt(skipLen - 2));
let theMessage = websocketMessage.substring(skipLen, websocketMessage.length);
if (websocketMessageType === MessageType.INT) {
return parseInt(theMessage);
} else if (websocketMessageType === MessageType.BOOLEAN) {
return Boolean(theMessage);
} else if (websocketMessageType === MessageType.STRING) {
return theMessage;
} else if (websocketMessageType === MessageType.JSON) {
return JSON.parse(theMessage);
} else {
return null; // invalid
}
}
private getWebsocketCustomEvent(websocketMessage: string): string {
if (websocketMessage.length < websocketMessagePrefixAndSepIdx) {
return '';
}
let s = websocketMessage.substring(websocketMessagePrefixAndSepIdx, websocketMessage.length);
let evt = s.substring(0, s.indexOf(websocketMessageSeparator));
return evt;
}
private getCustomMessage(event: string, websocketMessage: string): string {
let eventIdx = websocketMessage.indexOf(event + websocketMessageSeparator);
let s = websocketMessage.substring(eventIdx + event.length + websocketMessageSeparator.length + 2, websocketMessage.length);
return s;
}
//
// Ws Events
// messageReceivedFromConn this is the func which decides
// if it's a native websocket message or a custom qws message
// if native message then calls the fireNativeMessage
// else calls the fireMessage
//
// remember q gives you the freedom of native websocket messages if you don't want to use this client side at all.
private messageReceivedFromConn(evt: MessageEvent): void {
// check if qws message
let message = <string>evt.data;
if (message.indexOf(websocketMessagePrefix) !== -1) {
let event = this.getWebsocketCustomEvent(message);
if (event !== '') {
// it's a custom message
this.fireMessage(event, this.getCustomMessage(event, message));
return;
}
}
// it's a native websocket message
this.fireNativeMessage(message);
}
// errorReceivedFromConn this is the func which decides
// if it's a native websocket message or a custom qws message
// if native message then calls the fireNativeMessage
// else calls the fireMessage
//
// remember q gives you the freedom of native websocket messages if you don't want to use this client side at all.
private errorReceivedFromConn(evt: MessageEvent): void {
// check if qws message
let message = <string>evt.data;
if (message.indexOf(websocketMessagePrefix) !== -1) {
let event = this.getWebsocketCustomEvent(message);
if (event !== '') {
// it's a custom message
this.fireMessage(event, this.getCustomMessage(event, message));
return;
}
}
// it's a native websocket message
this.fireNativeMessage(message);
}
}
export interface Protocol {
serviceName: string;
methodName: string;
params?: string[];
}
export default Client;

View File

@ -0,0 +1,41 @@
import Action from '@overflow/commons/redux/Action';
import DomainMember from '@overflow/domain/api/model/DomainMember';
import MemberRegistPayload from '../payload/MemberRegistPayload';
// Action Type
export type REQUEST = '@overflow/domain/member_regist/REQUEST';
export type REQUEST_SUCCESS = '@overflow/domain/member_regist/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/domain/member_regist/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/domain/member_regist/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/domain/member_regist/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/domain/member_regist/REQUEST_FAILURE';
// Action Creater
export type request = (domain: DomainMember) => Action<MemberRegistPayload>;
export type requestSuccess = () => Action<void>;
export type requestFailure = (error: Error) => Action;
export const request: request = (domainMember: DomainMember): Action<MemberRegistPayload> => {
return {
type: REQUEST,
payload: {
domainMember: domainMember,
},
};
};
export const requestSuccess: requestSuccess = (): Action<void> => {
return {
type: REQUEST_SUCCESS,
payload: null,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,41 @@
import Action from '@overflow/commons/redux/Action';
import Domain from '@overflow/domain/api/model/Domain';
import RegistPayload from '../payload/RegistPayload';
// Action Type
export type REQUEST = '@overflow/domain/regist/REQUEST';
export type REQUEST_SUCCESS = '@overflow/domain/regist/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/domain/regist/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/domain/regist/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/domain/regist/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/domain/regist/REQUEST_FAILURE';
// Action Creater
export type request = (domain: Domain) => Action<RegistPayload>;
export type requestSuccess = () => Action<void>;
export type requestFailure = (error: Error) => Action;
export const request: request = (domain: Domain): Action<RegistPayload> => {
return {
type: REQUEST,
payload: {
domain: domain,
},
};
};
export const requestSuccess: requestSuccess = (): Action<void> => {
return {
type: REQUEST_SUCCESS,
payload: null,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,7 @@
import DomainMember from '../../api/model/DomainMember';
interface MemberRegistPayload {
domainMember: DomainMember;
}
export default MemberRegistPayload;

View File

@ -0,0 +1,6 @@
import Domain from '../../api/model/Domain';
interface RegistPayload {
domain: Domain;
}
export default RegistPayload;

View File

@ -0,0 +1,39 @@
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 DomainMember from '../../api/model/DomainMember';
import DomainMemberService from '../../api/service/DomainMemberService';
import * as MemberRegistActions from '../action/member_regist';
import MemberRegistPayload from '../payload/MemberRegistPayload';
function* regist(action: Action<MemberRegistPayload>): SagaIterator {
try {
const dm = action.payload.domainMember;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
yield call(AppContext.getService<DomainMemberService>().regist, dm);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(MemberRegistActions.requestSuccess());
} catch (e) {
yield put(MemberRegistActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchDomainMemberRegist(): SagaIterator {
yield takeLatest(MemberRegistActions.REQUEST, regist);
}

View File

@ -0,0 +1,39 @@
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 Domain from '../../api/model/Domain';
import DomainService from '../../api/service/DomainService';
import * as RegistActions from '../action/regist';
import RegistPayload from '../payload/RegistPayload';
function* regist(action: Action<RegistPayload>): SagaIterator {
try {
const dm = action.payload.domain;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
yield call(AppContext.getService<DomainService>().regist, dm);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(RegistActions.requestSuccess());
} catch (e) {
yield put(RegistActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchDomainRegist(): SagaIterator {
yield takeLatest(RegistActions.REQUEST, regist);
}

View File

@ -1,3 +1,45 @@
/**
* Created by geek on 17. 7. 4.
*/
import Action from '@overflow/commons/redux/Action';
import EmailAuth from '@overflow/email/api/model/EmailAuth';
import ModifyPayload from '../payload/ModifyPayload';
// Action Type
export type REQUEST = '@overflow/email/modify/REQUEST';
export type REQUEST_SUCCESS = '@overflow/email/modify/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/email/modify/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/email/modify/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/email/modify/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/email/modify/REQUEST_FAILURE';
// Action Creater
export type request = (emailAuth:EmailAuth) => Action<ModifyPayload>;
export type requestSuccess = (emailAuth: EmailAuth) => Action<EmailAuth>;
export type requestFailure = (error: Error) => Action;
export const request: request = (emailAuth:EmailAuth): Action<ModifyPayload> => {
return {
type: REQUEST,
payload: {
emailAuth: emailAuth,
},
};
};
export const requestSuccess: requestSuccess = (emailAuth: EmailAuth): Action<EmailAuth> => {
return {
type: REQUEST_SUCCESS,
payload: emailAuth,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,42 @@
/**
* Created by geek on 17. 7. 4.
*/
import Action from '@overflow/commons/redux/Action';
import EmailAuth from '@overflow/email/api/model/EmailAuth';
import ReadPayload from '../payload/ReadPayload';
// Action Type
export type REQUEST = '@overflow/email/read/REQUEST';
export type REQUEST_SUCCESS = '@overflow/email/read/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/email/read/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/email/read/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/email/read/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/email/read/REQUEST_FAILURE';
// Action Creater
export type request = (id: number) => Action<ReadPayload>;
export type requestSuccess = (emailAuth: EmailAuth) => Action<EmailAuth>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<ReadPayload> => {
return {
type: REQUEST,
payload: {
id: id,
},
};
};
export const requestSuccess: requestSuccess = (emailAuth: EmailAuth): Action<EmailAuth> => {
return {
type: REQUEST_SUCCESS,
payload: emailAuth,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,41 @@
/**
* Created by geek on 17. 7. 4.
*/
import Action from '@overflow/commons/redux/Action';
import EmailAuth from '@overflow/email/api/model/EmailAuth';
import ReadByAuthKeyPayload from '../payload/ReadByAuthKeyPayload';
// Action Type
export type REQUEST = '@overflow/email/read_by_auth_key/REQUEST';
export type REQUEST_SUCCESS = '@overflow/email/read_by_auth_key/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/email/read_by_auth_key/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/email/read_by_auth_key/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/email/read_by_auth_key/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/email/read_by_auth_key/REQUEST_FAILURE';
// Action Creater
export type request = (authKey: string) => Action<ReadByAuthKeyPayload>;
export type requestSuccess = (emailAuth: EmailAuth) => Action<EmailAuth>;
export type requestFailure = (error: Error) => Action;
export const request: request = (authKey: string): Action<ReadByAuthKeyPayload> => {
return {
type: REQUEST,
payload: {
authKey: authKey,
},
};
};
export const requestSuccess: requestSuccess = (emailAuth: EmailAuth): Action<EmailAuth> => {
return {
type: REQUEST_SUCCESS,
payload: emailAuth,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,41 @@
/**
* Created by geek on 17. 7. 4.
*/
import Action from '@overflow/commons/redux/Action';
import EmailAuth from '@overflow/email/api/model/EmailAuth';
import ReadByMemberPayload from '../payload/ReadByMemberPayload';
// Action Type
export type REQUEST = '@overflow/email/read_by_member/REQUEST';
export type REQUEST_SUCCESS = '@overflow/email/read_by_member/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/email/read_by_member/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/email/read_by_member/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/email/read_by_member/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/email/read_by_member/REQUEST_FAILURE';
// Action Creater
export type request = (memberId: number) => Action<ReadByMemberPayload>;
export type requestSuccess = (emailAuths: EmailAuth[]) => Action<EmailAuth[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (memberId: number): Action<ReadByMemberPayload> => {
return {
type: REQUEST,
payload: {
memberId: memberId,
},
};
};
export const requestSuccess: requestSuccess = (emailAuths: EmailAuth[]): Action<EmailAuth[]> => {
return {
type: REQUEST_SUCCESS,
payload: emailAuths,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,43 @@
import Action from '@overflow/commons/redux/Action';
import EmailAuth from '@overflow/email/api/model/EmailAuth';
import SendEmailPayload from '../payload/SendEmailByMemberPayload';
// Action Type
export type REQUEST = '@overflow/email/send_email_by_member/REQUEST';
export type REQUEST_SUCCESS = '@overflow/email/send_email_by_member/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/email/send_email_by_member/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/email/send_email_by_member/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/email/send_email_by_member/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/email/send_email_by_member/REQUEST_FAILURE';
// Action Creater
export type request = (memberId: number, email: string) => Action<SendEmailPayload>;
export type requestSuccess = (emailAuth: EmailAuth) => Action<EmailAuth>;
export type requestFailure = (error: Error) => Action;
export const request: request = (memberId: number, email: string): Action<SendEmailPayload> => {
return {
type: REQUEST,
payload: {
memberId: memberId,
email: email,
},
};
};
export const requestSuccess: requestSuccess = (emailAuth: EmailAuth): Action<EmailAuth> => {
return {
type: REQUEST_SUCCESS,
payload: emailAuth,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,7 @@
/**
* Created by geek on 17. 7. 4.
*/
import EmailAuth from '../../api/model/EmailAuth';
interface ModifyPayload {
emailAuth: EmailAuth;
}
export default ModifyPayload;

View File

@ -1,3 +1,5 @@
/**
* Created by geek on 17. 7. 4.
*/
interface ReadByAuthKeyPayload {
authKey: string;
}
export default ReadByAuthKeyPayload;

View File

@ -1,3 +1,5 @@
/**
* Created by geek on 17. 7. 4.
*/
interface ReadByMemberPayload {
memberId: number;
}
export default ReadByMemberPayload;

View File

@ -1,3 +1,9 @@
/**
* Created by geek on 17. 7. 4.
*/
interface ReadPayload {
id: number;
}
export default ReadPayload;

View File

@ -0,0 +1,6 @@
interface SendEmailByMemberPayload {
memberId: number;
email: string;
}
export default SendEmailByMemberPayload;

View File

@ -1,3 +1,44 @@
/**
* Created by geek on 17. 7. 4.
*/
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 EmailAuth from '@overflow/email/api/model/EmailAuth';
import EmailAuthService from '@overflow/email/api/service/EmailAuthService';
import * as ModifyAction from '../action/modify';
import ModifyPayload from '../payload/ModifyPayload';
function* modify(action: Action<ModifyPayload>): SagaIterator {
try {
const ea = action.payload.emailAuth;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const emailAuth = yield call(AppContext.getService<EmailAuthService>().modify, ea);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(ModifyAction.requestSuccess(emailAuth));
} catch (e) {
yield put(ModifyAction.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchEmailModify(): SagaIterator {
yield takeLatest(ModifyAction.REQUEST, modify);
}

View File

@ -1,3 +1,40 @@
/**
* Created by geek on 17. 7. 4.
*/
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 EmailAuth from '@overflow/email/api/model/EmailAuth';
import EmailAuthService from '@overflow/email/api/service/EmailAuthService';
import * as ReadAction from '../action/read';
import ReadPayload from '../payload/ReadPayload';
function* read(action: Action<ReadPayload>): SagaIterator {
try {
const id = action.payload.id;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const emailAuth = yield call(AppContext.getService<EmailAuthService>().read, id);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(ReadAction.requestSuccess(emailAuth));
} catch (e) {
yield put(ReadAction.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchEmailRead(): SagaIterator {
yield takeLatest(ReadAction.REQUEST, read);
}

View File

@ -1,3 +1,40 @@
/**
* Created by geek on 17. 7. 4.
*/
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 EmailAuth from '@overflow/email/api/model/EmailAuth';
import EmailAuthService from '@overflow/email/api/service/EmailAuthService';
import * as ReadByAuthKeyAction from '../action/read_by_auth_key';
import ReadByAuthKeyPayload from '../payload/ReadByAuthKeyPayload';
function* readByAuthKey(action: Action<ReadByAuthKeyPayload>): SagaIterator {
try {
const authKey = action.payload.authKey;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const emailAuth = yield call(AppContext.getService<EmailAuthService>().readByAuthKey, authKey);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(ReadByAuthKeyAction.requestSuccess(emailAuth));
} catch (e) {
yield put(ReadByAuthKeyAction.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchReadByAuthKey(): SagaIterator {
yield takeLatest(ReadByAuthKeyAction.REQUEST, readByAuthKey);
}

View File

@ -1,3 +1,40 @@
/**
* Created by geek on 17. 7. 4.
*/
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 EmailAuth from '@overflow/email/api/model/EmailAuth';
import EmailAuthService from '@overflow/email/api/service/EmailAuthService';
import * as ReadByMemberAction from '../action/read_by_member';
import ReadByMemberPayload from '../payload/ReadByMemberPayload';
function* readByMember(action: Action<ReadByMemberPayload>): SagaIterator {
try {
const id = action.payload.memberId;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const emailAuths = yield call(AppContext.getService<EmailAuthService>().readByMember, id);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(ReadByMemberAction.requestSuccess(emailAuths));
} catch (e) {
yield put(ReadByMemberAction.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchReadByMember(): SagaIterator {
yield takeLatest(ReadByMemberAction.REQUEST, readByMember);
}

View File

@ -0,0 +1,40 @@
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 EmailAuth from '@overflow/email/api/model/EmailAuth';
import EmailAuthService from '@overflow/email/api/service/EmailAuthService';
import * as SendEmailAction from '../action/send_email_by_member';
import SendEmailPayload from '../payload/SendEmailByMemberPayload';
function* sendEmail(action: Action<SendEmailPayload>): SagaIterator {
try {
const {memberId, email} = action.payload;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const emailAuth = yield call(AppContext.getService<EmailAuthService>().sendEmailByMember, memberId, email);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(SendEmailAction.requestSuccess(emailAuth));
} catch (e) {
yield put(SendEmailAction.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchSendEmail(): SagaIterator {
yield takeLatest(SendEmailAction.REQUEST, sendEmail);
}

View File

View File

@ -36,6 +36,9 @@ export class MemberService extends Service {
return null;
}
public modify(member: Member): Member {
return null;
}
}
export default MemberService;

View File

@ -1,3 +1,41 @@
/**
* Created by geek on 17. 7. 3.
*/
import Action from '@overflow/commons/redux/Action';
import Member from '@overflow/member/api/model/Member';
import ModifyPayload from '../payload/ModifyPayload';
// Action Type
export type REQUEST = '@overflow/member/modify/REQUEST';
export type REQUEST_SUCCESS = '@overflow/member/modify/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/member/modify/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/member/modify/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/modify/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/modify/REQUEST_FAILURE';
// Action Creater
export type request = (member: Member) => Action<ModifyPayload>;
export type requestSuccess = (member: Member) => Action<Member>;
export type requestFailure = (error: Error) => Action;
export const request: request = (member: Member): Action<ModifyPayload> => {
return {
type: REQUEST,
payload: {
member: member,
},
};
};
export const requestSuccess: requestSuccess = (member: Member): Action<Member> => {
return {
type: REQUEST_SUCCESS,
payload: member,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,41 @@
/**
* Created by geek on 17. 7. 3.
*/
import Action from '@overflow/commons/redux/Action';
import Member from '@overflow/member/api/model/Member';
import ReadPayload from '../payload/ReadPayload';
// Action Type
export type REQUEST = '@overflow/member/read/REQUEST';
export type REQUEST_SUCCESS = '@overflow/member/read/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/member/read/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/member/read/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/read/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/read/REQUEST_FAILURE';
// Action Creater
export type request = (id: number) => Action<ReadPayload>;
export type requestSuccess = (member: Member) => Action<Member>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<ReadPayload> => {
return {
type: REQUEST,
payload: {
id: id,
},
};
};
export const requestSuccess: requestSuccess = (member: Member): Action<Member> => {
return {
type: REQUEST_SUCCESS,
payload: member,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,6 @@
/**
* Created by geek on 17. 7. 3.
*/
import Member from '../../api/model/Member';
interface ModifyPayload {
member: Member;
}
export default ModifyPayload;

View File

@ -1,3 +1,5 @@
/**
* Created by geek on 17. 7. 3.
*/
interface ReadPayload {
id: number;
}
export default ReadPayload;

View File

@ -1,3 +1,39 @@
/**
* 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 Member from '../../api/model/Member';
import MemberService from '../../api/service/MemberService';
import * as ModifyActions from '../action/modify';
import ModifyPayload from '../payload/ModifyPayload';
function* modify(action: Action<ModifyPayload>): SagaIterator {
try {
const tempMember = action.payload.member;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const member = yield call(AppContext.getService<MemberService>().modify, tempMember);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(ModifyActions.requestSuccess(member));
} catch (e) {
yield put(ModifyActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchMemberModify(): SagaIterator {
yield takeLatest(ModifyActions.REQUEST, modify);
}

View File

@ -1,3 +1,39 @@
/**
* 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 Member from '../../api/model/Member';
import MemberService from '../../api/service/MemberService';
import * as ReadActions from '../action/read';
import ReadPayload from '../payload/ReadPayload';
function* read(action: Action<ReadPayload>): SagaIterator {
try {
const id = action.payload.id;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const member = yield call(AppContext.getService<MemberService>().read, id);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(ReadActions.requestSuccess(member));
} catch (e) {
yield put(ReadActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchMemberRead(): SagaIterator {
yield takeLatest(ReadActions.REQUEST, read);
}