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

58 lines
2.1 KiB
TypeScript
Raw Normal View History

2018-05-18 08:49:13 +00:00
import { Component, OnInit } from '@angular/core';
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';
import { Domain, DomainMember } from '@overflow/commons-typescript/model/domain';
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
providers: [ConfirmationService, MessageService]
})
2018-05-26 09:59:57 +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-28 09:06:33 +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));
this.error$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectError));
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
}
);
}
accept(selected) {
2018-05-28 08:58:10 +00:00
this.store.dispatch(new NoAuthProbeEntityStore.Accept(selected));
2018-05-18 08:49:13 +00:00
}
deny(selected) {
2018-05-28 08:58:10 +00:00
this.store.dispatch(new NoAuthProbeEntityStore.Deny(selected));
2018-05-18 08:49:13 +00:00
}
}