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)); } }