From 4347fbc44c279856d5b83a1768638fe571daf4d5 Mon Sep 17 00:00:00 2001 From: jh245g Date: Wed, 22 May 2019 17:26:40 -0400 Subject: [PATCH] Apply mat-table to control and catalog Change-Id: Ia19844502618c70a5627a0017eb79ec42b922e88 Signed-off-by: Jun (Nicolas) Hu --- docs/release-notes.rst | 3 +- webapp-frontend/src/app/app.module.ts | 12 ++- .../src/app/catalog/catalog.component.css | 25 +++--- .../src/app/catalog/catalog.component.html | 48 +++++++++-- .../src/app/catalog/catalog.component.ts | 53 ++++-------- .../src/app/catalog/catalog.datasource.ts | 59 ++++++++++++++ .../src/app/control/control.animations.ts | 28 +++++++ .../src/app/control/control.component.css | 26 +++--- .../src/app/control/control.component.html | 79 ++++++++++++++++-- .../src/app/control/control.component.ts | 95 ++++------------------ .../src/app/control/control.datasource.ts | 74 +++++++++++++++++ .../src/app/interfaces/xapp-mgr.types.ts | 5 ++ .../src/app/services/xapp-mgr/xapp-mgr.service.ts | 5 +- 13 files changed, 352 insertions(+), 160 deletions(-) create mode 100644 webapp-frontend/src/app/catalog/catalog.datasource.ts create mode 100644 webapp-frontend/src/app/control/control.animations.ts create mode 100644 webapp-frontend/src/app/control/control.datasource.ts diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 082678c2..ec39828b 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -20,7 +20,7 @@ RIC Dashboard Release Notes =========================== -Version 1.0.3, 21 May 2019 +Version 1.0.3, 22 May 2019 -------------------------- * Add AC xApp controller to backend * Add AC xApp interface to frontend @@ -33,6 +33,7 @@ Version 1.0.3, 21 May 2019 * Add AC and ANR xApp services * Rename signal service to E2 Manager service * Use XappMgrService to replace ControlService and CatalogService +* Apply mat-table to control and catalog Version 1.0.2, 13 May 2019 -------------------------- diff --git a/webapp-frontend/src/app/app.module.ts b/webapp-frontend/src/app/app.module.ts index f249df5c..6255d2ac 100644 --- a/webapp-frontend/src/app/app.module.ts +++ b/webapp-frontend/src/app/app.module.ts @@ -19,10 +19,11 @@ */ import { BrowserModule } from '@angular/platform-browser'; // tslint:disable-next-line:max-line-length -import { MatIconModule, MatCardModule, MatListModule, MatSidenavModule, - MatButtonToggleModule, MatSliderModule, MatGridListModule, MatSlideToggleModule, - MatExpansionModule, MatTabsModule, MatDialogModule, MatFormFieldModule, - MatButtonModule, MatInputModule, MatSnackBarModule} from '@angular/material'; +import {MatButtonModule, MatButtonToggleModule, MatCardModule, MatDialogModule, + MatExpansionModule, MatFormFieldModule, MatGridListModule, MatIconModule, + MatInputModule, MatListModule, MatPaginatorModule, MatProgressSpinnerModule, + MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSnackBarModule, + MatSortModule,MatTableModule, MatTabsModule} from '@angular/material'; import { BrowserAnimationsModule} from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { Ng2SmartTableModule } from 'ng2-smart-table'; @@ -99,9 +100,12 @@ import { ErrorDialogService } from './services/ui/error-dialog.service'; MatSidenavModule, MatSlideToggleModule, MatTabsModule, + MatSortModule, + MatTableModule, MatFormFieldModule, MatButtonModule, MatInputModule, + MatProgressSpinnerModule, Ng2SmartTableModule, MatSnackBarModule, MDBBootstrapModule.forRoot(), diff --git a/webapp-frontend/src/app/catalog/catalog.component.css b/webapp-frontend/src/app/catalog/catalog.component.css index f3454763..00617b6b 100644 --- a/webapp-frontend/src/app/catalog/catalog.component.css +++ b/webapp-frontend/src/app/catalog/catalog.component.css @@ -31,21 +31,24 @@ transform: translate(149 56); } -:host /deep/ ng2-smart-table tbody > tr > td { - text-align: left; +.spinner-container { + height: 360px; + width: 390px; + position: fixed; } -:host /deep/ ng2-smart-table thead th{ - text-align: left; +.spinner-container mat-spinner { + margin: 130px auto 0 auto; } -:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom { - display: inline-block; - width: 50px; - text-align: center; - font-size: 1.1em; +.catalog-table { + width: 99%; + min-height: 150px; + margin-top: 10px; + background-color: transparent; } -:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom:hover { - color: #5dcfe3; +.catalog-button-row button{ + margin-right: 5px; } + diff --git a/webapp-frontend/src/app/catalog/catalog.component.html b/webapp-frontend/src/app/catalog/catalog.component.html index 86e925ef..2379fd43 100644 --- a/webapp-frontend/src/app/catalog/catalog.component.html +++ b/webapp-frontend/src/app/catalog/catalog.component.html @@ -7,9 +7,9 @@ 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. @@ -18,8 +18,44 @@ ========================LICENSE_END=================================== -->
-

