From: jh245g Date: Wed, 28 Aug 2019 13:32:20 +0000 (-0400) Subject: Add loading component X-Git-Tag: R2~28 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=492897ca754d470da3cbbc31eb49caea8fa7fe2c;p=portal%2Fric-dashboard.git Add loading component Create loading-dialog component and service Showing the loading-dialog while making API call Add notification and error handling for xapp configuration Change-Id: I6366c07d63055057fdc45036b56a2fcbfff04487 Signed-off-by: Jun (Nicolas) Hu --- diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 1e6deb4b..4d94370f 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -47,6 +47,9 @@ Version 1.2.0, 23 Aug 2019 * Use snake_case (not camelCase) names in AC policy front end * Update A1 mediator client to spec version 0.10.3 * Extend AC control screen to read policy from A1 +* Create loading-dialog component and service +* Showing the loading-dialog while making API call +* Add notification and error handling for xapp configuration Version 1.0.5, 5 July 2019 -------------------------- 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 652c955e..9e253912 100644 --- a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts +++ b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts @@ -18,15 +18,16 @@ * ========================LICENSE_END=================================== */ -import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { 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'; @@ -54,6 +55,7 @@ export class AnrXappComponent implements AfterViewInit, OnInit { private dialog: MatDialog, private confirmDialogService: ConfirmDialogService, private errorDialogService: ErrorDialogService, + private loadingDialogService: LoadingDialogService, private notificationService: NotificationService) { } ngOnInit() { @@ -107,7 +109,11 @@ export class AnrXappComponent implements AfterViewInit, OnInit { .openConfirmDialog('Are you sure you want to delete this relation?') .afterClosed().subscribe(res => { if (res) { + this.loadingDialogService.startLoading("Deleting"); this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci) + .pipe( + finalize(() => this.loadingDialogService.stopLoading()) + ) .subscribe( (response: HttpResponse) => { switch (response.status) { diff --git a/webapp-frontend/src/app/app-configuration/app-configuration.component.ts b/webapp-frontend/src/app/app-configuration/app-configuration.component.ts index 8b429c6e..28e9bf77 100644 --- a/webapp-frontend/src/app/app-configuration/app-configuration.component.ts +++ b/webapp-frontend/src/app/app-configuration/app-configuration.component.ts @@ -18,13 +18,15 @@ * ========================LICENSE_END=================================== */ -import { Component, OnInit, Inject } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { AppMgrService } from '../services/app-mgr/app-mgr.service'; -import { ErrorDialogService } from '../services/ui/error-dialog.service'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { finalize } from 'rxjs/operators'; - +import { AppMgrService } from '../services/app-mgr/app-mgr.service'; +import { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { LoadingDialogService } from '../services/ui/loading-dialog.service'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { NotificationService } from './../services/ui/notification.service'; @Component({ selector: 'rd-app-configuration', @@ -40,12 +42,14 @@ export class AppConfigurationComponent implements OnInit { private dialogRef: MatDialogRef, private appMgrService: AppMgrService, private errorDiaglogService: ErrorDialogService, + private loadingDialogService: LoadingDialogService, + private notificationService: NotificationService, @Inject(MAT_DIALOG_DATA) private data ) { } xappMetadata: any; xappConfigSchema: any; - xappConfigData: any; + xappConfigData: any; xappLayout:any; ngOnInit() { this.loadingSubject.next(true); @@ -67,8 +71,26 @@ export class AppConfigurationComponent implements OnInit { config: event, layout: this.xappLayout } + this.loadingDialogService.startLoading("Updating " + this.data.name + " configuration"); this.appMgrService.putConfig(config) - this.dialogRef.close(); + .pipe( + finalize(() => { + this.loadingDialogService.stopLoading(); + this.dialogRef.close(); + }) + ) + .subscribe( + (response: HttpResponse) => { + this.notificationService.success('Configuration update succeeded!'); + }, + ((her: HttpErrorResponse) => { + let msg = her.message; + if (her.error && her.error.message) { + msg = her.error.message; + } + this.notificationService.warn('Configuration update failed: ' + msg); + }) + ); } loadConfigForm(name: string, allConfig: any) { 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 057b9761..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,7 +76,12 @@ 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!'); diff --git a/webapp-frontend/src/app/catalog/catalog.component.ts b/webapp-frontend/src/app/catalog/catalog.component.ts index 9100de48..7f8cb685 100644 --- a/webapp-frontend/src/app/catalog/catalog.component.ts +++ b/webapp-frontend/src/app/catalog/catalog.component.ts @@ -17,17 +17,19 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit, ViewChild } from '@angular/core'; import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; import { MatSort } from '@angular/material/sort'; -import { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { finalize } from 'rxjs/operators'; +import { XMDeployableApp } from '../interfaces/app-mgr.types'; import { AppMgrService } from '../services/app-mgr/app-mgr.service'; +import { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { LoadingDialogService } from '../services/ui/loading-dialog.service'; +import { AppConfigurationComponent } from './../app-configuration/app-configuration.component'; import { ConfirmDialogService } from './../services/ui/confirm-dialog.service'; import { NotificationService } from './../services/ui/notification.service'; import { CatalogDataSource } from './catalog.datasource'; -import { XMDeployableApp } from '../interfaces/app-mgr.types'; -import { MatDialog } from '@angular/material/dialog'; -import { AppConfigurationComponent } from './../app-configuration/app-configuration.component'; @Component({ selector: 'rd-app-catalog', @@ -45,6 +47,7 @@ export class CatalogComponent implements OnInit { private confirmDialogService: ConfirmDialogService, private dialog: MatDialog, private errorDiaglogService: ErrorDialogService, + private loadingDialogService: LoadingDialogService, private notificationService: NotificationService) { } ngOnInit() { @@ -68,7 +71,12 @@ export class CatalogComponent implements OnInit { this.confirmDialogService.openConfirmDialog('Deploy application ' + app.name + '?') .afterClosed().subscribe( (res: boolean) => { if (res) { - this.appMgrService.deployXapp(app.name).subscribe( + this.loadingDialogService.startLoading("Deploying " + app.name); + this.appMgrService.deployXapp(app.name) + .pipe( + finalize(() => this.loadingDialogService.stopLoading()) + ) + .subscribe( (response: HttpResponse) => { this.notificationService.success('App deploy succeeded!'); }, diff --git a/webapp-frontend/src/app/ran-control/ran-connection-dialog.component.ts b/webapp-frontend/src/app/ran-control/ran-connection-dialog.component.ts index 7c63f132..4065f44a 100644 --- a/webapp-frontend/src/app/ran-control/ran-connection-dialog.component.ts +++ b/webapp-frontend/src/app/ran-control/ran-connection-dialog.component.ts @@ -17,100 +17,108 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit, Inject } from '@angular/core'; -import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; -import { FormGroup, FormControl, Validators } from '@angular/forms'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { MatDialogRef } from '@angular/material/dialog'; import { Observable } from 'rxjs'; +import { finalize } from 'rxjs/operators'; +import { E2SetupRequest, RanDialogFormData } from '../interfaces/e2-mgr.types'; import { E2ManagerService } from '../services/e2-mgr/e2-mgr.service'; -import { NotificationService } from '../services/ui/notification.service'; import { ErrorDialogService } from '../services/ui/error-dialog.service'; -import { E2SetupRequest, RanDialogFormData } from '../interfaces/e2-mgr.types'; +import { LoadingDialogService } from '../services/ui/loading-dialog.service'; +import { NotificationService } from '../services/ui/notification.service'; @Component({ - selector: 'rd-ran-control-connect-dialog', - templateUrl: './ran-connection-dialog.component.html', - styleUrls: ['./ran-connection-dialog.component.scss'] + selector: 'rd-ran-control-connect-dialog', + templateUrl: './ran-connection-dialog.component.html', + styleUrls: ['./ran-connection-dialog.component.scss'] }) export class RanControlConnectDialogComponent implements OnInit { - public ranDialogForm: FormGroup; - public processing = false; + public ranDialogForm: FormGroup; + public processing = false; - constructor( - private dialogRef: MatDialogRef, - private service: E2ManagerService, - private errorService: ErrorDialogService, - private notifService: NotificationService) { - // opens with empty fields; accepts no data to display - } + constructor( + private dialogRef: MatDialogRef, + private service: E2ManagerService, + private errorService: ErrorDialogService, + private loadingDialogService: LoadingDialogService, + private notifService: NotificationService) { + // opens with empty fields; accepts no data to display + } - ngOnInit() { - const namePattern = /^([A-Z]){4}([0-9]){6}$/; - // tslint:disable-next-line:max-line-length - const ipPattern = /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/; - const portPattern = /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/; - this.ranDialogForm = new FormGroup({ - ranType: new FormControl('endc'), - ranName: new FormControl('', [Validators.required, Validators.pattern(namePattern)]), - ranIp: new FormControl('', [Validators.required, Validators.pattern(ipPattern)]), - ranPort: new FormControl('', [Validators.required, Validators.pattern(portPattern)]) - }); - } + ngOnInit() { + const namePattern = /^([A-Z]){4}([0-9]){6}$/; + // tslint:disable-next-line:max-line-length + const ipPattern = /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/; + const portPattern = /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/; + this.ranDialogForm = new FormGroup({ + ranType: new FormControl('endc'), + ranName: new FormControl('', [Validators.required, Validators.pattern(namePattern)]), + ranIp: new FormControl('', [Validators.required, Validators.pattern(ipPattern)]), + ranPort: new FormControl('', [Validators.required, Validators.pattern(portPattern)]) + }); + } - onCancel() { - this.dialogRef.close(false); - } + onCancel() { + this.dialogRef.close(false); + } - setupConnection = (ranFormValue: RanDialogFormData) => { - if (!this.ranDialogForm.valid) { - // should never happen - return; - } - this.processing = true; - const setupRequest: E2SetupRequest = { - ranName: ranFormValue.ranName, - ranIp: ranFormValue.ranIp, - ranPort: ranFormValue.ranPort - }; - let observable: Observable>; - if (ranFormValue.ranType === 'endc') { - observable = this.service.endcSetup(setupRequest); - } else { - observable = this.service.x2Setup(setupRequest); - } - observable.subscribe( - (response: any) => { - this.processing = false; - this.notifService.success('Connect succeeded!'); - this.dialogRef.close(true); - }, - ( (her: HttpErrorResponse) => { - this.processing = false; - // the error field carries the server's response - let msg = her.message; - if (her.error && her.error.message) { - msg = her.error.message; - } - this.errorService.displayError('Connect failed: ' + msg); - // keep the dialog open - }) - ); + setupConnection = (ranFormValue: RanDialogFormData) => { + if (!this.ranDialogForm.valid) { + // should never happen + return; + } + this.processing = true; + const setupRequest: E2SetupRequest = { + ranName: ranFormValue.ranName, + ranIp: ranFormValue.ranIp, + ranPort: ranFormValue.ranPort + }; + this.loadingDialogService.startLoading("Setting up connection "); + let observable: Observable>; + if (ranFormValue.ranType === 'endc') { + observable = this.service.endcSetup(setupRequest); + } else { + observable = this.service.x2Setup(setupRequest); } + observable + .pipe( + finalize(() => this.loadingDialogService.stopLoading()) + ) + .subscribe( + (response: any) => { + this.processing = false; + this.notifService.success('Connect succeeded!'); + this.dialogRef.close(true); + }, + ((her: HttpErrorResponse) => { + this.processing = false; + // the error field carries the server's response + let msg = her.message; + if (her.error && her.error.message) { + msg = her.error.message; + } + this.errorService.displayError('Connect failed: ' + msg); + // keep the dialog open + }) + ); + } - hasError(controlName: string, errorName: string) { - if (this.ranDialogForm.controls[controlName].hasError(errorName)) { - return true; - } - return false; + hasError(controlName: string, errorName: string) { + if (this.ranDialogForm.controls[controlName].hasError(errorName)) { + return true; } + return false; + } - validateControl(controlName: string) { - if (this.ranDialogForm.controls[controlName].invalid && this.ranDialogForm.controls[controlName].touched) { - return true; - } - return false; + validateControl(controlName: string) { + if (this.ranDialogForm.controls[controlName].invalid && this.ranDialogForm.controls[controlName].touched) { + return true; } + return false; + } } 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 af7709d8..172a84e2 100644 --- a/webapp-frontend/src/app/ran-control/ran-control.component.ts +++ b/webapp-frontend/src/app/ran-control/ran-control.component.ts @@ -17,14 +17,16 @@ * limitations under the License. * ========================LICENSE_END=================================== */ +import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; -import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; import { MatDialog } from '@angular/material/dialog'; -import { RanControlConnectDialogComponent } from './ran-connection-dialog.component'; +import { finalize } from 'rxjs/operators'; 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 { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { LoadingDialogService } from '../services/ui/loading-dialog.service'; import { NotificationService } from '../services/ui/notification.service'; +import { RanControlConnectDialogComponent } from './ran-connection-dialog.component'; import { RANControlDataSource } from './ran-control.datasource'; @Component({ @@ -40,6 +42,7 @@ export class RanControlComponent implements OnInit { private errorDialogService: ErrorDialogService, private confirmDialogService: ConfirmDialogService, private notificationService: NotificationService, + private loadingDialogService: LoadingDialogService, public dialog: MatDialog) { } ngOnInit() { @@ -63,7 +66,12 @@ export class RanControlComponent implements OnInit { this.confirmDialogService.openConfirmDialog('Are you sure you want to disconnect all RAN connections?') .afterClosed().subscribe( (res: boolean) => { if (res) { - this.e2MgrSvc.nodebPut().subscribe( + this.loadingDialogService.startLoading("Disconnecting"); + this.e2MgrSvc.nodebPut() + .pipe( + finalize(() => this.loadingDialogService.stopLoading()) + ) + .subscribe( ( body: any ) => { this.notificationService.success('Disconnect succeeded!'); this.dataSource.loadTable(); diff --git a/webapp-frontend/src/app/rd.module.ts b/webapp-frontend/src/app/rd.module.ts index 8b59594a..acb95367 100644 --- a/webapp-frontend/src/app/rd.module.ts +++ b/webapp-frontend/src/app/rd.module.ts @@ -55,6 +55,7 @@ import { ErrorDialogComponent } from './ui/error-dialog/error-dialog.component'; import { ErrorDialogService } from './services/ui/error-dialog.service'; import { FlexLayoutModule } from '@angular/flex-layout'; import { FooterComponent } from './footer/footer.component'; +import { LoadingDialogComponent } from './ui/loading-dialog/loading-dialog.component'; import { MainComponent } from './main/main.component'; import { MaterialDesignFrameworkModule } from 'angular6-json-schema-form'; import { ModalEventComponent } from './ui/modal-event/modal-event.component'; @@ -85,6 +86,7 @@ import { UserComponent } from './user/user.component'; EditDashboardUserDialogComponent, ErrorDialogComponent, FooterComponent, + LoadingDialogComponent, MainComponent, ModalEventComponent, RanControlComponent, @@ -157,6 +159,7 @@ import { UserComponent } from './user/user.component'; ConfirmDialogComponent, EditDashboardUserDialogComponent, ErrorDialogComponent, + LoadingDialogComponent, RanControlConnectDialogComponent ], providers: [ diff --git a/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts b/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts index 33dd1cb6..f9df38c3 100644 --- a/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts +++ b/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts @@ -29,32 +29,32 @@ export class AppMgrService { // injects to variable httpClient } - private basePath = 'api/appmgr/xapps'; + private basePath = 'api/appmgr'; getDeployable(): Observable { - return this.httpClient.get(this.basePath + '/list'); + return this.httpClient.get(this.basePath + '/xapps/list'); } getDeployed(): Observable { - return this.httpClient.get(this.basePath); + return this.httpClient.get(this.basePath + '/xapps'); } deployXapp(name: string): Observable> { const xappInfo: XMXappInfo = { name: name }; - return this.httpClient.post(this.basePath, xappInfo, { observe: 'response' }); + return this.httpClient.post((this.basePath + '/xapps'), xappInfo, { observe: 'response' }); } undeployXapp(name: string): Observable> { - return this.httpClient.delete((this.basePath + '/' + name), { observe: 'response' }); + return this.httpClient.delete((this.basePath + '/xapps'+ '/' + name), { observe: 'response' }); } getConfig(): Observable{ return this.httpClient.get("/assets/mockdata/config.json"); - //return this.httpClient.get((this.basePath + '/config')); + //return this.httpClient.get((this.basePath + '/config')); } putConfig(config: any): Observable> { - return this.httpClient.post((this.basePath + '/config' ), config, { observe: 'response' }); + return this.httpClient.put((this.basePath + '/config' ), config, { observe: 'response' }); } diff --git a/webapp-frontend/src/app/services/ui/loading-dialog.service.spec.ts b/webapp-frontend/src/app/services/ui/loading-dialog.service.spec.ts new file mode 100644 index 00000000..2aec88d4 --- /dev/null +++ b/webapp-frontend/src/app/services/ui/loading-dialog.service.spec.ts @@ -0,0 +1,32 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +import { TestBed } from '@angular/core/testing'; + +import { LoadingDialogService } from './loading-dialog.service'; + +describe('LoadingDialogService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: LoadingDialogService = TestBed.get(LoadingDialogService); + expect(service).toBeTruthy(); + }); +}); diff --git a/webapp-frontend/src/app/services/ui/loading-dialog.service.ts b/webapp-frontend/src/app/services/ui/loading-dialog.service.ts new file mode 100644 index 00000000..a172d287 --- /dev/null +++ b/webapp-frontend/src/app/services/ui/loading-dialog.service.ts @@ -0,0 +1,51 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +import { Injectable } from '@angular/core'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { LoadingDialogComponent } from './../../ui/loading-dialog/loading-dialog.component'; + +@Injectable({ + providedIn: 'root' +}) +export class LoadingDialogService { + + constructor(private dialog: MatDialog) { } + + private loadingDialogRef: MatDialogRef; + + startLoading(msg: string) { + this.loadingDialogRef = this.dialog.open(LoadingDialogComponent, { + disableClose: true, + width: '480px', + position: { top: '100px' }, + data: { + message: msg + } + }); + } + + stopLoading() { + this.loadingDialogRef.close() + } + +} + + diff --git a/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.html b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.html new file mode 100644 index 00000000..3066d0e0 --- /dev/null +++ b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.html @@ -0,0 +1,27 @@ + + + +
+ {{data.message}} +
+ + + diff --git a/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.scss b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.scss new file mode 100644 index 00000000..8683a537 --- /dev/null +++ b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.scss @@ -0,0 +1,23 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +mat-spinner { + margin: 10px +} diff --git a/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.spec.ts b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.spec.ts new file mode 100644 index 00000000..4462b3b1 --- /dev/null +++ b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.spec.ts @@ -0,0 +1,45 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoadingDialogComponent } from './loading-dialog.component'; + +describe('LoadingDialogComponent', () => { + let component: LoadingDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ LoadingDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LoadingDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.ts b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.ts new file mode 100644 index 00000000..9658efe2 --- /dev/null +++ b/webapp-frontend/src/app/ui/loading-dialog/loading-dialog.component.ts @@ -0,0 +1,36 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ + +import { Component, OnInit, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA } from '@angular/material'; + +@Component({ + selector: 'rd-loading-dialog', + templateUrl: './loading-dialog.component.html', + styleUrls: ['./loading-dialog.component.scss'] +}) +export class LoadingDialogComponent implements OnInit { + + constructor(@Inject(MAT_DIALOG_DATA) public data) { } + + ngOnInit() { + } + +}