X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fanr-xapp%2Fanr-xapp.component.ts;h=d173505b90bd91bdf34de32edcef7a08a5258067;hb=29ce34b03e4099786f14cd7fc5473305da8750d6;hp=efe0992cedec94c966a27cd859334469845856b6;hpb=6ca7894a0bb7717740dd785ddfe613c85a25e2b7;p=portal%2Fric-dashboard.git 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 efe0992c..d173505b 100644 --- a/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts +++ b/webapp-frontend/src/app/anr-xapp/anr-xapp.component.ts @@ -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. @@ -17,18 +17,111 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit } from '@angular/core'; + +import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +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 { NotificationService } from './../services/ui/notification.service'; @Component({ - selector: 'app-anr-xapp', + selector: 'app-anr', templateUrl: './anr-xapp.component.html', styleUrls: ['./anr-xapp.component.scss'] }) -export class AnrXappComponent implements OnInit { +export class AnrXappComponent implements AfterViewInit, OnInit { + + dataSource: ANRXappDataSource; + anrClientVersion: string; + gNodeBIds: string[]; + @ViewChild('ggNodeB') ggNodeB: ElementRef; + @ViewChild('servingCellNrcgi') servingCellNrcgi: ElementRef; + @ViewChild('neighborCellNrpci') neighborCellNrpci: ElementRef; + + displayedColumns = ['cellIdentifierNrcgi', 'neighborCellNrpci', 'neighborCellNrcgi', + 'flagNoHo', 'flagNoXn', 'flagNoRemove', 'action']; - constructor() { } + constructor( + private anrXappService: ANRXappService, + private dialog: MatDialog, + private confirmDialogService: ConfirmDialogService, + private errorDialogService: ErrorDialogService, + private notificationService: NotificationService) { } ngOnInit() { + this.dataSource = new ANRXappDataSource(this.anrXappService); + this.dataSource.loadTable(); + // Empty string occurs first in the array of gNodeBIds + this.anrXappService.getgNodeBs().subscribe((res: string[]) => this.gNodeBIds = res); + this.anrXappService.getVersion().subscribe((res: string) => this.anrClientVersion = res); + } + + ngAfterViewInit() { + // the selector event calls loadNcrtPage() directly. + fromEvent(this.servingCellNrcgi.nativeElement, 'keyup') + .pipe( + debounceTime(150), + distinctUntilChanged(), + tap(() => { + this.loadNcrtPage(); + }) + ) + .subscribe(); + fromEvent(this.neighborCellNrpci.nativeElement, 'keyup') + .pipe( + debounceTime(150), + distinctUntilChanged(), + tap(() => { + this.loadNcrtPage(); + }) + ) + .subscribe(); + } + + loadNcrtPage() { + this.dataSource.loadTable( + this.ggNodeB.nativeElement.value, + this.servingCellNrcgi.nativeElement.value, + this.neighborCellNrpci.nativeElement.value); + } + + modifyNcr(ncr: ANRNeighborCellRelation): void { + const dialogRef = this.dialog.open(ANREditNCRDialogComponent, { + width: '300px', + data: ncr + }); + dialogRef.afterClosed().subscribe(result => { + this.loadNcrtPage(); + }); + } + + deleteNcr(ncr: ANRNeighborCellRelation): void { + this.confirmDialogService + .openConfirmDialog('Are you sure you want to delete this relation?') + .afterClosed().subscribe(res => { + if (res) { + this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci) + .subscribe( + response => { + switch (response.status) { + case 200: + this.notificationService.success('Delete succeeded!'); + break; + default: + this.notificationService.warn('Delete failed.'); + } + }, + error => { + this.errorDialogService.displayError(error.message); + }); + } + }); } }