xApp Catalog

- - - +

xApp Catalog

+
+ +
+ + + + xApp Name + {{element.name}} + + + + xApp version + {{element.version}} + + + + Status + {{element.status}} + + + + Action + +
+ + +
+
+
+ + + +
diff --git a/webapp-frontend/src/app/catalog/catalog.component.ts b/webapp-frontend/src/app/catalog/catalog.component.ts index fd28f0a3..96e040e2 100644 --- a/webapp-frontend/src/app/catalog/catalog.component.ts +++ b/webapp-frontend/src/app/catalog/catalog.component.ts @@ -17,65 +17,44 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit } from '@angular/core'; -import { LocalDataSource } from 'ng2-smart-table'; +import { Component, OnInit} from '@angular/core'; import { XappMgrService } from '../services/xapp-mgr/xapp-mgr.service'; import { ConfirmDialogService } from './../services/ui/confirm-dialog.service' import { NotificationService } from './../services/ui/notification.service' -import { XMXapp } from '../interfaces/xapp-mgr.types'; +import { ErrorDialogService } from '../services/ui/error-dialog.service'; +import { CatalogDataSource } from './catalog.datasource'; @Component({ selector: 'app-catalog', templateUrl: './catalog.component.html', - styleUrls: ['./catalog.component.css'] + styleUrls: ['./catalog.component.css'], }) export class CatalogComponent implements OnInit{ - settings = { - hideSubHeader: true, - actions: { - columnTitle: 'Actions', - add: false, - edit: false, - delete: false, - custom: [ - { name: 'deployxApp', title: 'Deploy' }, - ], - position: 'right' - - }, - columns: { - name: { - title: 'xApp Name', - type: 'string', - }, - version: { - title: 'xApp Version', - type: 'string', - }, - status: { - title: 'Status', - type: 'string', - }, - }, - }; - - source: LocalDataSource = new LocalDataSource(); + displayedColumns: string[] = ['name', 'version', 'status', 'action']; + dataSource: CatalogDataSource; constructor( private xappMgrSvc: XappMgrService, private confirmDialogService: ConfirmDialogService, + private errorService: ErrorDialogService, private notification: NotificationService) { } ngOnInit() { - this.xappMgrSvc.getAll().subscribe((xapps: XMXapp[]) => this.source.load(xapps)); + this.dataSource = new CatalogDataSource(this.xappMgrSvc); + this.dataSource.loadTable(); + } + + onConfigurexApp(name: string): void { + const aboutError = 'Not implemented yet'; + this.errorService.displayError(aboutError); } - onDeployxApp(event): void { + onDeployxApp(name: string): void { this.confirmDialogService.openConfirmDialog('Are you sure you want to deploy this xApp?') .afterClosed().subscribe(res => { if (res) { - this.xappMgrSvc.deployXapp(event.data.name).subscribe( + this.xappMgrSvc.deployXapp(name).subscribe( response => { switch (response.status) { case 200: diff --git a/webapp-frontend/src/app/catalog/catalog.datasource.ts b/webapp-frontend/src/app/catalog/catalog.datasource.ts new file mode 100644 index 00000000..6ee6e92f --- /dev/null +++ b/webapp-frontend/src/app/catalog/catalog.datasource.ts @@ -0,0 +1,59 @@ +/*- + * ========================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 { CollectionViewer, DataSource } from '@angular/cdk/collections'; +import { Observable } from 'rxjs/Observable'; +import { catchError, finalize } from 'rxjs/operators'; +import { of } from 'rxjs/observable/of'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { XappMgrService } from '../services/xapp-mgr/xapp-mgr.service'; +import { XMXapp } from '../interfaces/xapp-mgr.types'; + +export class CatalogDataSource extends DataSource { + + private xAppsSubject = new BehaviorSubject([]); + + private loadingSubject = new BehaviorSubject(false); + + public loading$ = this.loadingSubject.asObservable(); + + constructor(private xappMgrSvc: XappMgrService) { + super(); + }; + + loadTable() { + this.loadingSubject.next(true); + this.xappMgrSvc.getAll() + .pipe( + catchError(() => of([])), + finalize(() => this.loadingSubject.next(false)) + ) + .subscribe(xApps => this.xAppsSubject.next(xApps) ) + } + + connect(collectionViewer: CollectionViewer): Observable { + return this.xAppsSubject.asObservable(); + } + + disconnect(collectionViewer: CollectionViewer): void { + this.xAppsSubject.complete(); + this.loadingSubject.complete(); + } +} diff --git a/webapp-frontend/src/app/control/control.animations.ts b/webapp-frontend/src/app/control/control.animations.ts new file mode 100644 index 00000000..aa92a57c --- /dev/null +++ b/webapp-frontend/src/app/control/control.animations.ts @@ -0,0 +1,28 @@ +/*- + * ========================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 { animate, state, style, transition, trigger } from '@angular/animations'; + +export const ControlAnimations = { + messageTrigger: trigger('messageExpand', [ + state('collapsed', style({ height: '0px', minHeight: '0', display: 'none' })), + state('expanded', style({ height: '*' })), + ]) +} \ No newline at end of file diff --git a/webapp-frontend/src/app/control/control.component.css b/webapp-frontend/src/app/control/control.component.css index 798e94d3..e589e3e2 100644 --- a/webapp-frontend/src/app/control/control.component.css +++ b/webapp-frontend/src/app/control/control.component.css @@ -32,21 +32,23 @@ transform: translate(149 56); } -:host /deep/ ng2-smart-table tbody > tr > td{ - text-align: left; +.spinner-container { + height: 360px; + width: 390px; + position: fixed; } -:host /deep/ ng2-smart-table thead th{ - text-align: left; +.spinner-container mat-spinner { + margin: 130px auto 0 auto; } -:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom { - display: inline-block; - width: 50px; - text-align: center; - font-size: 1.1em; +.control-table { + width: 99%; + min-height: 150px; + margin-top: 10px; + background-color: transparent; } -:host /deep/ i.material-icons.red-close { - color: red !important; -} \ No newline at end of file +tr.message-row { + height: 0; +} diff --git a/webapp-frontend/src/app/control/control.component.html b/webapp-frontend/src/app/control/control.component.html index 0ae71ac6..d29191cc 100644 --- a/webapp-frontend/src/app/control/control.component.html +++ b/webapp-frontend/src/app/control/control.component.html @@ -7,9 +7,9 @@ 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. @@ -18,8 +18,75 @@ ========================LICENSE_END=================================== -->
-

xApp Control

- - - +

xApp Control

+
+ +
+ + + + xApp Name + {{element.xapp}} + + + + Instance Name + {{element.instance.name}} + + + + Status + {{element.instance.status}} + + + + IP + {{element.instance.ip}} + + + + Port + {{element.instance.port}} + + + + Action + + + + + + + + + + + + + +
+
+
+ txMessages: +
+
  • + {{rxmessage}} +
  • +
    + rxMessages: +
    +
  • + {{txmessage}} +
  • +
    +
    diff --git a/webapp-frontend/src/app/control/control.component.ts b/webapp-frontend/src/app/control/control.component.ts index 067077ed..54ce96d4 100644 --- a/webapp-frontend/src/app/control/control.component.ts +++ b/webapp-frontend/src/app/control/control.component.ts @@ -17,70 +17,26 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { LocalDataSource } from 'ng2-smart-table'; +import { Component, OnInit } from '@angular/core'; import { XappMgrService } from '../services/xapp-mgr/xapp-mgr.service'; import { Router } from '@angular/router'; import { ConfirmDialogService } from './../services/ui/confirm-dialog.service' import { NotificationService } from './../services/ui/notification.service' import { XMXapp } from '../interfaces/xapp-mgr.types'; +import { ControlAnimations } from './control.animations'; +import { ControlDataSource } from './control.datasource'; @Component({ selector: 'app-control', templateUrl: './control.component.html', styleUrls: ['./control.component.css'], - encapsulation: ViewEncapsulation.Emulated, + animations: [ControlAnimations.messageTrigger], }) -export class ControlComponent implements OnInit { +export class ControlComponent implements OnInit { - settings = { - hideSubHeader: true, - actions: { - columnTitle: 'Actions', - add: false, - edit: false, - delete: false, - custom: [ - { name: 'view', title: 'visibility', }, - { name: 'undeploy', title: 'close', }, - ], - position: 'right' - - }, - columns: { - xapp: { - title: 'xApp Name', - type: 'string', - }, - name: { - title: 'Instance Name', - type: 'string', - }, - status: { - title: 'Status', - type: 'string', - }, - ip: { - title: 'IP', - type: 'string', - }, - port: { - title: 'Port', - type: 'integer', - }, - txMessages: { - title: 'txMessages', - type: 'array', - }, - rxMessages: { - title: 'rxMessages', - type: 'array', - }, - }, - }; - - source: LocalDataSource = new LocalDataSource(); + displayedColumns: string[] = ['xapp', 'name', 'status', 'ip', 'port', 'action']; + dataSource: ControlDataSource; constructor( private xappMgrSvc: XappMgrService, @@ -89,32 +45,22 @@ export class ControlComponent implements OnInit { private notification: NotificationService) { } ngOnInit() { - this.xappMgrSvc.getAll().subscribe((xapps: XMXapp[]) => this.source.load(this.getInstance(xapps))); + this.dataSource = new ControlDataSource(this.xappMgrSvc); + this.dataSource.loadTable(); } - onxAppControlAction(event) { - switch (event.action) { - case 'view': - this.view(event); - break; - case 'undeploy': - this.undeploy(event); - break; - } - } - - view(event): void { + view(): void { const url = '/xapp'; - this.router.navigate([url, event]); + this.router.navigate([url]); } - undeploy(event): void { + undeploy(name: string): void { this.confirmDialogService.openConfirmDialog('Are you sure you want to undeploy this xApp ?') .afterClosed().subscribe(res => { if (res) { - this.xappMgrSvc.undeployXapp(event.data.xapp).subscribe( + this.xappMgrSvc.undeployXapp(name).subscribe( response => { - this.xappMgrSvc.getAll().subscribe((xapps: XMXapp[]) => this.source.load(this.getInstance(xapps))); + this.dataSource.loadTable(); switch (response.status) { case 200: this.notification.success('xApp undeployed successfully!'); @@ -128,19 +74,6 @@ export class ControlComponent implements OnInit { }); } - getInstance(allxappdata: XMXapp[]) { - const xAppInstances = []; - for (const xappindex in allxappdata) { - const instancelist = allxappdata[xappindex].instances; - for (const instanceindex in instancelist) { - var instance: any; - instance = instancelist[instanceindex]; - instance.xapp = allxappdata[xappindex].name; - xAppInstances.push(instance); - } - } - return xAppInstances; - } } diff --git a/webapp-frontend/src/app/control/control.datasource.ts b/webapp-frontend/src/app/control/control.datasource.ts new file mode 100644 index 00000000..833a4f06 --- /dev/null +++ b/webapp-frontend/src/app/control/control.datasource.ts @@ -0,0 +1,74 @@ +/*- + * ========================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 { CollectionViewer, DataSource } from '@angular/cdk/collections'; +import { Observable } from 'rxjs/Observable'; +import { catchError, finalize } from 'rxjs/operators'; +import { of } from 'rxjs/observable/of'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { XappMgrService } from '../services/xapp-mgr/xapp-mgr.service'; +import { XMXapp, XappControlRow } from '../interfaces/xapp-mgr.types'; + +export class ControlDataSource extends DataSource { + + private xAppInstancesSubject = new BehaviorSubject([]); + + private loadingSubject = new BehaviorSubject(false); + + public loading$ = this.loadingSubject.asObservable(); + + constructor(private xappMgrSvc: XappMgrService) { + super(); + }; + + loadTable() { + this.loadingSubject.next(true); + this.xappMgrSvc.getAll() + .pipe( + catchError(() => of([])), + finalize(() => this.loadingSubject.next(false)) + ) + .subscribe(xApps => this.xAppInstancesSubject.next(this.getInstance(xApps)) ) + } + + connect(collectionViewer: CollectionViewer): Observable { + return this.xAppInstancesSubject.asObservable(); + } + + disconnect(collectionViewer: CollectionViewer): void { + this.xAppInstancesSubject.complete(); + this.loadingSubject.complete(); + } + + getInstance(allxappdata: XMXapp[]) { + const xAppInstances: XappControlRow[]= []; + for (const xappindex in allxappdata) { + const instancelist = allxappdata[xappindex].instances; + for (const instanceindex in instancelist) { + var instance: XappControlRow = { + xapp: allxappdata[xappindex].name, + instance: instancelist[instanceindex] + } + xAppInstances.push(instance); + } + } + return xAppInstances; + } +} diff --git a/webapp-frontend/src/app/interfaces/xapp-mgr.types.ts b/webapp-frontend/src/app/interfaces/xapp-mgr.types.ts index 999ddb33..7654377f 100644 --- a/webapp-frontend/src/app/interfaces/xapp-mgr.types.ts +++ b/webapp-frontend/src/app/interfaces/xapp-mgr.types.ts @@ -47,3 +47,8 @@ export interface XMXapp { version: string; instances: Array; } + +export interface XappControlRow { + xapp: string; + instance: XMXappInstance; +} \ No newline at end of file diff --git a/webapp-frontend/src/app/services/xapp-mgr/xapp-mgr.service.ts b/webapp-frontend/src/app/services/xapp-mgr/xapp-mgr.service.ts index daef3e07..13ae13db 100644 --- a/webapp-frontend/src/app/services/xapp-mgr/xapp-mgr.service.ts +++ b/webapp-frontend/src/app/services/xapp-mgr/xapp-mgr.service.ts @@ -32,8 +32,9 @@ export class XappMgrService { private basePath = 'api/xappmgr/xapps'; - getAll(){ - return this.httpClient.get(this.basePath); + getAll(): Observable{ + return this.httpClient.get(this.basePath) + } deployXapp(name: string) { -- 2.16.6