X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fanr-xapp%2Fanr-xapp.component.ts;h=eaa2ca393f620379685ccbcaedf3f1dcea548fab;hb=b244a344777f416ad9b5ff09d1a8ad5f5517f2bf;hp=3440482cfc0540cb46a871fe10312730c605c83f;hpb=1379dce23d47c42d169ed13a337bbee827714830;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts index 3440482c..eaa2ca39 100644 --- a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts +++ b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts @@ -18,14 +18,16 @@ * ========================LICENSE_END=================================== */ +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { MatSort } from '@angular/material'; import { MatDialog } from '@angular/material/dialog'; import { fromEvent } from 'rxjs/observable/fromEvent'; -import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators'; +import { debounceTime, distinctUntilChanged, finalize, tap } from 'rxjs/operators'; import { ANRNeighborCellRelation } from '../interfaces/anr-xapp.types'; import { ANRXappService } from '../services/anr-xapp/anr-xapp.service'; import { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { LoadingDialogService } from '../services/ui/loading-dialog.service'; import { ConfirmDialogService } from './../services/ui/confirm-dialog.service'; import { NotificationService } from './../services/ui/notification.service'; import { AnrEditNcrDialogComponent } from './anr-edit-ncr-dialog.component'; @@ -39,12 +41,11 @@ import { ANRXappDataSource } from './anr-xapp.datasource'; export class AnrXappComponent implements AfterViewInit, OnInit { dataSource: ANRXappDataSource; - anrClientVersion: string; gNodeBIds: string[]; - @ViewChild('ggNodeB', {static: true}) ggNodeB: ElementRef; - @ViewChild('servingCellNrcgi', {static: true}) servingCellNrcgi: ElementRef; - @ViewChild('neighborCellNrpci', {static: true}) neighborCellNrpci: ElementRef; - @ViewChild(MatSort, {static: true}) sort: MatSort; + @ViewChild('ggNodeB', { static: true }) ggNodeB: ElementRef; + @ViewChild('servingCellNrcgi', { static: true }) servingCellNrcgi: ElementRef; + @ViewChild('neighborCellNrpci', { static: true }) neighborCellNrpci: ElementRef; + @ViewChild(MatSort, { static: true }) sort: MatSort; displayedColumns = ['cellIdentifierNrcgi', 'neighborCellNrpci', 'neighborCellNrcgi', 'flagNoHo', 'flagNoXn', 'flagNoRemove', 'action']; @@ -54,14 +55,14 @@ export class AnrXappComponent implements AfterViewInit, OnInit { private dialog: MatDialog, private confirmDialogService: ConfirmDialogService, private errorDialogService: ErrorDialogService, + private loadingDialogService: LoadingDialogService, private notificationService: NotificationService) { } ngOnInit() { - this.dataSource = new ANRXappDataSource(this.anrXappService, this.sort); + this.dataSource = new ANRXappDataSource(this.anrXappService, this.sort, this.notificationService); this.dataSource.loadTable(); // Empty string occurs first in the array of gNodeBIds this.anrXappService.getgNodeBs().subscribe((res: string[]) => this.gNodeBIds = res); - this.anrXappService.getVersion().subscribe((res: string) => this.anrClientVersion = res); } ngAfterViewInit() { @@ -98,32 +99,39 @@ export class AnrXappComponent implements AfterViewInit, OnInit { width: '300px', data: ncr }); - dialogRef.afterClosed().subscribe(result => { - this.loadNcrtPage(); - }); + dialogRef.afterClosed().subscribe( + (result: any) => { + this.loadNcrtPage(); + } + ); } deleteNcr(ncr: ANRNeighborCellRelation): void { this.confirmDialogService .openConfirmDialog('Are you sure you want to delete this relation?') - .afterClosed().subscribe(res => { - if (res) { - this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci) - .subscribe( - response => { - switch (response.status) { - case 200: - this.notificationService.success('Delete succeeded!'); - break; - default: - this.notificationService.warn('Delete failed.'); - } - }, - error => { - this.errorDialogService.displayError(error.message); - }); - } - }); + .afterClosed().subscribe( + (res: any) => { + if (res) { + this.loadingDialogService.startLoading("Deleting"); + this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci) + .pipe( + finalize(() => this.loadingDialogService.stopLoading()) + ) + .subscribe( + (response: HttpResponse) => { + switch (response.status) { + case 200: + this.notificationService.success('Delete succeeded!'); + break; + default: + this.notificationService.warn('Delete failed.'); + } + }, + (error: HttpErrorResponse) => { + this.errorDialogService.displayError(error.message); + }); + } + }); } }