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";
29 } from "@angular/forms";
30 import { EventEmitter } from "@angular/core";
31 import { Rics } from "@interfaces/ric";
32 import { PolicyService } from "@services/policy/policy.service";
33 import { MatSelectChange } from "@angular/material/select";
36 selector: "nrcp-ric-selector",
37 templateUrl: "./ric-selector.component.html",
38 styleUrls: ["./ric-selector.component.scss"],
40 { provide: ControlContainer, useExisting: FormGroupDirective },
43 export class RicSelectorComponent implements OnInit {
44 @Input() policyTypeName: string = "";
45 @Output() selectedRic: EventEmitter<string> = new EventEmitter<string>();
48 instanceForm: FormGroup = new FormGroup({
49 ricSelector: new FormControl(this.ric, [Validators.required]),
51 allRics: string[] = [];
53 constructor(private dataService: PolicyService) {}
59 onRicChanged(newvalue: MatSelectChange): void {
60 this.selectedRic.emit(newvalue.value);
63 get ricSelector(): AbstractControl {
64 return this.instanceForm.get("ricSelector");
68 if (!this.policyTypeName) this.policyTypeName = "";
69 console.log("fetchRics ", this.policyTypeName);
70 const self: RicSelectorComponent = this;
71 this.dataService.getRics(this.policyTypeName).subscribe({
73 value.rics.forEach((ric) => {
74 self.allRics.push(ric.ric_id);