member_webapp/@overflow/noauth-probe/container/noauth-probe-list-container.component.ts

57 lines
2.1 KiB
TypeScript
Raw Normal View History

2018-05-30 05:24:19 +00:00
import { Component, OnInit } from '@angular/core';
2018-05-18 08:49:13 +00:00
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
2018-05-28 08:58:10 +00:00
import { AuthContainerSelector } from '@overflow/shared/auth/store';
2018-05-30 05:24:19 +00:00
import { DomainMember } from '@overflow/commons-typescript/model/domain';
2018-05-28 08:58:10 +00:00
import * as NoAuthProbeEntityStore from '../store/entity/noauth-probe';
import { NoAuthProbeListContainerSelector } from '../store';
2018-05-18 08:49:13 +00:00
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
import { ConfirmationService } from 'primeng/primeng';
import { MessageService } from 'primeng/components/common/messageservice';
2018-05-28 08:58:10 +00:00
import { RPCClientError } from '@loafer/ng-rpc';
2018-05-18 08:49:13 +00:00
@Component({
2018-05-28 05:41:56 +00:00
selector: 'of-noauth-probe-list-container',
templateUrl: './noauth-probe-list-container.component.html',
2018-05-18 08:49:13 +00:00
})
2018-05-30 05:24:19 +00:00
export class NoAuthProbeListContainerComponent implements OnInit {
2018-05-18 08:49:13 +00:00
noauthProbes$: Observable<NoAuthProbe[]>;
2018-05-28 08:58:10 +00:00
pending$: Observable<boolean>;
2018-05-30 05:24:19 +00:00
error$: Observable<any>;
2018-05-18 08:49:13 +00:00
constructor(
2018-05-28 08:58:10 +00:00
private store: Store<any>,
2018-05-18 08:49:13 +00:00
) {
2018-05-28 08:58:10 +00:00
}
ngOnInit() {
this.pending$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectPending));
2018-05-30 05:24:19 +00:00
this.error$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectError));
2018-05-28 08:58:10 +00:00
this.noauthProbes$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectAll)).map((_noauthProbes: NoAuthProbe[]) => {
2018-05-18 08:49:13 +00:00
if (null === _noauthProbes) {
return null;
}
_noauthProbes.forEach(_noauthProbe => {
_noauthProbe.descriptions = JSON.parse(_noauthProbe.description);
});
return _noauthProbes;
});
2018-05-28 08:58:10 +00:00
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
this.store.dispatch(new NoAuthProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
2018-05-18 08:49:13 +00:00
}
);
}
2018-05-28 13:19:31 +00:00
accept(noAuthProbe: NoAuthProbe) {
2018-05-28 13:40:44 +00:00
this.store.dispatch(new NoAuthProbeEntityStore.Accept({aa: noAuthProbe.id} as any));
2018-05-18 08:49:13 +00:00
}
2018-05-28 13:19:31 +00:00
deny(noAuthProbe: NoAuthProbe) {
this.store.dispatch(new NoAuthProbeEntityStore.Deny(noAuthProbe.id));
2018-05-18 08:49:13 +00:00
}
}