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===================================
22 import { Component, Input, OnInit } from '@angular/core';
23 import { AbstractControl, ControlContainer, FormBuilder, FormControl, FormGroup, FormGroupDirective, Validators } from '@angular/forms';
24 import { Ric, Rics } from 'src/app/interfaces/ric';
25 import { PolicyService } from 'src/app/services/policy/policy.service';
28 selector: 'nrcp-ric-selector',
29 templateUrl: './ric-selector.component.html',
30 styleUrls: ['./ric-selector.component.scss'],
31 viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }]
34 export class RicSelectorComponent implements OnInit {
36 @Input() instanceForm: FormGroup;
37 @Input() policyTypeName: string = '';
39 allRics: string[] = [];
42 private dataService: PolicyService,
43 private formBuilder: FormBuilder) {
47 this.instanceForm.addControl(
48 'ricSelector', new FormControl(this.ric, [
52 console.log('Ric:', this.ric);
56 get selectedRic(): string { return this.ric; }
58 get ricSelector(): AbstractControl {
59 return this.instanceForm.get('ricSelector');
63 console.log('fetchRics ', this.policyTypeName);
64 const self: RicSelectorComponent = this;
65 this.dataService.getRics(this.policyTypeName).subscribe(
68 value.rics.forEach(ric => {
69 self.allRics.push(ric.ric_id)