2 // ========================LICENSE_START=================================
5 // Copyright (C) 2021: Nordix Foundation
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 { Component, Input, OnInit, Output } from "@angular/core";
30 } from "@angular/forms";
31 import { EventEmitter } from "@angular/core";
32 import { Rics } from "src/app/interfaces/ric";
33 import { PolicyService } from "src/app/services/policy/policy.service";
34 import { MatSelectChange } from "@angular/material/select";
37 selector: "nrcp-ric-selector",
38 templateUrl: "./ric-selector.component.html",
39 styleUrls: ["./ric-selector.component.scss"],
41 { provide: ControlContainer, useExisting: FormGroupDirective },
44 export class RicSelectorComponent implements OnInit {
45 @Input() policyTypeName: string = "";
46 @Output() selectedRic: EventEmitter<string> = new EventEmitter<string>();
49 instanceForm: FormGroup = new FormGroup({
50 ricSelector: new FormControl(this.ric, [Validators.required]),
52 allRics: string[] = [];
55 private dataService: PolicyService,
56 private formBuilder: FormBuilder
60 console.log("Ric:", this.ric);
64 onRicChanged(newvalue: MatSelectChange): void {
65 this.selectedRic.emit(newvalue.value);
68 get ricSelector(): AbstractControl {
69 return this.instanceForm.get("ricSelector");
73 console.log("fetchRics ", this.policyTypeName);
74 const self: RicSelectorComponent = this;
75 this.dataService.getRics(this.policyTypeName).subscribe({
77 value.rics.forEach((ric) => {
78 self.allRics.push(ric.ric_id);