Add error handling to HttpRequestInterceptor
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy-control / policy-type.datasource.ts
index 2e10f55..a7aa98d 100644 (file)
  * ========================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'
@@ -40,25 +37,15 @@ export class PolicyTypeDataSource extends DataSource<PolicyTypeSchema> {
 
     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) {
@@ -72,13 +59,6 @@ export class PolicyTypeDataSource extends DataSource<PolicyTypeSchema> {
                         }
                         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;