X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fran-control%2Fran-control.datasource.ts;h=d919f4ea768f4913f680124825731b55f2939fa3;hb=226fd436a085f717d4cbf81bf1719bdaf1468414;hp=431537fe56132f2f474051b9f70865843e8cb32b;hpb=dfa4f23a94fcbf31deab33abde4c6a8318fd4186;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/ran-control/ran-control.datasource.ts b/webapp-frontend/src/app/ran-control/ran-control.datasource.ts index 431537fe..d919f4ea 100644 --- a/webapp-frontend/src/app/ran-control/ran-control.datasource.ts +++ b/webapp-frontend/src/app/ran-control/ran-control.datasource.ts @@ -19,36 +19,48 @@ */ import { CollectionViewer, DataSource } from '@angular/cdk/collections'; +import { HttpErrorResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; -import { catchError, finalize } from 'rxjs/operators'; -import { of } from 'rxjs/observable/of'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; -import { E2SetupRequest } from '../interfaces/e2-mgr.types'; +import { of } from 'rxjs/observable/of'; +import { catchError, finalize } from 'rxjs/operators'; +import { E2RanDetails } from '../interfaces/e2-mgr.types'; import { E2ManagerService } from '../services/e2-mgr/e2-mgr.service'; +import { NotificationService } from '../services/ui/notification.service'; -export class RANControlDataSource extends DataSource { +export class RANControlDataSource extends DataSource { - private ranControlSubject = new BehaviorSubject([]); + private ranControlSubject = new BehaviorSubject([]); private loadingSubject = new BehaviorSubject(false); public loading$ = this.loadingSubject.asObservable(); - constructor(private e2MgrSvcservice: E2ManagerService) { + public rowCount = 1; // hide footer during intial load + + constructor(private e2MgrSvcservice: E2ManagerService, + private notificationService: NotificationService) { super(); } loadTable() { this.loadingSubject.next(true); - this.e2MgrSvcservice.getAll() + this.e2MgrSvcservice.getRan() .pipe( - catchError(() => of([])), - finalize(() => this.loadingSubject.next(false)) + catchError( (err: HttpErrorResponse) => { + console.log('RANControlDataSource failed: ' + err.message); + this.notificationService.error('Failed to get RAN details.'); + return of([]); + }), + finalize( () => this.loadingSubject.next(false) ) ) - .subscribe((ranControl: E2SetupRequest[]) => this.ranControlSubject.next(ranControl)); + .subscribe( (ranControl: E2RanDetails[] ) => { + this.rowCount = ranControl.length; + this.ranControlSubject.next(ranControl); + }); } - connect(collectionViewer: CollectionViewer): Observable { + connect(collectionViewer: CollectionViewer): Observable { return this.ranControlSubject.asObservable(); }