From a0dcd38dcf71b44c42bcf6ccffd36c6d03b33b9d Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 10 Aug 2017 15:49:06 +0900 Subject: [PATCH] ing --- src/ts/@overflow/app/config/index.ts | 5 +++ .../commons/websocket/WebSocketRPC.ts | 1 + .../member/react/components/SignIn.tsx | 4 +- .../noauthprobe/react/NoauthProbeList.tsx | 5 --- .../react/components/NoauthProbeList.tsx | 1 - src/ts/@overflow/probe/react/ProbeDetail.tsx | 12 +++-- src/ts/@overflow/probe/react/ProbeList.tsx | 4 +- .../react/components/ProbeDetailInfo.tsx | 5 ++- .../probe/react/components/ProbeList.tsx | 18 ++++---- src/ts/@overflow/probe/redux/action/read.ts | 7 +++ .../probe/redux/action/read_all_by_domain.ts | 44 ++----------------- .../probe/redux/payload/ReadPayload.ts | 6 +++ src/ts/@overflow/probe/redux/reducer/read.ts | 21 +++++++++ src/ts/@overflow/probe/redux/state/Read.ts | 9 ++++ .../probe/redux/state/ReadAllByDomain.ts | 2 + 15 files changed, 78 insertions(+), 66 deletions(-) create mode 100644 src/ts/@overflow/probe/redux/action/read.ts create mode 100644 src/ts/@overflow/probe/redux/payload/ReadPayload.ts create mode 100644 src/ts/@overflow/probe/redux/reducer/read.ts create mode 100644 src/ts/@overflow/probe/redux/state/Read.ts diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index f73c67b..684443e 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -2,6 +2,9 @@ import { ReducersMapObject } from 'redux'; import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; import signInReducer from '@overflow/member/redux/reducer/signIn'; +import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain'; +import readProbeReducer from '@overflow/probe/redux/reducer/read'; + import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest'; // Container Configuration @@ -37,6 +40,8 @@ const reduxConfig: ReduxConfig = { state: reduxState, reducerMaps: [ signInReducer, + readAllProbeReducer, + readProbeReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts index 7600792..941598d 100644 --- a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts +++ b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts @@ -112,6 +112,7 @@ export default class WebSocketRPC { let promise = this.requestQueue.get(requestID); this.requestQueue.delete(requestID); if (null != result) { + console.log(result); promise.resolve(result); } else if (null != error) { promise.reject(error); diff --git a/src/ts/@overflow/member/react/components/SignIn.tsx b/src/ts/@overflow/member/react/components/SignIn.tsx index 3ce6296..e090a27 100644 --- a/src/ts/@overflow/member/react/components/SignIn.tsx +++ b/src/ts/@overflow/member/react/components/SignIn.tsx @@ -41,10 +41,8 @@ export class SignIn extends React.Component { forgotPopup: false, sendComPopup: false, email: 'overflow@loafle.com', - pass: 'qwer5795', + pass: '!@#$qwer1234', }; - - } public render(): JSX.Element { diff --git a/src/ts/@overflow/noauthprobe/react/NoauthProbeList.tsx b/src/ts/@overflow/noauthprobe/react/NoauthProbeList.tsx index 2c9b76e..46ca802 100644 --- a/src/ts/@overflow/noauthprobe/react/NoauthProbeList.tsx +++ b/src/ts/@overflow/noauthprobe/react/NoauthProbeList.tsx @@ -6,8 +6,6 @@ import { } from './components/NoauthProbeList'; import Domain from '@overflow/domain/api/model/Domain'; -import * as probeListActions from '../redux/action/read_all_by_domain'; - export function mapStateToProps(state: any): ProbeListStateProps { return { @@ -17,9 +15,6 @@ export function mapStateToProps(state: any): ProbeListStateProps { export function mapDispatchToProps(dispatch: Dispatch): ProbeListDispatchProps { return { - onReadAllByDomain: (domain: Domain) => { - dispatch(probeListActions.request(domain)); - }, }; } diff --git a/src/ts/@overflow/noauthprobe/react/components/NoauthProbeList.tsx b/src/ts/@overflow/noauthprobe/react/components/NoauthProbeList.tsx index c3ed92e..b8c93c9 100644 --- a/src/ts/@overflow/noauthprobe/react/components/NoauthProbeList.tsx +++ b/src/ts/@overflow/noauthprobe/react/components/NoauthProbeList.tsx @@ -14,7 +14,6 @@ export interface StateProps { } export interface DispatchProps { - onReadAllByDomain(domain: Domain): void; } export type Props = StateProps & DispatchProps; diff --git a/src/ts/@overflow/probe/react/ProbeDetail.tsx b/src/ts/@overflow/probe/react/ProbeDetail.tsx index 04f0f47..80f00e5 100644 --- a/src/ts/@overflow/probe/react/ProbeDetail.tsx +++ b/src/ts/@overflow/probe/react/ProbeDetail.tsx @@ -6,7 +6,8 @@ import { } from './components/ProbeDetailInfo'; import { push as routerPush } from 'react-router-redux'; import Probe from '@overflow/probe/api/model/Probe'; - +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; +import * as probeReadActions from '../redux/action/read'; export function mapStateToProps(state: any, props: any): ProbeDetailStateProps { return { @@ -16,9 +17,12 @@ export function mapStateToProps(state: any, props: any): ProbeDetailStateProps { export function mapDispatchToProps(dispatch: Dispatch): ProbeDetailDispatchProps { return { - onDiscoveryClick: ( id: string) => { - dispatch(routerPush( id + '/ targets' )); - }, + onRead: (id: string) => { + dispatch(asyncRequestActions.request('ProbeService', 'read', probeReadActions.REQUEST, id)); + }, + onDiscoveryClick: (id: string) => { + dispatch(routerPush(id + '/ targets')); + }, }; } diff --git a/src/ts/@overflow/probe/react/ProbeList.tsx b/src/ts/@overflow/probe/react/ProbeList.tsx index cbba40b..43456c8 100644 --- a/src/ts/@overflow/probe/react/ProbeList.tsx +++ b/src/ts/@overflow/probe/react/ProbeList.tsx @@ -8,17 +8,17 @@ import { import Domain from '@overflow/domain/api/model/Domain'; import * as probeListActions from '../redux/action/read_all_by_domain'; import { push as routerPush } from 'react-router-redux'; +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; export function mapStateToProps(state: any): ProbeListStateProps { return { - }; } export function mapDispatchToProps(dispatch: Dispatch): ProbeListDispatchProps { return { onReadAllByDomain: (domain: Domain) => { - dispatch(probeListActions.request(domain)); + dispatch(asyncRequestActions.request('ProbeService', 'readAllByDomain', probeListActions.REQUEST, JSON.stringify(domain))); }, onProbeSelection: (id: string) => { dispatch(routerPush('/probe/' + id)); diff --git a/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx b/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx index c0d8dc3..08695eb 100644 --- a/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx +++ b/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx @@ -15,7 +15,8 @@ export interface StateProps { } export interface DispatchProps { - onDiscoveryClick(id:string):void; + onRead?(id: string): void; + onDiscoveryClick?(id:string):void; } export type Props = StateProps & DispatchProps; @@ -37,7 +38,7 @@ export class ProbeDetailInfo extends React.Component { } public componentWillMount(): void { - + this.props.onRead(this.props.id); // todo. getting probe by probeId let p = { 'id': '11', diff --git a/src/ts/@overflow/probe/react/components/ProbeList.tsx b/src/ts/@overflow/probe/react/components/ProbeList.tsx index d67d890..16f6073 100644 --- a/src/ts/@overflow/probe/react/components/ProbeList.tsx +++ b/src/ts/@overflow/probe/react/components/ProbeList.tsx @@ -8,8 +8,8 @@ export interface StateProps { } export interface DispatchProps { - onReadAllByDomain(domain: Domain): void; - onProbeSelection(id: string): void; + onReadAllByDomain?(domain: Domain): void; + onProbeSelection?(id: string): void; } export type Props = StateProps & DispatchProps; @@ -33,13 +33,13 @@ export class ProbeList extends React.Component { } public componentWillMount(): void { - // let domain: Domain = { - // id: 1, - // }; - // this.props.onReadAllByDomain(domain); + let domain: Domain = { + id: 1, + }; + this.props.onReadAllByDomain(domain); this.data = [ { - 'id': 11, + 'id': 1, 'status': { 'name': 'NORMAL', }, @@ -58,7 +58,7 @@ export class ProbeList extends React.Component { 'description': 'description1111111111', }, { - 'id': 22, + 'id': 1, 'status': { 'name': 'INITIAL', }, @@ -73,7 +73,7 @@ export class ProbeList extends React.Component { 'description': 'description1111111111', }, { - 'id': 33, + 'id': 1, 'status': { 'name': 'NORMAL', }, diff --git a/src/ts/@overflow/probe/redux/action/read.ts b/src/ts/@overflow/probe/redux/action/read.ts new file mode 100644 index 0000000..757a0b7 --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/read.ts @@ -0,0 +1,7 @@ +export type REQUEST = '@overflow/probe/read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/probe/read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/probe/read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/probe/read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/read/REQUEST/FAILURE'; 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 index c5e9ece..1cddf38 100644 --- a/src/ts/@overflow/probe/redux/action/read_all_by_domain.ts +++ b/src/ts/@overflow/probe/redux/action/read_all_by_domain.ts @@ -1,43 +1,7 @@ -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 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, - }; -}; +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'; diff --git a/src/ts/@overflow/probe/redux/payload/ReadPayload.ts b/src/ts/@overflow/probe/redux/payload/ReadPayload.ts new file mode 100644 index 0000000..d9c5fdc --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/ReadPayload.ts @@ -0,0 +1,6 @@ + +interface ReadPayload { + id: string; +} + +export default ReadPayload; diff --git a/src/ts/@overflow/probe/redux/reducer/read.ts b/src/ts/@overflow/probe/redux/reducer/read.ts new file mode 100644 index 0000000..d1b1acd --- /dev/null +++ b/src/ts/@overflow/probe/redux/reducer/read.ts @@ -0,0 +1,21 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import Probe from '@overflow/probe/api/model/Probe'; + +import * as ReadActionTypes from '../action/read'; +import ReadState, { defaultState as readDefaultState } from '../state/Read'; + +const reducer: ReducersMapObject = { + [ReadActionTypes.REQUEST_SUCCESS]: + (state: ReadState = readDefaultState, action: Action): + ReadState => { + return state; + }, + [ReadActionTypes.REQUEST_FAILURE]: + (state: ReadState = readDefaultState, action: Action): + ReadState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/probe/redux/state/Read.ts b/src/ts/@overflow/probe/redux/state/Read.ts new file mode 100644 index 0000000..fc4378e --- /dev/null +++ b/src/ts/@overflow/probe/redux/state/Read.ts @@ -0,0 +1,9 @@ +export interface State { + readonly error?: Error; +} + +export const defaultState: State = { + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts b/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts index fc4378e..bf0eeb0 100644 --- a/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts +++ b/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts @@ -1,8 +1,10 @@ export interface State { + readonly temp?: any; readonly error?: Error; } export const defaultState: State = { + temp: null, error: undefined, };