X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fapp-control%2Fapp-control.component.ts;h=35c910d8eda5d4a7552b88b0f00de26e4499ccc6;hb=3f812ea25d352ec33d07f5ffa4c2aa2a77e8e793;hp=f87b9b5bf002ec0dc9da4de88ce209b56d098154;hpb=1379dce23d47c42d169ed13a337bbee827714830;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/app-control/app-control.component.ts b/webapp-frontend/src/app/app-control/app-control.component.ts index f87b9b5b..35c910d8 100644 --- a/webapp-frontend/src/app/app-control/app-control.component.ts +++ b/webapp-frontend/src/app/app-control/app-control.component.ts @@ -18,6 +18,7 @@ * ========================LICENSE_END=================================== */ import { Component, OnInit, ViewChild } from '@angular/core'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; import { MatSort } from '@angular/material/sort'; import { Router } from '@angular/router'; import { XappControlRow } from '../interfaces/app-mgr.types'; @@ -31,7 +32,7 @@ import { AppControlDataSource } from './app-control.datasource'; @Component({ selector: 'rd-app-control', templateUrl: './app-control.component.html', - styleUrls: ['./app-control.component.css'], + styleUrls: ['./app-control.component.scss'], animations: [AppControlAnimations.messageTrigger] }) export class AppControlComponent implements OnInit { @@ -45,10 +46,10 @@ export class AppControlComponent implements OnInit { private router: Router, private confirmDialogService: ConfirmDialogService, private errorDialogService: ErrorDialogService, - private notification: NotificationService) { } + private notificationService: NotificationService) { } ngOnInit() { - this.dataSource = new AppControlDataSource(this.appMgrSvc, this.sort); + this.dataSource = new AppControlDataSource(this.appMgrSvc, this.sort, this.notificationService); this.dataSource.loadTable(); } @@ -67,21 +68,29 @@ export class AppControlComponent implements OnInit { } } - undeployApp(app: XappControlRow): void { - this.confirmDialogService.openConfirmDialog('Are you sure you want to undeploy xApp ' + app.xapp + '?') - .afterClosed().subscribe(res => { + onUndeployApp(app: XappControlRow): void { + this.confirmDialogService.openConfirmDialog('Are you sure you want to undeploy App ' + app.xapp + '?') + .afterClosed().subscribe( (res: boolean) => { if (res) { this.appMgrSvc.undeployXapp(app.xapp).subscribe( - response => { + ( httpResponse: HttpResponse) => { this.dataSource.loadTable(); - switch (response.status) { + switch (httpResponse.status) { case 200: - this.notification.success('xApp undeployed successfully!'); + this.notificationService.success('App undeployed successfully!'); break; default: - this.notification.warn('xApp undeploy failed.'); + this.notificationService.warn('App undeploy failed.'); } - } + }, + ( (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.notificationService.warn('App undeploy failed: ' + msg); + }) ); } });