2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property
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 { HttpErrorResponse, HttpResponse } from '@angular/common/http';
22 import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
23 import { MatSort } from '@angular/material/sort';
24 import { MatDialog } from '@angular/material/dialog';
25 import { fromEvent } from 'rxjs/observable/fromEvent';
26 import { debounceTime, distinctUntilChanged, finalize, tap } from 'rxjs/operators';
27 import { ANRNeighborCellRelation } from '../interfaces/anr-xapp.types';
28 import { ANRXappService } from '../services/anr-xapp/anr-xapp.service';
29 import { ErrorDialogService } from '../services/ui/error-dialog.service';
30 import { LoadingDialogService } from '../services/ui/loading-dialog.service';
31 import { ConfirmDialogService } from './../services/ui/confirm-dialog.service';
32 import { NotificationService } from './../services/ui/notification.service';
33 import { AnrEditNcrDialogComponent } from './anr-edit-ncr-dialog.component';
34 import { ANRXappDataSource } from './anr-xapp.datasource';
35 import { UiService } from '../services/ui/ui.service';
39 templateUrl: './anr-xapp.component.html',
40 styleUrls: ['./anr-xapp.component.scss']
42 export class AnrXappComponent implements AfterViewInit, OnInit {
45 panelClass: string = "";
46 dataSource: ANRXappDataSource;
48 @ViewChild('ggNodeB', { static: true }) ggNodeB: ElementRef;
49 @ViewChild('servingCellNrcgi', { static: true }) servingCellNrcgi: ElementRef;
50 @ViewChild('neighborCellNrpci', { static: true }) neighborCellNrpci: ElementRef;
51 @ViewChild(MatSort, { static: true }) sort: MatSort;
53 displayedColumns = ['cellIdentifierNrcgi', 'neighborCellNrpci', 'neighborCellNrcgi',
54 'flagNoHo', 'flagNoXn', 'flagNoRemove', 'action'];
57 private anrXappService: ANRXappService,
58 private dialog: MatDialog,
59 private confirmDialogService: ConfirmDialogService,
60 private errorDialogService: ErrorDialogService,
61 private loadingDialogService: LoadingDialogService,
62 private notificationService: NotificationService,
63 public ui: UiService) { }
66 this.dataSource = new ANRXappDataSource(this.anrXappService, this.sort, this.notificationService);
67 this.dataSource.loadTable();
68 // Empty string occurs first in the array of gNodeBIds
69 this.anrXappService.getgNodeBs().subscribe((res: string[]) => this.gNodeBIds = res);
70 this.ui.darkModeState.subscribe((isDark) => {
71 this.darkMode = isDark;
76 // the selector event calls loadNcrtPage() directly.
77 fromEvent(this.servingCellNrcgi.nativeElement, 'keyup')
80 distinctUntilChanged(),
86 fromEvent(this.neighborCellNrpci.nativeElement, 'keyup')
89 distinctUntilChanged(),
98 this.dataSource.loadTable(
99 this.ggNodeB.nativeElement.value,
100 this.servingCellNrcgi.nativeElement.value,
101 this.neighborCellNrpci.nativeElement.value);
104 modifyNcr(ncr: ANRNeighborCellRelation): void {
106 this.panelClass = "dark-theme";
108 this.panelClass = "";
110 const dialogRef = this.dialog.open(AnrEditNcrDialogComponent, {
111 panelClass: this.panelClass,
115 dialogRef.afterClosed().subscribe(
122 deleteNcr(ncr: ANRNeighborCellRelation): void {
123 this.confirmDialogService
124 .openConfirmDialog('Are you sure you want to delete this relation?')
125 .afterClosed().subscribe(
128 this.loadingDialogService.startLoading("Deleting");
129 this.anrXappService.deleteNcr(ncr.servingCellNrcgi, ncr.neighborCellNrpci)
131 finalize(() => this.loadingDialogService.stopLoading())
134 (response: HttpResponse<Object>) => {
135 switch (response.status) {
137 this.notificationService.success('Delete succeeded!');
141 this.notificationService.warn('Delete failed.');
144 (error: HttpErrorResponse) => {
145 this.errorDialogService.displayError(error.message);