This commit is contained in:
crusader 2018-05-10 19:54:47 +09:00
parent 0d1ddb8b93
commit bcf00db2d7
8 changed files with 96 additions and 2 deletions

2
.gitignore vendored
View File

@ -43,4 +43,4 @@ testem.log
Thumbs.db Thumbs.db
yarn.lock yarn.lock
package-lock.json package-lock.json

View File

@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { LoggerModule } from '@loafer/ng-logger';
@NgModule({
imports: [
LoggerModule.forFeature({}),
],
})
export class NoAuthProbeLoggerModule { }

View File

@ -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 { }

View File

@ -1,6 +1,8 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NoAuthProbeStoreModule } from './noauth-probe-store.module'; 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 { COMPONENTS } from './component';
import { SERVICES } from './service'; import { SERVICES } from './service';
import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module'; import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module';
@ -9,7 +11,9 @@ import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module';
imports: [ imports: [
CommonModule, CommonModule,
NoAuthProbeStoreModule, NoAuthProbeStoreModule,
PrimeNGModules NoAuthProbeRPCModule,
NoAuthProbeLoggerModule,
PrimeNGModules,
], ],
declarations: [ declarations: [
COMPONENTS, COMPONENTS,

View File

@ -18,6 +18,9 @@ export enum ActionType {
Deny = '[noauth-proboe.noauth-proboe] Deny', Deny = '[noauth-proboe.noauth-proboe] Deny',
DenySuccess = '[noauth-proboe.noauth-proboe] DenySuccess', DenySuccess = '[noauth-proboe.noauth-proboe] DenySuccess',
DenyFailure = '[noauth-proboe.noauth-proboe] DenyFailure', DenyFailure = '[noauth-proboe.noauth-proboe] DenyFailure',
OnConnect = '[noauth-proboe.noauth-proboe] OnConnect',
OnDisconnect = '[noauth-proboe.noauth-proboe] OnDisconnect',
} }
export class ReadAllByDomain implements Action { export class ReadAllByDomain implements Action {
@ -74,6 +77,18 @@ export class DenyFailure implements Action {
constructor(public payload: RPCClientError) {} 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 = export type Actions =
| ReadAllByDomain | ReadAllByDomain
@ -85,4 +100,6 @@ export type Actions =
| Deny | Deny
| DenySuccess | DenySuccess
| DenyFailure | DenyFailure
| OnConnect
| OnDisconnect
; ;

View File

@ -96,7 +96,17 @@ export function reducer(state = initialState, action: Actions): State {
pending: false, pending: false,
}; };
} }
case ActionType.OnConnect: {
return {
...state,
};
}
case ActionType.OnDisconnect: {
return {
...state,
};
}
default: { default: {
return state; return state;
} }

View File

@ -0,0 +1,5 @@
import { NoAuthProbeSubscriber } from './noauth-probe.subscriber';
export const SUBSCRIBERS = [
NoAuthProbeSubscriber,
];

View File

@ -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<NoAuthProbeStore.State>,
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));
}
}