ing
This commit is contained in:
parent
87f68ca3f3
commit
68e0e578c7
|
@ -6,10 +6,9 @@ import { Anim } from './animation';
|
|||
import { Store, select } from '@ngrx/store';
|
||||
import { Observable, of, Subscription } from 'rxjs';
|
||||
import { DiscoveryService } from '../service/discovery.service';
|
||||
import { DiscoveryNotify } from '../subscriber/discovery.subscriber.subject';
|
||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
||||
import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery';
|
||||
import { DiscoverySubscriber } from '../subscriber/discovery.subscriber';
|
||||
import { DiscoverySubscriber, DiscoveryNotify } from '../subscriber/discovery.subscriber';
|
||||
|
||||
@Component({
|
||||
selector: 'of-discovery',
|
||||
|
@ -39,9 +38,7 @@ export class DiscoveryComponent {
|
|||
|
||||
this.requested = true;
|
||||
|
||||
const discovery$ = this.discoverySubscriber.subscribe();
|
||||
|
||||
discovery$.pipe(
|
||||
this.discoverySubscriber.observable().pipe(
|
||||
tap(() => {
|
||||
this.discoveryService.discoverZone(this.selectedProbe.probe.probeKey, dz);
|
||||
}),
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { Subject } from 'rxjs';
|
||||
|
||||
import {
|
||||
Zone,
|
||||
Host,
|
||||
Port,
|
||||
Service,
|
||||
} from '@overflow/commons-typescript/model/discovery';
|
||||
|
||||
export interface DiscoveryNotify {
|
||||
method: string;
|
||||
params: Date | Zone | Host | Port | Service;
|
||||
}
|
||||
|
||||
export class DiscoverySubscriberSubject extends Subject<DiscoveryNotify> {
|
||||
|
||||
}
|
|
@ -14,7 +14,15 @@ import {
|
|||
Port,
|
||||
Service,
|
||||
} from '@overflow/commons-typescript/model/discovery';
|
||||
import { DiscoverySubscriberSubject, DiscoveryNotify } from './discovery.subscriber.subject';
|
||||
|
||||
export interface DiscoveryNotify {
|
||||
method: string;
|
||||
params: Date | Zone | Host | Port | Service;
|
||||
}
|
||||
|
||||
export class DiscoverySubscriberSubject extends Subject<DiscoveryNotify> {
|
||||
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class DiscoverySubscriber {
|
||||
|
@ -23,13 +31,13 @@ export class DiscoverySubscriber {
|
|||
public constructor(
|
||||
private loggerService: LoggerService,
|
||||
) {
|
||||
this.discoverySubscriberSubject = new DiscoverySubscriberSubject();
|
||||
this.discoverySubscriberSubject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public subscribe(): Observable<DiscoveryNotify> {
|
||||
public observable(): Observable<DiscoveryNotify> {
|
||||
if (null === this.discoverySubscriberSubject) {
|
||||
this.discoverySubscriberSubject = new DiscoverySubscriberSubject();
|
||||
}
|
||||
return this.discoverySubscriberSubject.asObservable();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
|||
|
||||
import { NoAuthProbeService } from '../service/noauth-probe.service';
|
||||
import { NoAuthProbeConnectingSelector } from '../store';
|
||||
import { NoAuthProbeSubscriber, NoAuthProbeNotify } from '../subscriber/noauth-probe.subscriber';
|
||||
|
||||
@Component({
|
||||
selector: 'of-noauth-probe-list',
|
||||
|
@ -21,12 +22,13 @@ export class NoAuthProbeListComponent implements OnInit, OnDestroy {
|
|||
error$: Observable<any>;
|
||||
|
||||
noauthProbes: NoAuthProbe[];
|
||||
connectingSubscription$: Subscription;
|
||||
// connectingSubscription$: Subscription;
|
||||
|
||||
constructor(
|
||||
private confirmationService: ConfirmationService,
|
||||
private store: Store<any>,
|
||||
private noAuthProbeService: NoAuthProbeService,
|
||||
private noAuthProbeSubscriber: NoAuthProbeSubscriber,
|
||||
) {
|
||||
this.noauthProbes = [];
|
||||
}
|
||||
|
@ -54,14 +56,30 @@ export class NoAuthProbeListComponent implements OnInit, OnDestroy {
|
|||
}),
|
||||
).take(1).subscribe();
|
||||
|
||||
this.connectingSubscription$ = this.store.pipe(
|
||||
select(NoAuthProbeConnectingSelector.selectEntities),
|
||||
tap((entities: { [id: number]: NoAuthProbe }) => {
|
||||
// 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.noAuthProbeSubscriber.observable().pipe(
|
||||
tap((noAuthProbeNotify: NoAuthProbeNotify) => {
|
||||
const noauthProbes = [];
|
||||
this.noauthProbes.forEach(noauthProbe => {
|
||||
const t = entities[noauthProbe.id];
|
||||
if (undefined !== t) {
|
||||
noauthProbes.push(t);
|
||||
const n = noAuthProbeNotify.params;
|
||||
if (noauthProbe.id === n.id) {
|
||||
noauthProbes.push(n);
|
||||
} else {
|
||||
noauthProbes.push(noauthProbe);
|
||||
}
|
||||
|
@ -100,7 +118,7 @@ export class NoAuthProbeListComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.connectingSubscription$.unsubscribe();
|
||||
// this.connectingSubscription$.unsubscribe();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
|
||||
import { RPCSubscriber } from '@loafer/ng-rpc';
|
||||
import { LoggerService } from '@loafer/ng-logger';
|
||||
|
@ -8,26 +9,47 @@ import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
|
|||
|
||||
import * as NoAuthProbeConnectingStore from '../store/connecting';
|
||||
|
||||
export interface NoAuthProbeNotify {
|
||||
method: string;
|
||||
params: NoAuthProbe;
|
||||
}
|
||||
|
||||
export class NoAuthProbeSubscriberSubject extends Subject<NoAuthProbeNotify> {
|
||||
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoAuthProbeSubscriber {
|
||||
private noAuthProbeSubscriberSubject: NoAuthProbeSubscriberSubject;
|
||||
|
||||
public constructor(
|
||||
private store: Store<any>,
|
||||
private loggerService: LoggerService,
|
||||
) {
|
||||
this.noAuthProbeSubscriberSubject = null;
|
||||
}
|
||||
|
||||
public observable(): Observable<NoAuthProbeNotify> {
|
||||
if (null === this.noAuthProbeSubscriberSubject) {
|
||||
this.noAuthProbeSubscriberSubject = new NoAuthProbeSubscriberSubject();
|
||||
}
|
||||
return this.noAuthProbeSubscriberSubject.asObservable();
|
||||
}
|
||||
|
||||
private publish(method: string, params: any): void {
|
||||
this.noAuthProbeSubscriberSubject.next({ method: method, params: params });
|
||||
}
|
||||
|
||||
@RPCSubscriber({method: 'NoAuthProbeService.onConnect'})
|
||||
public onConnect(noAuthProbe: NoAuthProbe): void {
|
||||
this.loggerService.debug('NoAuthProbeService.onConnect noAuthProbe:', noAuthProbe);
|
||||
|
||||
this.store.dispatch(new NoAuthProbeConnectingStore.OnConnect(noAuthProbe));
|
||||
this.publish('NoAuthProbeService.onConnect', noAuthProbe);
|
||||
}
|
||||
|
||||
@RPCSubscriber({method: 'NoAuthProbeService.onDisconnect'})
|
||||
public onDisconnect(noAuthProbe: NoAuthProbe): void {
|
||||
this.loggerService.debug('NoAuthProbeService.onDisconnect noAuthProbe:', noAuthProbe);
|
||||
|
||||
this.store.dispatch(new NoAuthProbeConnectingStore.OnDisconnect(noAuthProbe));
|
||||
this.publish('NoAuthProbeService.onDisconnect', noAuthProbe);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user