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 } from "@angular/core";
30 } from "@angular/forms";
31 import { Rics } from "src/app/interfaces/ric";
32 import { PolicyService } from "src/app/services/policy/policy.service";
35 selector: "nrcp-ric-selector",
36 templateUrl: "./ric-selector.component.html",
37 styleUrls: ["./ric-selector.component.scss"],
39 { provide: ControlContainer, useExisting: FormGroupDirective },
42 export class RicSelectorComponent implements OnInit {
43 @Input() instanceForm: FormGroup;
44 @Input() policyTypeName: string = "";
46 allRics: string[] = [];
49 private dataService: PolicyService,
50 private formBuilder: FormBuilder
54 this.instanceForm.addControl(
56 new FormControl(this.ric, [Validators.required])
59 console.log("Ric:", this.ric);
63 get selectedRic(): string {
67 get ricSelector(): AbstractControl {
68 return this.instanceForm.get("ricSelector");
72 console.log("fetchRics ", this.policyTypeName);
73 const self: RicSelectorComponent = this;
74 this.dataService.getRics(this.policyTypeName).subscribe({
76 value.rics.forEach((ric) => {
77 self.allRics.push(ric.ric_id);