diff --git a/.gitignore b/.gitignore index 81da553..9e345a3 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,4 @@ testem.log Thumbs.db yarn.lock -package-lock.json \ No newline at end of file +package-lock.json diff --git a/src/packages/noauth/noauth-probe-logger.module.ts b/src/packages/noauth/noauth-probe-logger.module.ts new file mode 100644 index 0000000..3e8f92e --- /dev/null +++ b/src/packages/noauth/noauth-probe-logger.module.ts @@ -0,0 +1,10 @@ +import { NgModule } from '@angular/core'; +import { LoggerModule } from '@loafer/ng-logger'; + + +@NgModule({ + imports: [ + LoggerModule.forFeature({}), + ], +}) +export class NoAuthProbeLoggerModule { } diff --git a/src/packages/noauth/noauth-probe-rpc.module.ts b/src/packages/noauth/noauth-probe-rpc.module.ts new file mode 100644 index 0000000..39e2760 --- /dev/null +++ b/src/packages/noauth/noauth-probe-rpc.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { RPCModule } from '@loafer/ng-rpc'; + +import { + SUBSCRIBERS, +} from './subscriber'; + +@NgModule({ + imports: [ + RPCModule.forFeature({subscribers: SUBSCRIBERS}), + ], +}) +export class NoAuthProbeRPCModule { } diff --git a/src/packages/noauth/noauth.module.ts b/src/packages/noauth/noauth.module.ts index e830483..288ad9f 100644 --- a/src/packages/noauth/noauth.module.ts +++ b/src/packages/noauth/noauth.module.ts @@ -1,6 +1,8 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { NoAuthProbeStoreModule } from './noauth-probe-store.module'; +import { NoAuthProbeRPCModule } from './noauth-probe-rpc.module'; +import { NoAuthProbeLoggerModule } from './noauth-probe-logger.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module'; @@ -9,7 +11,9 @@ import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module'; imports: [ CommonModule, NoAuthProbeStoreModule, - PrimeNGModules + NoAuthProbeRPCModule, + NoAuthProbeLoggerModule, + PrimeNGModules, ], declarations: [ COMPONENTS, diff --git a/src/packages/noauth/store/noauth-probe/noauth-probe.action.ts b/src/packages/noauth/store/noauth-probe/noauth-probe.action.ts index 6ea6794..3b92fb6 100644 --- a/src/packages/noauth/store/noauth-probe/noauth-probe.action.ts +++ b/src/packages/noauth/store/noauth-probe/noauth-probe.action.ts @@ -18,6 +18,9 @@ export enum ActionType { Deny = '[noauth-proboe.noauth-proboe] Deny', DenySuccess = '[noauth-proboe.noauth-proboe] DenySuccess', DenyFailure = '[noauth-proboe.noauth-proboe] DenyFailure', + + OnConnect = '[noauth-proboe.noauth-proboe] OnConnect', + OnDisconnect = '[noauth-proboe.noauth-proboe] OnDisconnect', } export class ReadAllByDomain implements Action { @@ -74,6 +77,18 @@ export class DenyFailure implements Action { constructor(public payload: RPCClientError) {} } +export class OnConnect implements Action { + readonly type = ActionType.OnConnect; + + constructor(public payload: NoAuthProbe) {} +} + +export class OnDisconnect implements Action { + readonly type = ActionType.OnDisconnect; + + constructor(public payload: NoAuthProbe) {} +} + export type Actions = | ReadAllByDomain @@ -85,4 +100,6 @@ export type Actions = | Deny | DenySuccess | DenyFailure + | OnConnect + | OnDisconnect ; diff --git a/src/packages/noauth/store/noauth-probe/noauth-probe.reducer.ts b/src/packages/noauth/store/noauth-probe/noauth-probe.reducer.ts index 3cfca53..c3382e0 100644 --- a/src/packages/noauth/store/noauth-probe/noauth-probe.reducer.ts +++ b/src/packages/noauth/store/noauth-probe/noauth-probe.reducer.ts @@ -96,7 +96,17 @@ export function reducer(state = initialState, action: Actions): State { pending: false, }; } + case ActionType.OnConnect: { + return { + ...state, + }; + } + case ActionType.OnDisconnect: { + return { + ...state, + }; + } default: { return state; } diff --git a/src/packages/noauth/subscriber/index.ts b/src/packages/noauth/subscriber/index.ts new file mode 100644 index 0000000..d163519 --- /dev/null +++ b/src/packages/noauth/subscriber/index.ts @@ -0,0 +1,5 @@ +import { NoAuthProbeSubscriber } from './noauth-probe.subscriber'; + +export const SUBSCRIBERS = [ + NoAuthProbeSubscriber, +]; diff --git a/src/packages/noauth/subscriber/noauth-probe.subscriber.ts b/src/packages/noauth/subscriber/noauth-probe.subscriber.ts new file mode 100644 index 0000000..08d02e7 --- /dev/null +++ b/src/packages/noauth/subscriber/noauth-probe.subscriber.ts @@ -0,0 +1,35 @@ +import { Injectable } from '@angular/core'; +import { Store, select } from '@ngrx/store'; + +import { RPCSubscriber } from '@loafer/ng-rpc/decorator'; +import { LoggerService } from '@loafer/ng-logger/service'; + +import * as NoAuthProbeStore from '../store/noauth-probe'; + +import { + NoAuthProbe, +} from '@overflow/commons-typescript/model/noauth'; + +@Injectable() +export class NoAuthProbeSubscriber { + + public constructor( + private store: Store, + private loggerService: LoggerService, + ) { + } + + @RPCSubscriber({method: 'NoAuthProbeService.onConnect'}) + public onConnect(noAuthProbe: NoAuthProbe): void { + this.loggerService.debug('NoAuthProbeService.onConnect noAuthProbe:', noAuthProbe); + + this.store.dispatch(new NoAuthProbeStore.OnConnect(noAuthProbe)); + } + + @RPCSubscriber({method: 'NoAuthProbeService.onDisconnect'}) + public onDisconnect(noAuthProbe: NoAuthProbe): void { + this.loggerService.debug('NoAuthProbeService.onDisconnect noAuthProbe:', noAuthProbe); + + this.store.dispatch(new NoAuthProbeStore.OnDisconnect(noAuthProbe)); + } +}