X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=webapp-frontend%2Fsrc%2Fapp%2Fapp-control%2Fapp-control.component.ts;h=18af73bf777e52f748f9085f02f60659d89de119;hb=55472d9367cf229b2b87a625a8aa1dfb822cbaad;hp=6ef4b1612054fc3acba212f1779345069c84c860;hpb=d6088959b3d83eeaa9aef70ccb600f806a48acdc;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 6ef4b161..18af73bf 100644 --- a/webapp-frontend/src/app/app-control/app-control.component.ts +++ b/webapp-frontend/src/app/app-control/app-control.component.ts @@ -17,17 +17,19 @@ * limitations under the License. * ========================LICENSE_END=================================== */ +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; 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'; import { AppMgrService } from '../services/app-mgr/app-mgr.service'; import { ConfirmDialogService } from '../services/ui/confirm-dialog.service'; import { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { LoadingDialogService } from '../services/ui/loading-dialog.service'; import { NotificationService } from '../services/ui/notification.service'; import { AppControlAnimations } from './app-control.animations'; import { AppControlDataSource } from './app-control.datasource'; +import { finalize } from 'rxjs/operators'; @Component({ selector: 'rd-app-control', @@ -46,6 +48,7 @@ export class AppControlComponent implements OnInit { private router: Router, private confirmDialogService: ConfirmDialogService, private errorDialogService: ErrorDialogService, + private loadingDialogService: LoadingDialogService, private notificationService: NotificationService) { } ngOnInit() { @@ -73,16 +76,16 @@ export class AppControlComponent implements OnInit { 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( + this.loadingDialogService.startLoading("Undeploying " + app.xapp); + this.appMgrSvc.undeployXapp(app.xapp) + .pipe( + finalize(() => this.loadingDialogService.stopLoading()) + ) + .subscribe( ( httpResponse: HttpResponse) => { + // Answers 204/No content on success + this.notificationService.success('App undeployed successfully!'); this.dataSource.loadTable(); - switch (httpResponse.status) { - case 200: - this.notificationService.success('App undeployed successfully!'); - break; - default: - this.notificationService.warn('App undeploy failed.'); - } }, ( (her: HttpErrorResponse) => { // the error field should have an ErrorTransport object