X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fran-control%2Fran-control.component.ts;h=f5ef36cafb538123f9a9ac36d29651d0862e08e6;hb=refs%2Fchanges%2F37%2F537%2F12;hp=262dd03c25cd54359379f750f925a1206f736b06;hpb=5b686151904e2582ea9ce9d2f1c6abb7a400afa5;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/ran-control/ran-control.component.ts b/webapp-frontend/src/app/ran-control/ran-control.component.ts index 262dd03c..f5ef36ca 100644 --- a/webapp-frontend/src/app/ran-control/ran-control.component.ts +++ b/webapp-frontend/src/app/ran-control/ran-control.component.ts @@ -18,17 +18,17 @@ * ========================LICENSE_END=================================== */ import { Component, OnInit } from '@angular/core'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; import { MatDialog } from '@angular/material/dialog'; -import { RANConnectionDialogComponent } from './ran-connection-dialog.component'; +import { RanControlConnectDialogComponent } from './ran-connection-dialog.component'; import { E2ManagerService } from '../services/e2-mgr/e2-mgr.service'; import { ErrorDialogService } from '../services/ui/error-dialog.service'; import { ConfirmDialogService } from '../services/ui/confirm-dialog.service'; import { NotificationService } from '../services/ui/notification.service'; import { RANControlDataSource } from './ran-control.datasource'; -import { HttpErrorResponse } from '@angular/common/http'; @Component({ - selector: 'control-ran-control', + selector: 'rd-ran-control', templateUrl: './ran-control.component.html', styleUrls: ['./ran-control.component.scss'] }) @@ -37,45 +37,50 @@ export class RanControlComponent implements OnInit { dataSource: RANControlDataSource; constructor(private e2MgrSvc: E2ManagerService, - private errorSvc: ErrorDialogService, + private errorDialogService: ErrorDialogService, private confirmDialogService: ConfirmDialogService, - private notification: NotificationService, + private notificationService: NotificationService, public dialog: MatDialog) { } ngOnInit() { - this.dataSource = new RANControlDataSource(this.e2MgrSvc); + this.dataSource = new RANControlDataSource(this.e2MgrSvc, this.notificationService); this.dataSource.loadTable(); } setupRANConnection() { - const dialogRef = this.dialog.open(RANConnectionDialogComponent, { - width: '450px', - data: {} + const dialogRef = this.dialog.open(RanControlConnectDialogComponent, { + width: '450px' }); - dialogRef.afterClosed().subscribe(result => { - this.dataSource.loadTable(); + dialogRef.afterClosed().subscribe( (result: boolean) => { + if (result) { + this.dataSource.loadTable(); + } }); } disconnectAllRANConnections() { - let httpErrRes: HttpErrorResponse; const aboutError = 'Disconnect all RAN Connections Failed: '; this.confirmDialogService.openConfirmDialog('Are you sure you want to disconnect all RAN connections?') - .afterClosed().subscribe(res => { + .afterClosed().subscribe( (res: boolean) => { if (res) { this.e2MgrSvc.nodebDelete().subscribe( - response => { + ( response: HttpResponse) => { if (response.status === 200) { - this.notification.success('Disconnect all RAN Connections Succeeded!'); + this.notificationService.success('Disconnect succeeded!'); this.dataSource.loadTable(); } }, - (error => { - httpErrRes = error; - this.errorSvc.displayError(aboutError + httpErrRes.message); + ( (her: HttpErrorResponse) => { + // the error field should have an ErrorTransport object + let msg = her.message; + if (her.error && her.error.message) { + msg = her.error.message; + } + this.errorDialogService.displayError('Disconnect failed: ' + msg); }) ); } }); } + }