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 { MatSort } from '@angular/material';
23 import { MatDialog } from '@angular/material/dialog';
24 import { fromEvent } from 'rxjs/observable/fromEvent';
25 import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
26 import { ANRNeighborCellRelation } from '../interfaces/anr-xapp.types';
27 import { ANRXappService } from '../services/anr-xapp/anr-xapp.service';
28 import { ErrorDialogService } from '../services/ui/error-dialog.service';
29 import { ConfirmDialogService } from './../services/ui/confirm-dialog.service';
30 import { NotificationService } from './../services/ui/notification.service';
31 import { ANREditNCRDialogComponent } from './anr-edit-ncr-dialog.component';
32 import { ANRXappDataSource } from './anr-xapp.datasource';
36 templateUrl: './anr-xapp.component.html',
37 styleUrls: ['./anr-xapp.component.scss']
39 export class AnrXappComponent implements AfterViewInit, OnInit {
41 dataSource: ANRXappDataSource;
42 anrClientVersion: string;
44 @ViewChild('ggNodeB') ggNodeB: ElementRef;
45 @ViewChild('servingCellNrcgi') servingCellNrcgi: ElementRef;
46 @ViewChild('neighborCellNrpci') neighborCellNrpci: ElementRef;
47 @ViewChild(MatSort) sort: MatSort;
49 displayedColumns = ['cellIdentifierNrcgi', 'neighborCellNrpci', 'neighborCellNrcgi',
50 'flagNoHo', 'flagNoXn', 'flagNoRemove', 'action'];
53 private anrXappService: ANRXappService,
54 private dialog: MatDialog,
55 private confirmDialogService: ConfirmDialogService,
56 private errorDialogService: ErrorDialogService,
57 private notificationService: NotificationService) { }
60 this.dataSource = new ANRXappDataSource(this.anrXappService, this.sort);
61 this.dataSource.loadTable();
62 // Empty string occurs first in the array of gNodeBIds
63 this.anrXappService.getgNodeBs().subscribe((res: string[]) => this.gNodeBIds = res);
64 this.anrXappService.getVersion().subscribe((res: string) => this.anrClientVersion = res);
68 // the selector event calls loadNcrtPage() directly.
69 fromEvent(this.servingCellNrcgi.nativeElement, 'keyup')
72 distinctUntilChanged(),
78 fromEvent(this.neighborCellNrpci.nativeElement, 'keyup')
81 distinctUntilChanged(),
90 this.dataSource.loadTable(
91 this.ggNodeB.nativeElement.value,
92 this.servingCellNrcgi.nativeElement.value,
93 this.neighborCellNrpci.nativeElement.value);
96 modifyNcr(ncr: ANRNeighborCellRelation): void {
97 const dialogRef = this.dialog.open(ANREditNCRDialogComponent, {
101 dialogRef.afterClosed().subscribe(result => {
106 deleteNcr(ncr: ANRNeighborCellRelation): void {
107 this.confirmDialogService
108 .openConfirmDialog('Are you sure you want to delete this relation?')
109 .afterClosed().subscribe(res => {
111 this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci)
114 switch (response.status) {
116 this.notificationService.success('Delete succeeded!');
119 this.notificationService.warn('Delete failed.');
123 this.errorDialogService.displayError(error.message);