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===================================
20 import { Component, OnInit, Inject } from '@angular/core';
21 import { FormGroup, FormControl, Validators } from '@angular/forms';
22 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
23 import { ANRXappService } from '../services/anr-xapp/anr-xapp.service';
24 import { ErrorDialogService } from '../services/ui/error-dialog.service';
25 import { ANRNeighborCellRelation, ANRNeighborCellRelationMod } from '../interfaces/anr-xapp.types';
28 selector: 'rd-ncr-edit-dialog',
29 templateUrl: './anr-edit-ncr-dialog.component.html',
30 styleUrls: ['./anr-edit-ncr-dialog.component.scss']
33 export class AnrEditNcrDialogComponent implements OnInit {
35 private ncrDialogForm: FormGroup;
38 private dialogRef: MatDialogRef<AnrEditNcrDialogComponent>,
39 private dataService: ANRXappService,
40 private errorService: ErrorDialogService,
41 @Inject(MAT_DIALOG_DATA) private data: ANRNeighborCellRelation) { }
44 this.ncrDialogForm = new FormGroup({
45 servingCellNrcgi: new FormControl(this.data.servingCellNrcgi), // readonly
46 neighborCellNrpci: new FormControl(this.data.neighborCellNrpci), // readonly
47 neighborCellNrcgi: new FormControl(this.data.neighborCellNrcgi, [Validators.required]),
48 flagNoHo: new FormControl(this.data.flagNoHo),
49 flagNoXn: new FormControl(this.data.flagNoXn),
50 flagNoRemove: new FormControl(this.data.flagNoRemove)
55 this.dialogRef.close();
58 modifyNcr = (ncrFormValue: ANRNeighborCellRelation) => {
59 if (this.ncrDialogForm.valid) {
60 const ncrm = {} as ANRNeighborCellRelationMod;
61 // there must be a better way
62 ncrm.neighborCellNrcgi = ncrFormValue.neighborCellNrcgi;
63 ncrm.neighborCellNrpci = ncrFormValue.neighborCellNrpci;
64 ncrm.flagNoHo = ncrFormValue.flagNoHo;
65 ncrm.flagNoXn = ncrFormValue.flagNoXn;
66 ncrm.flagNoRemove = ncrFormValue.flagNoRemove;
67 this.dataService.modifyNcr(ncrFormValue.servingCellNrcgi, ncrFormValue.neighborCellNrpci, ncrm).subscribe((val: any[]) => { },
69 this.errorService.displayError('NCR update failed: ' + error.message);
72 this.dialogRef.close();
76 hasError(controlName: string, errorName: string) {
77 if (this.ncrDialogForm.controls[controlName].hasError(errorName)) {
83 validateControl(controlName: string) {
84 if (this.ncrDialogForm.controls[controlName].invalid && this.ncrDialogForm.controls[controlName].touched) {