member_webapp/@overflow/noauth-probe/container/noauth-probe-list-container.component.ts
2018-05-30 14:24:19 +09:00

57 lines
2.1 KiB
TypeScript

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<NoAuthProbe[]>;
pending$: Observable<boolean>;
error$: Observable<any>;
constructor(
private store: Store<any>,
) {
}
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));
}
}