2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property and Nokia
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
22 import { MatDialog } from '@angular/material/dialog';
23 import { fromEvent } from 'rxjs/observable/fromEvent';
24 import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
25 import { ANRNeighborCellRelation } from '../interfaces/anr-xapp.types';
26 import { ANRXappDataSource } from './anr-xapp.datasource';
27 import { ANRXappService } from '../services/anr-xapp/anr-xapp.service';
28 import { ANREditNCRDialogComponent } from './anr-edit-ncr-dialog.component';
29 import { ConfirmDialogService } from './../services/ui/confirm-dialog.service';
30 import { ErrorDialogService } from '../services/ui/error-dialog.service';
31 import { NotificationService } from './../services/ui/notification.service';
35 templateUrl: './anr-xapp.component.html',
36 styleUrls: ['./anr-xapp.component.scss']
38 export class AnrXappComponent implements AfterViewInit, OnInit {
40 dataSource: ANRXappDataSource;
41 anrClientVersion: string;
43 @ViewChild('ggNodeB') ggNodeB: ElementRef;
44 @ViewChild('servingCellNrcgi') servingCellNrcgi: ElementRef;
45 @ViewChild('neighborCellNrpci') neighborCellNrpci: ElementRef;
47 displayedColumns = ['cellIdentifierNrcgi', 'neighborCellNrpci', 'neighborCellNrcgi',
48 'flagNoHo', 'flagNoXn', 'flagNoRemove', 'action'];
51 private anrXappService: ANRXappService,
52 private dialog: MatDialog,
53 private confirmDialogService: ConfirmDialogService,
54 private errorDialogService: ErrorDialogService,
55 private notificationService: NotificationService) { }
58 this.dataSource = new ANRXappDataSource(this.anrXappService);
59 this.dataSource.loadTable();
60 // Empty string occurs first in the array of gNodeBIds
61 this.anrXappService.getgNodeBs().subscribe((res: string[]) => this.gNodeBIds = res);
62 this.anrXappService.getVersion().subscribe((res: string) => this.anrClientVersion = res);
66 // the selector event calls loadNcrtPage() directly.
67 fromEvent(this.servingCellNrcgi.nativeElement, 'keyup')
70 distinctUntilChanged(),
76 fromEvent(this.neighborCellNrpci.nativeElement, 'keyup')
79 distinctUntilChanged(),
88 this.dataSource.loadTable(
89 this.ggNodeB.nativeElement.value,
90 this.servingCellNrcgi.nativeElement.value,
91 this.neighborCellNrpci.nativeElement.value);
94 modifyNcr(ncr: ANRNeighborCellRelation): void {
95 const dialogRef = this.dialog.open(ANREditNCRDialogComponent, {
99 dialogRef.afterClosed().subscribe(result => {
104 deleteNcr(ncr: ANRNeighborCellRelation): void {
105 this.confirmDialogService
106 .openConfirmDialog('Are you sure you want to delete this relation?')
107 .afterClosed().subscribe(res => {
109 this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci)
112 switch (response.status) {
114 this.notificationService.success('Delete succeeded!');
117 this.notificationService.warn('Delete failed.');
121 this.errorDialogService.displayError(error.message);