* ========================LICENSE_END===================================
*/
-import { HttpErrorResponse } from '@angular/common/http';
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { of } from 'rxjs/observable/of';
import { Observable } from 'rxjs/Observable';
-import { catchError, finalize, map } from 'rxjs/operators';
import { PolicyType, PolicyTypes, PolicyTypeSchema } from '../interfaces/policy.types';
import { PolicyService } from '../services/policy/policy.service';
-import { NotificationService } from '../services/ui/notification.service';
@Injectable({
providedIn: 'root'
policyTypeSubject = new BehaviorSubject<PolicyTypeSchema[]>([]);
- private loadingSubject = new BehaviorSubject<boolean>(false);
-
public rowCount = 1; // hide footer during intial load
- constructor(public policySvc: PolicyService,
- private notificationService: NotificationService) {
+ constructor(public policySvc: PolicyService) {
super();
}
public getPolicyTypes() {
this.policyTypes = [] as PolicyTypeSchema[];
this.policySvc.getPolicyTypes()
- .pipe(
- catchError((httpError: HttpErrorResponse) => {
- this.notificationService.error('Failed to get policy types: ' + httpError.error);
- return of([]);
- }),
- finalize(() => this.loadingSubject.next(false))
- )
.subscribe((policyType: PolicyTypes) => {
this.rowCount = policyType.policytype_ids.length;
if (policyType.policytype_ids.length != 0) {
}
else {
this.policySvc.getPolicyType(policyTypeId)
- .pipe(
- catchError((httpError: HttpErrorResponse) => {
- this.notificationService.error('Failed to get policy type: ' + httpError.error);
- return of([]);
- }),
- finalize(() => this.loadingSubject.next(false))
- )
.subscribe((policyType: PolicyType) => {
policyTypeSchema.id = policyTypeId;
policyTypeSchema.schemaObject = policyType.policy_schema;