From cf8037063addf89ea694148742e348fba5b35bed Mon Sep 17 00:00:00 2001 From: Byung Jun Park Date: Fri, 28 Jul 2017 02:55:14 +0900 Subject: [PATCH] ing --- src/ts/@overflow/app/config/index.ts | 4 +-- src/ts/@overflow/app/index.tsx | 25 +++++++++---------- .../views/infrastructure/target/Detail.tsx | 2 +- .../app/views/infrastructure/target/List.tsx | 2 +- src/ts/@overflow/app/views/member/SignOut.tsx | 4 +-- .../app/views/monitoring/probe/Detail.tsx | 2 +- .../app/views/monitoring/probe/History.tsx | 2 +- .../app/views/monitoring/probe/Host.tsx | 2 +- .../app/views/monitoring/probe/List.tsx | 2 +- .../app/views/monitoring/probe/NoAuth.tsx | 2 +- .../app/views/monitoring/probe/Setup.tsx | 2 +- .../app/views/monitoring/sensor/Detail.tsx | 4 +-- .../views/monitoring/sensor/DetailInfo.tsx | 4 +-- .../views/monitoring/sensor/DetailItems.tsx | 4 +-- .../app/views/monitoring/sensor/ItemTree.tsx | 4 +-- .../app/views/monitoring/sensor/List.tsx | 4 +-- .../app/views/monitoring/sensor/Setup.tsx | 4 +-- .../context/pouches/decorator/Inject.ts | 17 +++++++++---- .../context/pouches/decorator/Injectable.ts | 9 ++++++- .../context/pouches/factory/PouchFactory.ts | 2 +- .../temp/react/components/Discovery.tsx | 2 +- 21 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 6c3a492..7e46695 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -24,7 +24,7 @@ const rpcConfig: RPCConfig = { export interface ReduxConfig { state: ReduxState; reducerMaps: ReducersMapObject[]; - sagaWarchers: (SagaWatcher[])[]; + sagaWarchers: SagaWatcher[]; } export interface ReduxState { @@ -39,7 +39,7 @@ const reduxConfig: ReduxConfig = { signInReducer, ], sagaWarchers: [ - signInSagaWatchers, + ...signInSagaWatchers, ], }; diff --git a/src/ts/@overflow/app/index.tsx b/src/ts/@overflow/app/index.tsx index 07046b0..354a6bf 100644 --- a/src/ts/@overflow/app/index.tsx +++ b/src/ts/@overflow/app/index.tsx @@ -86,8 +86,8 @@ class Application { this.displayLoading(); this.context = await this.initContext(); - // this.rpcClient = await this.initRpcClient(); - // this.context.PouchFactory.registerPouch(this.rpcClient); + this.rpcClient = await this.initRpcClient(); + this.context.PouchFactory.registerPouch(this.rpcClient); await this.initRedux(); @@ -112,13 +112,14 @@ class Application { private initRpcClient(): Promise { const rpcClient = new Promise((resolve, reject) => { let client = new WebSocketRPC(this.config.rpc.url); - client.initialize() - .then(() => { - resolve(client); - }) - .catch((err: any) => { - reject(err); - }); + // client.initialize() + // .then(() => { + // resolve(client); + // }) + // .catch((err: any) => { + // reject(err); + // }); + resolve(client); }); return rpcClient; @@ -154,11 +155,9 @@ class Application { return init; } - private * initReduxSagaWarchers(sagaWarchers: (SagaWatcher[])[]): SagaIterator { + private * initReduxSagaWarchers(sagaWarchers: SagaWatcher[]): SagaIterator { for (let sagaWarcher of sagaWarchers) { - for (let warcher of sagaWarcher) { - yield fork(warcher); - } + yield fork(sagaWarcher); } } diff --git a/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx b/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx index 6a3d43c..e04b965 100644 --- a/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx +++ b/src/ts/@overflow/app/views/infrastructure/target/Detail.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class TargetDetail extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/infrastructure/target/List.tsx b/src/ts/@overflow/app/views/infrastructure/target/List.tsx index 6c281c4..7dc7f25 100644 --- a/src/ts/@overflow/app/views/infrastructure/target/List.tsx +++ b/src/ts/@overflow/app/views/infrastructure/target/List.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class TargetList extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/member/SignOut.tsx b/src/ts/@overflow/app/views/member/SignOut.tsx index 3f1b2e1..4df50b0 100644 --- a/src/ts/@overflow/app/views/member/SignOut.tsx +++ b/src/ts/@overflow/app/views/member/SignOut.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SignOut extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SignOut extends React.Component, object> { ); } - private test(@inject() c: WebSocketRPC): void { + private test( c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/app/views/monitoring/probe/Detail.tsx b/src/ts/@overflow/app/views/monitoring/probe/Detail.tsx index 2761603..f420ee0 100644 --- a/src/ts/@overflow/app/views/monitoring/probe/Detail.tsx +++ b/src/ts/@overflow/app/views/monitoring/probe/Detail.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class ProbeDetail extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/monitoring/probe/History.tsx b/src/ts/@overflow/app/views/monitoring/probe/History.tsx index e2698ca..8a00282 100644 --- a/src/ts/@overflow/app/views/monitoring/probe/History.tsx +++ b/src/ts/@overflow/app/views/monitoring/probe/History.tsx @@ -5,7 +5,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class ProbeHistory extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/monitoring/probe/Host.tsx b/src/ts/@overflow/app/views/monitoring/probe/Host.tsx index 095dd45..3184f3b 100644 --- a/src/ts/@overflow/app/views/monitoring/probe/Host.tsx +++ b/src/ts/@overflow/app/views/monitoring/probe/Host.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class ProbeHost extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/monitoring/probe/List.tsx b/src/ts/@overflow/app/views/monitoring/probe/List.tsx index 3dcf1d3..c3d8575 100644 --- a/src/ts/@overflow/app/views/monitoring/probe/List.tsx +++ b/src/ts/@overflow/app/views/monitoring/probe/List.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class ProbeList extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/monitoring/probe/NoAuth.tsx b/src/ts/@overflow/app/views/monitoring/probe/NoAuth.tsx index 8356a75..9705ce3 100644 --- a/src/ts/@overflow/app/views/monitoring/probe/NoAuth.tsx +++ b/src/ts/@overflow/app/views/monitoring/probe/NoAuth.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class ProbeList extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/monitoring/probe/Setup.tsx b/src/ts/@overflow/app/views/monitoring/probe/Setup.tsx index e7de7a0..38b4809 100644 --- a/src/ts/@overflow/app/views/monitoring/probe/Setup.tsx +++ b/src/ts/@overflow/app/views/monitoring/probe/Setup.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class ProbeList extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { diff --git a/src/ts/@overflow/app/views/monitoring/sensor/Detail.tsx b/src/ts/@overflow/app/views/monitoring/sensor/Detail.tsx index 1d81918..9a8d719 100644 --- a/src/ts/@overflow/app/views/monitoring/sensor/Detail.tsx +++ b/src/ts/@overflow/app/views/monitoring/sensor/Detail.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SensorDetail extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SensorDetail extends React.Component, object> ); } - private test(@inject() c: WebSocketRPC): void { + private test( c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/app/views/monitoring/sensor/DetailInfo.tsx b/src/ts/@overflow/app/views/monitoring/sensor/DetailInfo.tsx index 6437319..9e096c4 100644 --- a/src/ts/@overflow/app/views/monitoring/sensor/DetailInfo.tsx +++ b/src/ts/@overflow/app/views/monitoring/sensor/DetailInfo.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SensorDetailInfo extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SensorDetailInfo extends React.Component, obje ); } - private test(@inject() c: WebSocketRPC): void { + private test( c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/app/views/monitoring/sensor/DetailItems.tsx b/src/ts/@overflow/app/views/monitoring/sensor/DetailItems.tsx index 0b7907c..ced8d1e 100644 --- a/src/ts/@overflow/app/views/monitoring/sensor/DetailItems.tsx +++ b/src/ts/@overflow/app/views/monitoring/sensor/DetailItems.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SensorDetailItems extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SensorDetailItems extends React.Component, obj ); } - private test(@inject() c: WebSocketRPC): void { + private test( c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/app/views/monitoring/sensor/ItemTree.tsx b/src/ts/@overflow/app/views/monitoring/sensor/ItemTree.tsx index 039a31e..2a26d74 100644 --- a/src/ts/@overflow/app/views/monitoring/sensor/ItemTree.tsx +++ b/src/ts/@overflow/app/views/monitoring/sensor/ItemTree.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SensorItemTree extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SensorItemTree extends React.Component, object ); } - private test(@inject() c: WebSocketRPC): void { + private test( c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/app/views/monitoring/sensor/List.tsx b/src/ts/@overflow/app/views/monitoring/sensor/List.tsx index 2197cf2..278ff35 100644 --- a/src/ts/@overflow/app/views/monitoring/sensor/List.tsx +++ b/src/ts/@overflow/app/views/monitoring/sensor/List.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SensorList extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SensorList extends React.Component, object> { ); } - private test(@inject() c: WebSocketRPC): void { + private test( c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/app/views/monitoring/sensor/Setup.tsx b/src/ts/@overflow/app/views/monitoring/sensor/Setup.tsx index d7b0d67..fc63c31 100644 --- a/src/ts/@overflow/app/views/monitoring/sensor/Setup.tsx +++ b/src/ts/@overflow/app/views/monitoring/sensor/Setup.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class SensorSetup extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) { @@ -21,7 +21,7 @@ class SensorSetup extends React.Component, object> { ); } - private test(@inject() c: WebSocketRPC): void { + private test(c: WebSocketRPC): void { console.log(''); } } diff --git a/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts b/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts index 9eab2e0..4aa0bc2 100644 --- a/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts +++ b/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts @@ -5,16 +5,23 @@ import PouchInjectDefinition from '../config/PouchInjectDefinition'; const Inject = (injectConfig: InjectConfig = {}) => { return (...args: any[]) => { - switch(args.length) { + let params = []; + for (let i = 0; i < args.length; i++) { + if (args[i]) { + params.push(args[i]); + } + } + + switch(params.length) { case 1: - return injectClass.apply(this, args); + return injectClass(injectConfig).apply(this, args); case 2: - return injectProperty.apply(this, args); + return injectProperty(injectConfig).apply(this, args); case 3: if(typeof args[2] === 'number') { - return injectParameter.apply(this, args); + return injectParameter(injectConfig).apply(this, args); } - return injectMethod.apply(this, args); + return injectMethod(injectConfig).apply(this, args); default: throw new Error('@Inject decorators are not valid here!'); } diff --git a/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts b/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts index 1f8c137..19b213b 100644 --- a/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts +++ b/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts @@ -3,7 +3,14 @@ import PouchDefinition from '../config/PouchDefinition'; const Injectable = (...args: any[]) => { - switch(args.length) { + let params = []; + for (let i = 0; i < args.length; i++) { + if (args[i]) { + params.push(args[i]); + } + } + + switch(params.length) { case 1: return injectableClass.apply(this, args); case 2: diff --git a/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts b/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts index 24d38be..aaeda7f 100644 --- a/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts +++ b/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts @@ -48,7 +48,7 @@ class PouchFactory { * registerPouch */ public registerPouch(pouch: any, qualifier: string | symbol = POUCH_DEFAULT_QUALIFIER): void { - let clazz = pouch.prototype; + let clazz = Object.getPrototypeOf(pouch); this._putPouchInstance(clazz, qualifier, pouch); } diff --git a/src/ts/@overflow/temp/react/components/Discovery.tsx b/src/ts/@overflow/temp/react/components/Discovery.tsx index bbda650..57ba13b 100644 --- a/src/ts/@overflow/temp/react/components/Discovery.tsx +++ b/src/ts/@overflow/temp/react/components/Discovery.tsx @@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context'; import inject from '@overflow/commons/context/decorator/inject'; class Discovery extends React.Component, object> { - @inject() + private client: WebSocketRPC; public constructor(props?: RouteComponentProps, context?: object) {