From 4974336077f572236d11ec153729aad527ea68b0 Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 28 Sep 2017 16:26:51 +0900 Subject: [PATCH] noauth probe refresh --- src/ts/@overflow/app/config/index.ts | 4 ++- .../@overflow/commons/api/service/Service.ts | 2 +- .../api/service/NoAuthProbeService.ts | 12 +++++-- .../redux/action/new_noauth_probe.ts | 7 ++++ .../redux/reducer/new_noauth_probe.ts | 35 +++++++++++++++++++ .../noauthprobe/redux/state/NewNoAuthProbe.ts | 13 +++++++ 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 src/ts/@overflow/noauthprobe/redux/action/new_noauth_probe.ts create mode 100644 src/ts/@overflow/noauthprobe/redux/reducer/new_noauth_probe.ts create mode 100644 src/ts/@overflow/noauthprobe/redux/state/NewNoAuthProbe.ts diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index a65d4d2..82ba000 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -14,6 +14,7 @@ import hostReadByProbeReducer from '@overflow/probe/redux/reducer/host_read_by_p import modifyProbeReducer from '@overflow/probe/redux/reducer/modify'; import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain'; +import noauthNewReducer from '@overflow/noauthprobe/redux/reducer/new_noauth_probe'; import noauthAcceptReducer from '@overflow/noauthprobe/redux/reducer/accept'; import noauthDenyReducer from '@overflow/noauthprobe/redux/reducer/deny'; @@ -76,7 +77,7 @@ export interface RPCConfig { url: string; } const rpcConfig: RPCConfig = { - url: 'ws://192.168.1.101:19090/web', + url: 'ws://192.168.1.50:19090/web', }; // REST Server Configuration @@ -126,6 +127,7 @@ const reduxConfig: ReduxConfig = { readOSReducer, readServiceReducer, hostReadByProbeReducer, + noauthNewReducer, noauthAcceptReducer, noauthDenyReducer, modifyProbeReducer, diff --git a/src/ts/@overflow/commons/api/service/Service.ts b/src/ts/@overflow/commons/api/service/Service.ts index a01dad7..d2ae891 100644 --- a/src/ts/@overflow/commons/api/service/Service.ts +++ b/src/ts/@overflow/commons/api/service/Service.ts @@ -5,7 +5,7 @@ import { import Action from '@overflow/commons/redux/Action'; export abstract class Service { - private store: Store; + protected store: Store; public setStore(store: Store): void { this.store = store; diff --git a/src/ts/@overflow/noauthprobe/api/service/NoAuthProbeService.ts b/src/ts/@overflow/noauthprobe/api/service/NoAuthProbeService.ts index bea962a..a40ef00 100644 --- a/src/ts/@overflow/noauthprobe/api/service/NoAuthProbeService.ts +++ b/src/ts/@overflow/noauthprobe/api/service/NoAuthProbeService.ts @@ -1,7 +1,10 @@ import { Service } from '@overflow/commons/api/service'; import NoAuthProbe from '../model/NoAuthProbe'; import Action from '@overflow/commons/redux/Action'; -import * as AcceptActions from '../../redux/action/accept'; +import * as NewActions from '../../redux/action/new_noauth_probe'; + +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; +import * as noauthListActions from '../../redux/action/read_all_by_domain'; export class NoAuthProbeService extends Service { public constructor() { @@ -10,7 +13,12 @@ export class NoAuthProbeService extends Service { public regist(params: any): void { const noAuthProbe: NoAuthProbe = JSON.parse(params); - this.dispatch(AcceptActions.REQUEST, noAuthProbe); + if(noAuthProbe.domain === undefined || noAuthProbe.domain === null) { + return; + } + // this.dispatch(NewActions.REQUEST_SUCCESS, noAuthProbe); + this.store.dispatch(asyncRequestActions.request('NoAuthProbeService', 'readAllByDomain', + noauthListActions.REQUEST, JSON.stringify(noAuthProbe.domain))); } } diff --git a/src/ts/@overflow/noauthprobe/redux/action/new_noauth_probe.ts b/src/ts/@overflow/noauthprobe/redux/action/new_noauth_probe.ts new file mode 100644 index 0000000..942aa10 --- /dev/null +++ b/src/ts/@overflow/noauthprobe/redux/action/new_noauth_probe.ts @@ -0,0 +1,7 @@ +export type REQUEST = '@overflow/noAuthProbe/new/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/noAuthProbe/new/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/noAuthProbe/new/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/noAuthProbe/new/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noAuthProbe/new/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noAuthProbe/new/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/noauthprobe/redux/reducer/new_noauth_probe.ts b/src/ts/@overflow/noauthprobe/redux/reducer/new_noauth_probe.ts new file mode 100644 index 0000000..92ff162 --- /dev/null +++ b/src/ts/@overflow/noauthprobe/redux/reducer/new_noauth_probe.ts @@ -0,0 +1,35 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import NoAuthProbe from '@overflow/noauthprobe/api/model/NoAuthProbe'; + +import * as NewActionTypes from '../action/new_noauth_probe'; +import NewState, { defaultState as newDefaultState } from '../state/NewNoAuthProbe'; + +import * as _ from 'lodash'; + +const reducer: ReducersMapObject = { + [NewActionTypes.REQUEST_SUCCESS]: + (state: NewState = newDefaultState, action: Action): + NewState => { + + let nlist: Array; + if (state.noauthList === undefined) { + nlist = null; + } else { + nlist = _.clone(state.noauthList); + nlist.push(action.payload); + } + + return { + ...state, + noauthList: nlist, + }; + }, + [NewActionTypes.REQUEST_FAILURE]: + (state: NewState = newDefaultState, action: Action): + NewState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/noauthprobe/redux/state/NewNoAuthProbe.ts b/src/ts/@overflow/noauthprobe/redux/state/NewNoAuthProbe.ts new file mode 100644 index 0000000..288a6ed --- /dev/null +++ b/src/ts/@overflow/noauthprobe/redux/state/NewNoAuthProbe.ts @@ -0,0 +1,13 @@ +import NoAuthProbe from '../../api/model/NoAuthProbe'; + +export interface State { + readonly noauthList?: NoAuthProbe[]; + readonly error?: Error; +} + +export const defaultState: State = { + noauthList: undefined, + error: undefined, +}; + +export default State;