From b41447eecc802f21deba94b647f4d87040d41829 Mon Sep 17 00:00:00 2001 From: jh245g Date: Fri, 31 May 2019 12:02:06 -0400 Subject: [PATCH] Add column sorting on ANR page Issue-ID: RICPLT-1344 Signed-off-by: Jun (Nicolas) Hu Change-Id: I33ecdb823367d66b9e648464733ba60794bab2c2 --- docs/release-notes.rst | 2 +- .../src/app/anr-xapp/anr-xapp.component.html | 14 ++++---- .../src/app/anr-xapp/anr-xapp.component.ts | 10 +++--- .../src/app/anr-xapp/anr-xapp.datasource.ts | 41 +++++++++++++++++++--- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index c50e4cc3..71b23a66 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -24,7 +24,7 @@ Version 1.0.4, 30 May 2019 -------------------------- * Add ANR xApp neighbor cell relation table * Drop the pendulum xApp control screen -* Add column sorting on xApp catalog and xApp control +* Add column sorting on xApp catalog, xApp control, ANR * Add disconnect-all button to RAN connection screen Version 1.0.3, 28 May 2019 diff --git a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.html b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.html index a245b2de..49182f2e 100644 --- a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.html +++ b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.html @@ -39,35 +39,35 @@ - +
- Serving Cell NRCGI + Serving Cell NRCGI {{ncr.servingCellNrcgi}} - Neighbor Cell NRPCI + Neighbor Cell NRPCI {{ncr.neighborCellNrpci}} - Neighbor Cell NRCGI + Neighbor Cell NRCGI {{ncr.neighborCellNrcgi}} - Flag No Handover + Flag No Handover {{ncr.flagNoHo}} - Flag No Xn + Flag No Xn {{ncr.flagNoXn}} - Flag No Remove + Flag No Remove {{ncr.flagNoRemove}} 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 d173505b..c3f3cb83 100644 --- a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts +++ b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts @@ -19,16 +19,17 @@ */ 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 { ANRNeighborCellRelation } from '../interfaces/anr-xapp.types'; -import { ANRXappDataSource } from './anr-xapp.datasource'; import { ANRXappService } from '../services/anr-xapp/anr-xapp.service'; -import { ANREditNCRDialogComponent } from './anr-edit-ncr-dialog.component'; -import { ConfirmDialogService } from './../services/ui/confirm-dialog.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 { ANREditNCRDialogComponent } from './anr-edit-ncr-dialog.component'; +import { ANRXappDataSource } from './anr-xapp.datasource'; @Component({ selector: 'app-anr', @@ -43,6 +44,7 @@ export class AnrXappComponent implements AfterViewInit, OnInit { @ViewChild('ggNodeB') ggNodeB: ElementRef; @ViewChild('servingCellNrcgi') servingCellNrcgi: ElementRef; @ViewChild('neighborCellNrpci') neighborCellNrpci: ElementRef; + @ViewChild(MatSort) sort: MatSort; displayedColumns = ['cellIdentifierNrcgi', 'neighborCellNrpci', 'neighborCellNrcgi', 'flagNoHo', 'flagNoXn', 'flagNoRemove', 'action']; @@ -55,7 +57,7 @@ export class AnrXappComponent implements AfterViewInit, OnInit { private notificationService: NotificationService) { } ngOnInit() { - this.dataSource = new ANRXappDataSource(this.anrXappService); + this.dataSource = new ANRXappDataSource(this.anrXappService, this.sort); this.dataSource.loadTable(); // Empty string occurs first in the array of gNodeBIds this.anrXappService.getgNodeBs().subscribe((res: string[]) => this.gNodeBIds = res); diff --git a/webapp-frontend/src/app/anr-xapp/anr-xapp.datasource.ts b/webapp-frontend/src/app/anr-xapp/anr-xapp.datasource.ts index bca766c6..bc04b6b0 100644 --- a/webapp-frontend/src/app/anr-xapp/anr-xapp.datasource.ts +++ b/webapp-frontend/src/app/anr-xapp/anr-xapp.datasource.ts @@ -18,11 +18,13 @@ * ========================LICENSE_END=================================== */ -import { CollectionViewer, DataSource} from '@angular/cdk/collections'; +import { CollectionViewer, DataSource } from '@angular/cdk/collections'; +import { MatSort } from '@angular/material'; +import { merge } from 'rxjs'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { Observable } from 'rxjs/Observable'; -import { catchError, finalize } from 'rxjs/operators'; import { of } from 'rxjs/observable/of'; -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { catchError, finalize, map } from 'rxjs/operators'; import { ANRNeighborCellRelation } from '../interfaces/anr-xapp.types'; import { ANRXappService } from '../services/anr-xapp/anr-xapp.service'; @@ -35,7 +37,7 @@ export class ANRXappDataSource extends DataSource { public loading$ = this.loadingSubject.asObservable(); - constructor(private anrXappService: ANRXappService) { + constructor(private anrXappService: ANRXappService, private sort: MatSort) { super(); } @@ -50,7 +52,13 @@ export class ANRXappDataSource extends DataSource { } connect(collectionViewer: CollectionViewer): Observable { - return this.relationsSubject.asObservable(); + const dataMutations = [ + this.relationsSubject.asObservable(), + this.sort.sortChange + ]; + return merge(...dataMutations).pipe(map(() => { + return this.getSortedData([...this.relationsSubject.getValue()]); + })); } disconnect(collectionViewer: CollectionViewer): void { @@ -58,4 +66,27 @@ export class ANRXappDataSource extends DataSource { this.loadingSubject.complete(); } + private getSortedData(data: ANRNeighborCellRelation[]) { + if (!this.sort.active || this.sort.direction === '') { + return data; + } + + return data.sort((a, b) => { + const isAsc = this.sort.direction === 'asc'; + switch (this.sort.active) { + case 'cellIdentifierNrcgi': return compare(a.servingCellNrcgi, b.servingCellNrcgi, isAsc); + case 'neighborCellNrpci': return compare(a.neighborCellNrpci, b.neighborCellNrpci, isAsc); + case 'neighborCellNrcgi': return compare(a.neighborCellNrcgi, b.neighborCellNrcgi, isAsc); + case 'flagNoHo': return compare(a.flagNoHo, b.flagNoHo, isAsc); + case 'flagNoXn': return compare(a.flagNoXn, b.flagNoXn, isAsc); + case 'flagNoRemove': return compare(a.flagNoRemove, b.flagNoRemove, isAsc); + default: return 0; + } + }); + } + +} + +function compare(a, b, isAsc) { + return (a < b ? -1 : 1) * (isAsc ? 1 : -1); } -- 2.16.6