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-24 06:44:13 +00:00
|
|
|
import { AuthSelector } from '@overflow/member/store';
|
2018-05-18 08:49:13 +00:00
|
|
|
import { Domain } from '@overflow/commons-typescript/model/domain';
|
2018-05-25 11:31:58 +00:00
|
|
|
import * as ListStore from '../../store/entity/noauth-probe';
|
2018-05-18 08:49:13 +00:00
|
|
|
import { NoAuthProbeSelector } from '../../store';
|
|
|
|
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
|
|
|
|
import { ConfirmationService } from 'primeng/primeng';
|
|
|
|
import { MessageService } from 'primeng/components/common/messageservice';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-noauth-list-container',
|
|
|
|
templateUrl: './list-container.component.html',
|
|
|
|
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[]>;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private store: Store<ListStore.State>,
|
|
|
|
) {
|
2018-05-25 11:31:58 +00:00
|
|
|
this.noauthProbes$ = this.store.pipe(select(NoAuthProbeSelector.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-26 09:59:57 +00:00
|
|
|
ngOnInit() {
|
2018-05-18 08:49:13 +00:00
|
|
|
this.store.select(AuthSelector.select('domain')).subscribe(
|
|
|
|
(domain: Domain) => {
|
2018-05-24 11:03:23 +00:00
|
|
|
this.store.dispatch(new ListStore.ReadAllByDomainID(domain.id));
|
2018-05-18 08:49:13 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
accept(selected) {
|
|
|
|
this.store.dispatch(new ListStore.Accept(selected));
|
|
|
|
}
|
|
|
|
|
|
|
|
deny(selected) {
|
|
|
|
this.store.dispatch(new ListStore.Deny(selected));
|
|
|
|
}
|
|
|
|
}
|