From e8ad7b6716e761c62810e743a282d3e802dc2abb Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 31 May 2018 16:38:44 +0900 Subject: [PATCH] ing --- .../noauth-probe-list.component.html | 5 + .../component/noauth-probe-list.component.ts | 34 +++++- @overflow/noauth-probe/container/index.ts | 5 - ...noauth-probe-list-container.component.html | 7 -- ...uth-probe-list-container.component.spec.ts | 25 ----- .../noauth-probe-list-container.component.ts | 56 ---------- @overflow/noauth-probe/noauth-probe.module.ts | 3 - .../noauth-probe/store/connecting/index.ts | 4 + .../noauth-probe-connecting.action.ts | 26 +++++ .../noauth-probe-connecting.effect.spec.ts} | 4 +- .../noauth-probe-connecting.effect.ts | 23 ++++ .../noauth-probe-connecting.reducer.ts | 21 ++++ .../noauth-probe-connecting.state.ts} | 9 +- .../container/noauth-probe-list/index.ts | 2 - .../noauth-probe-list.reducer.ts | 55 ---------- .../store/entity/noauth-probe/index.ts | 2 - .../noauth-probe/noauth-probe.action.ts | 102 ------------------ .../noauth-probe/noauth-probe.effect.ts | 78 -------------- @overflow/noauth-probe/store/index.ts | 14 ++- .../subscriber/noauth-probe.subscriber.ts | 10 +- 20 files changed, 125 insertions(+), 360 deletions(-) delete mode 100644 @overflow/noauth-probe/container/index.ts delete mode 100644 @overflow/noauth-probe/container/noauth-probe-list-container.component.html delete mode 100644 @overflow/noauth-probe/container/noauth-probe-list-container.component.spec.ts delete mode 100644 @overflow/noauth-probe/container/noauth-probe-list-container.component.ts create mode 100644 @overflow/noauth-probe/store/connecting/index.ts create mode 100644 @overflow/noauth-probe/store/connecting/noauth-probe-connecting.action.ts rename @overflow/noauth-probe/store/{entity/noauth-probe/noauth-probe.effect.spec.ts => connecting/noauth-probe-connecting.effect.spec.ts} (70%) create mode 100644 @overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.ts create mode 100644 @overflow/noauth-probe/store/connecting/noauth-probe-connecting.reducer.ts rename @overflow/noauth-probe/store/{container/noauth-probe-list/noauth-probe-list.state.ts => connecting/noauth-probe-connecting.state.ts} (53%) delete mode 100644 @overflow/noauth-probe/store/container/noauth-probe-list/index.ts delete mode 100644 @overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.reducer.ts delete mode 100644 @overflow/noauth-probe/store/entity/noauth-probe/index.ts delete mode 100644 @overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.action.ts delete mode 100644 @overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.ts diff --git a/@overflow/noauth-probe/component/noauth-probe-list.component.html b/@overflow/noauth-probe/component/noauth-probe-list.component.html index b0ec7a3..3428d29 100644 --- a/@overflow/noauth-probe/component/noauth-probe-list.component.html +++ b/@overflow/noauth-probe/component/noauth-probe-list.component.html @@ -46,6 +46,9 @@
HostID: {{rowData.descriptions.host.hostID}}
+
+ Connected: {{rowData.connectDate | date: 'dd/MM/yyyy'}} ({{rowData.connectAddress}}) +
@@ -62,6 +65,8 @@
Mac Address: {{rowData.descriptions.network.macAddress}}
+
+
diff --git a/@overflow/noauth-probe/component/noauth-probe-list.component.ts b/@overflow/noauth-probe/component/noauth-probe-list.component.ts index 3051b95..72e31a6 100644 --- a/@overflow/noauth-probe/component/noauth-probe-list.component.ts +++ b/@overflow/noauth-probe/component/noauth-probe-list.component.ts @@ -1,6 +1,6 @@ -import { Component, Input, Output, EventEmitter, AfterContentInit, OnInit } from '@angular/core'; +import { Component, Input, Output, EventEmitter, AfterContentInit, OnInit, OnDestroy } from '@angular/core'; import { Store, select } from '@ngrx/store'; -import { Observable, of } from 'rxjs'; +import { Observable, of, Subscription } from 'rxjs'; import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; import { ConfirmationService, Message } from 'primeng/primeng'; @@ -9,17 +9,21 @@ import { AuthContainerSelector } from '@overflow/shared/auth/store'; import { DomainMember } from '@overflow/commons-typescript/model/domain'; import { NoAuthProbeService } from '../service/noauth-probe.service'; +import { NoAuthProbeConnectingSelector } from '../store'; @Component({ selector: 'of-noauth-probe-list', templateUrl: './noauth-probe-list.component.html', providers: [ConfirmationService] }) -export class NoAuthProbeListComponent implements OnInit { +export class NoAuthProbeListComponent implements OnInit, OnDestroy { noauthProbes$: Observable; pending$: Observable; error$: Observable; + noauthProbes: NoAuthProbe[]; + connectingSubscription$: Subscription; + constructor( private confirmationService: ConfirmationService, private store: Store, @@ -50,6 +54,24 @@ export class NoAuthProbeListComponent implements OnInit { }), ).take(1).subscribe(); + this.connectingSubscription$ = this.store.pipe( + select(NoAuthProbeConnectingSelector.selectEntities), + tap((entities: { [id: number]: NoAuthProbe }) => { + const noauthProbes = []; + this.noauthProbes.forEach(noauthProbe => { + const t = entities[noauthProbe.id]; + if (undefined !== t) { + noauthProbes.push(t); + } else { + noauthProbes.push(noauthProbe); + } + }); + + this.setNoauthProbes$(noauthProbes); + } + ), + ).subscribe(); + // this.noauthProbes$ = this.store.pipe( // select(AuthContainerSelector.selectDomainMember), // exhaustMap((domainMember: DomainMember) => @@ -77,6 +99,11 @@ export class NoAuthProbeListComponent implements OnInit { } + ngOnDestroy(): void { + this.connectingSubscription$.unsubscribe(); + } + + onAcceptOrDeny(isAccept: boolean, selected: NoAuthProbe) { const title = isAccept ? 'Are you sure to accept this Probe?' : 'Are you sure to deny this Probe'; @@ -136,6 +163,7 @@ export class NoAuthProbeListComponent implements OnInit { noauthProbes.forEach(noauthProbe => { noauthProbe.descriptions = JSON.parse(noauthProbe.description); }); + this.noauthProbes = noauthProbes; this.noauthProbes$ = of(noauthProbes); } diff --git a/@overflow/noauth-probe/container/index.ts b/@overflow/noauth-probe/container/index.ts deleted file mode 100644 index 77e3b4b..0000000 --- a/@overflow/noauth-probe/container/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { NoAuthProbeListContainerComponent } from './noauth-probe-list-container.component'; - -export const CONTAINER_COMPONENTS = [ - NoAuthProbeListContainerComponent, -]; diff --git a/@overflow/noauth-probe/container/noauth-probe-list-container.component.html b/@overflow/noauth-probe/container/noauth-probe-list-container.component.html deleted file mode 100644 index cc6465d..0000000 --- a/@overflow/noauth-probe/container/noauth-probe-list-container.component.html +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/@overflow/noauth-probe/container/noauth-probe-list-container.component.spec.ts b/@overflow/noauth-probe/container/noauth-probe-list-container.component.spec.ts deleted file mode 100644 index d2a3436..0000000 --- a/@overflow/noauth-probe/container/noauth-probe-list-container.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { NoAuthProbeListContainerComponent } from './noauth-probe-list-container.component'; - -describe('NoAuthProbeListContainerComponent', () => { - let component: NoAuthProbeListContainerComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ NoAuthProbeListContainerComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(NoAuthProbeListContainerComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/@overflow/noauth-probe/container/noauth-probe-list-container.component.ts b/@overflow/noauth-probe/container/noauth-probe-list-container.component.ts deleted file mode 100644 index edad21e..0000000 --- a/@overflow/noauth-probe/container/noauth-probe-list-container.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Store, select } from '@ngrx/store'; -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/map'; - -import { AuthContainerSelector } from '@overflow/shared/auth/store'; -import { DomainMember } from '@overflow/commons-typescript/model/domain'; -import * as NoAuthProbeEntityStore from '../store/entity/noauth-probe'; -import { NoAuthProbeListContainerSelector } from '../store'; -import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth'; -import { ConfirmationService } from 'primeng/primeng'; -import { MessageService } from 'primeng/components/common/messageservice'; -import { RPCClientError } from '@loafer/ng-rpc'; - -@Component({ - selector: 'of-noauth-probe-list-container', - templateUrl: './noauth-probe-list-container.component.html', -}) -export class NoAuthProbeListContainerComponent implements OnInit { - noauthProbes$: Observable; - pending$: Observable; - error$: Observable; - - constructor( - private store: Store, - ) { - } - - ngOnInit() { - this.pending$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectPending)); - this.error$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectError)); - this.noauthProbes$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectAll)).map((_noauthProbes: NoAuthProbe[]) => { - if (null === _noauthProbes) { - return null; - } - _noauthProbes.forEach(_noauthProbe => { - _noauthProbe.descriptions = JSON.parse(_noauthProbe.description); - }); - return _noauthProbes; - }); - - this.store.select(AuthContainerSelector.selectDomainMember).subscribe( - (domainMember: DomainMember) => { - this.store.dispatch(new NoAuthProbeEntityStore.ReadAllByDomainID(domainMember.domain.id)); - } - ); - } - - accept(noAuthProbe: NoAuthProbe) { - this.store.dispatch(new NoAuthProbeEntityStore.Accept({aa: noAuthProbe.id} as any)); - } - - deny(noAuthProbe: NoAuthProbe) { - this.store.dispatch(new NoAuthProbeEntityStore.Deny(noAuthProbe.id)); - } -} diff --git a/@overflow/noauth-probe/noauth-probe.module.ts b/@overflow/noauth-probe/noauth-probe.module.ts index 4491d65..de1698e 100644 --- a/@overflow/noauth-probe/noauth-probe.module.ts +++ b/@overflow/noauth-probe/noauth-probe.module.ts @@ -7,7 +7,6 @@ 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 { CONTAINER_COMPONENTS } from './container'; import { SERVICES } from './service'; @@ -21,11 +20,9 @@ import { SERVICES } from './service'; ], declarations: [ COMPONENTS, - CONTAINER_COMPONENTS, ], exports: [ COMPONENTS, - CONTAINER_COMPONENTS, ], providers: [ SERVICES, diff --git a/@overflow/noauth-probe/store/connecting/index.ts b/@overflow/noauth-probe/store/connecting/index.ts new file mode 100644 index 0000000..a1fa35f --- /dev/null +++ b/@overflow/noauth-probe/store/connecting/index.ts @@ -0,0 +1,4 @@ +export * from './noauth-probe-connecting.action'; +export * from './noauth-probe-connecting.effect'; +export * from './noauth-probe-connecting.reducer'; +export * from './noauth-probe-connecting.state'; diff --git a/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.action.ts b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.action.ts new file mode 100644 index 0000000..747eef8 --- /dev/null +++ b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.action.ts @@ -0,0 +1,26 @@ +import { Action } from '@ngrx/store'; + +import { RPCClientError } from '@loafer/ng-rpc'; +import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth'; + +export enum ActionType { + OnConnect = '[noauth-probe.connecting] OnConnect', + OnDisconnect = '[noauth-probe.connecting] OnDisconnect', +} + +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 = + | OnConnect + | OnDisconnect +; diff --git a/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.spec.ts b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.spec.ts similarity index 70% rename from @overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.spec.ts rename to @overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.spec.ts index b02bbdc..f89a907 100644 --- a/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.spec.ts +++ b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.spec.ts @@ -1,8 +1,8 @@ import { TestBed, inject } from '@angular/core/testing'; -import { Effects } from './noauth-probe.effect'; +import { Effects } from './noauth-probe-connecting.effect'; -describe('NoAuth-Probe.Effects', () => { +describe('noauth-probe-connecting.Effects', () => { beforeEach(() => { TestBed.configureTestingModule({ providers: [Effects] diff --git a/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.ts b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.ts new file mode 100644 index 0000000..f48e8d6 --- /dev/null +++ b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.effect.ts @@ -0,0 +1,23 @@ +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + +import { Effect, Actions, ofType } from '@ngrx/effects'; +import { Action } from '@ngrx/store'; + +import { RPCClientError } from '@loafer/ng-rpc'; +import { NoAuthProbeService } from '../../service/noauth-probe.service'; + +import { + ActionType, +} from './noauth-probe-connecting.action'; + +@Injectable() +export class Effects { + + constructor( + private actions$: Actions, + private noAuthProbeService: NoAuthProbeService, + private router: Router + ) { } + +} diff --git a/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.reducer.ts b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.reducer.ts new file mode 100644 index 0000000..567d8c3 --- /dev/null +++ b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.reducer.ts @@ -0,0 +1,21 @@ +import { ActionType, Actions } from './noauth-probe-connecting.action'; +import { + State, + initialState, + noAuthProbeConnectingAdapter, +} from './noauth-probe-connecting.state'; + +export function reducer(state = initialState, action: Actions): State { + switch (action.type) { + case ActionType.OnConnect: { + return noAuthProbeConnectingAdapter.upsertOne(action.payload, state); + } + case ActionType.OnDisconnect: { + return noAuthProbeConnectingAdapter.upsertOne(action.payload, state); + } + + default: { + return state; + } + } +} diff --git a/@overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.state.ts b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.state.ts similarity index 53% rename from @overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.state.ts rename to @overflow/noauth-probe/store/connecting/noauth-probe-connecting.state.ts index 4f06304..8711e5c 100644 --- a/@overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.state.ts +++ b/@overflow/noauth-probe/store/connecting/noauth-probe-connecting.state.ts @@ -4,17 +4,14 @@ import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth'; import { Selector, createSelector } from '@ngrx/store'; import { createEntityAdapter, EntityState } from '@loafer/ng-entity'; -export const noAuthProbeListContainerAdapter = createEntityAdapter(); +export const noAuthProbeConnectingAdapter = createEntityAdapter(); export interface State extends EntityState { - pending: boolean; } -export const initialState: State = noAuthProbeListContainerAdapter.getInitialState({ - pending: false, +export const initialState: State = noAuthProbeConnectingAdapter.getInitialState({ }); export function getSelectors(selector: Selector) { return { - ...noAuthProbeListContainerAdapter.getSelectors(selector), - selectPending: createSelector(selector, (state: State) => state.pending), + ...noAuthProbeConnectingAdapter.getSelectors(selector), }; } diff --git a/@overflow/noauth-probe/store/container/noauth-probe-list/index.ts b/@overflow/noauth-probe/store/container/noauth-probe-list/index.ts deleted file mode 100644 index b185175..0000000 --- a/@overflow/noauth-probe/store/container/noauth-probe-list/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './noauth-probe-list.reducer'; -export * from './noauth-probe-list.state'; diff --git a/@overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.reducer.ts b/@overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.reducer.ts deleted file mode 100644 index 0bfd981..0000000 --- a/@overflow/noauth-probe/store/container/noauth-probe-list/noauth-probe-list.reducer.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { ActionType, Actions } from '../../entity/noauth-probe'; -import { - State, - initialState, - noAuthProbeListContainerAdapter, -} from './noauth-probe-list.state'; - -import { Probe } from '@overflow/commons-typescript/model/probe'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.ReadAllByDomainID: { - return { - ...state, - pending: true, - }; - } - case ActionType.ReadAllByDomainIDSuccess: { - return noAuthProbeListContainerAdapter.setAll(action.payload, {...state, pending: false}); - } - case ActionType.ReadAllByDomainIDFailure: { - return noAuthProbeListContainerAdapter.setError(action.payload, {...state, pending: false}); - } - - case ActionType.Accept: { - return { - ...state, - pending: true, - }; - } - case ActionType.AcceptSuccess: { - return noAuthProbeListContainerAdapter.setAll(action.payload, {...state, pending: false}); - } - case ActionType.AcceptFailure: { - return noAuthProbeListContainerAdapter.setError(action.payload, {...state, pending: false}); - } - - case ActionType.Deny: { - return { - ...state, - pending: true, - }; - } - case ActionType.DenySuccess: { - return noAuthProbeListContainerAdapter.setAll(action.payload, {...state, pending: false}); - } - case ActionType.DenyFailure: { - return noAuthProbeListContainerAdapter.setError(action.payload, {...state, pending: false}); - } - - default: { - return state; - } - } -} diff --git a/@overflow/noauth-probe/store/entity/noauth-probe/index.ts b/@overflow/noauth-probe/store/entity/noauth-probe/index.ts deleted file mode 100644 index 284851e..0000000 --- a/@overflow/noauth-probe/store/entity/noauth-probe/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './noauth-probe.action'; -export * from './noauth-probe.effect'; diff --git a/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.action.ts b/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.action.ts deleted file mode 100644 index db91f2f..0000000 --- a/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.action.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth'; - -export enum ActionType { - ReadAllByDomainID = '[noauth-probe.noauth-probe] ReadAllByDomainID', - ReadAllByDomainIDSuccess = '[noauth-probe.noauth-probe] ReadAllByDomainIDSuccess', - ReadAllByDomainIDFailure = '[noauth-probe.noauth-probe] ReadAllByDomainIDFailure', - - Accept = '[noauth-probe.noauth-probe] Accept', - AcceptSuccess = '[noauth-probe.noauth-probe] AcceptSuccess', - AcceptFailure = '[noauth-probe.noauth-probe] AcceptFailure', - - Deny = '[noauth-probe.noauth-probe] Deny', - DenySuccess = '[noauth-probe.noauth-probe] DenySuccess', - DenyFailure = '[noauth-probe.noauth-probe] DenyFailure', - - OnConnect = '[noauth-probe.noauth-probe] OnConnect', - OnDisconnect = '[noauth-probe.noauth-probe] OnDisconnect', -} - -export class ReadAllByDomainID implements Action { - readonly type = ActionType.ReadAllByDomainID; - - constructor(public payload: number) {} -} - -export class ReadAllByDomainIDSuccess implements Action { - readonly type = ActionType.ReadAllByDomainIDSuccess; - - constructor(public payload: NoAuthProbe[]) {} -} - -export class ReadAllByDomainIDFailure implements Action { - readonly type = ActionType.ReadAllByDomainIDFailure; - - constructor(public payload: RPCClientError) {} -} - -export class Accept implements Action { - readonly type = ActionType.Accept; - - constructor(public payload: number) {} -} - -export class AcceptSuccess implements Action { - readonly type = ActionType.AcceptSuccess; - - constructor(public payload: NoAuthProbe[]) {} -} - -export class AcceptFailure implements Action { - readonly type = ActionType.AcceptFailure; - - constructor(public payload: RPCClientError) {} -} - -export class Deny implements Action { - readonly type = ActionType.Deny; - - constructor(public payload: number) {} -} - -export class DenySuccess implements Action { - readonly type = ActionType.DenySuccess; - - constructor(public payload: NoAuthProbe[]) {} -} - -export class DenyFailure implements Action { - readonly type = ActionType.DenyFailure; - - 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 = - | ReadAllByDomainID - | ReadAllByDomainIDSuccess - | ReadAllByDomainIDFailure - | Accept - | AcceptSuccess - | AcceptFailure - | Deny - | DenySuccess - | DenyFailure - | OnConnect - | OnDisconnect -; diff --git a/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.ts b/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.ts deleted file mode 100644 index 8defbbc..0000000 --- a/@overflow/noauth-probe/store/entity/noauth-probe/noauth-probe.effect.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Router } from '@angular/router'; - -import { Effect, Actions, ofType } from '@ngrx/effects'; -import { Action } from '@ngrx/store'; - -import { Observable } from 'rxjs/Observable'; -import { of } from 'rxjs/observable/of'; - -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/exhaustMap'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/take'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { NoAuthProbeService } from '../../../service/noauth-probe.service'; - -import { - ReadAllByDomainID, - ReadAllByDomainIDFailure, - ReadAllByDomainIDSuccess, - Accept, - AcceptSuccess, - AcceptFailure, - Deny, - DenySuccess, - DenyFailure, - ActionType, -} from './noauth-probe.action'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private noAuthProbeService: NoAuthProbeService, - private router: Router - ) { } - - @Effect() - readAllByDomain$: Observable = this.actions$ - .ofType(ActionType.ReadAllByDomainID) - .map((action: ReadAllByDomainID) => action.payload) - .switchMap(payload => this.noAuthProbeService.readAllByDomainID(payload)) - .map(noAuthProbes => { - return new ReadAllByDomainIDSuccess(noAuthProbes); - }) - .catch((error: RPCClientError) => { - return of(new ReadAllByDomainIDFailure(error)); - }); - - @Effect() - accept$: Observable = this.actions$ - .ofType(ActionType.Accept) - .map((action: Accept) => action.payload) - .switchMap(payload => this.noAuthProbeService.acceptNoAuthProbe(payload)) - .map(noAuthProbes => { - return new AcceptSuccess(noAuthProbes); - }) - .catch((error: RPCClientError) => { - return of(new AcceptFailure(error)); - }); - - @Effect() - deny$: Observable = this.actions$ - .ofType(ActionType.Deny) - .map((action: Deny) => action.payload) - .switchMap(payload => this.noAuthProbeService.denyNoauthProbe(payload)) - .map(noAuthProbes => { - return new DenySuccess(noAuthProbes); - }) - .catch((error: RPCClientError) => { - return of(new DenyFailure(error)); - }); - -} diff --git a/@overflow/noauth-probe/store/index.ts b/@overflow/noauth-probe/store/index.ts index 4d59cef..4f5d7c3 100644 --- a/@overflow/noauth-probe/store/index.ts +++ b/@overflow/noauth-probe/store/index.ts @@ -5,25 +5,23 @@ import { import { MODULE } from '../noauth-probe.constant'; -import * as NoAuthProbeEntityStore from './entity/noauth-probe'; - -import * as NoAuthProbeListContainerStore from './container/noauth-probe-list'; +import * as NoAuthProbeConnectingStore from './connecting'; export interface State { - noauth_probe_list: NoAuthProbeListContainerStore.State; + connecting: NoAuthProbeConnectingStore.State; } export const REDUCERS = { - noauth_probe_list: NoAuthProbeListContainerStore.reducer, + connecting: NoAuthProbeConnectingStore.reducer, }; export const EFFECTS = [ - NoAuthProbeEntityStore.Effects, + NoAuthProbeConnectingStore.Effects, ]; export const selectState = createFeatureSelector(MODULE.name); -export const NoAuthProbeListContainerSelector = NoAuthProbeListContainerStore.getSelectors(createSelector( +export const NoAuthProbeConnectingSelector = NoAuthProbeConnectingStore.getSelectors(createSelector( selectState, - (state: State) => state.noauth_probe_list + (state: State) => state.connecting )); diff --git a/@overflow/noauth-probe/subscriber/noauth-probe.subscriber.ts b/@overflow/noauth-probe/subscriber/noauth-probe.subscriber.ts index a499251..bf6358c 100644 --- a/@overflow/noauth-probe/subscriber/noauth-probe.subscriber.ts +++ b/@overflow/noauth-probe/subscriber/noauth-probe.subscriber.ts @@ -4,11 +4,9 @@ import { Store, select } from '@ngrx/store'; import { RPCSubscriber } from '@loafer/ng-rpc'; import { LoggerService } from '@loafer/ng-logger'; -import * as NoAuthProbeStore from '../store/entity/noauth-probe'; +import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth'; -import { - NoAuthProbe, -} from '@overflow/commons-typescript/model/noauth'; +import * as NoAuthProbeConnectingStore from '../store/connecting'; @Injectable() export class NoAuthProbeSubscriber { @@ -23,13 +21,13 @@ export class NoAuthProbeSubscriber { public onConnect(noAuthProbe: NoAuthProbe): void { this.loggerService.debug('NoAuthProbeService.onConnect noAuthProbe:', noAuthProbe); - this.store.dispatch(new NoAuthProbeStore.OnConnect(noAuthProbe)); + this.store.dispatch(new NoAuthProbeConnectingStore.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)); + this.store.dispatch(new NoAuthProbeConnectingStore.OnDisconnect(noAuthProbe)); } }