X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fpolicy%2Fric-selector%2Fric-selector.component.ts;h=996d9a092c24e8c0ba058e1790d81bce9c2efe20;hb=042a087cf3eea5e6f941ee9add6e1c50cb106e91;hp=583f02af1da3dffa7d7d52474a0d6360b8156742;hpb=23f01d834cb151beb27ce2da0fe7f7b42b3b3a4d;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/policy/ric-selector/ric-selector.component.ts b/webapp-frontend/src/app/policy/ric-selector/ric-selector.component.ts index 583f02a..996d9a0 100644 --- a/webapp-frontend/src/app/policy/ric-selector/ric-selector.component.ts +++ b/webapp-frontend/src/app/policy/ric-selector/ric-selector.component.ts @@ -1,54 +1,83 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { AbstractControl, ControlContainer, FormBuilder, FormControl, FormGroup, FormGroupDirective, Validators } from '@angular/forms'; -import { Ric, Rics } from 'src/app/interfaces/ric'; -import { PolicyService } from 'src/app/services/policy/policy.service'; +// - +// ========================LICENSE_START================================= +// O-RAN-SC +// %% +// Copyright (C) 2021: Nordix Foundation +// %% +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ========================LICENSE_END=================================== +// / -@Component({ - selector: 'nrcp-ric-selector', - templateUrl: './ric-selector.component.html', - styleUrls: ['./ric-selector.component.scss'], - viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }] +import { Component, Input, OnInit } from "@angular/core"; +import { + AbstractControl, + ControlContainer, + FormBuilder, + FormControl, + FormGroup, + FormGroupDirective, + Validators, +} from "@angular/forms"; +import { Rics } from "src/app/interfaces/ric"; +import { PolicyService } from "src/app/services/policy/policy.service"; +@Component({ + selector: "nrcp-ric-selector", + templateUrl: "./ric-selector.component.html", + styleUrls: ["./ric-selector.component.scss"], + viewProviders: [ + { provide: ControlContainer, useExisting: FormGroupDirective }, + ], }) export class RicSelectorComponent implements OnInit { - @Input() instanceForm: FormGroup; - @Input() policyTypeName: string = ''; + @Input() policyTypeName: string = ""; ric: string; allRics: string[] = []; constructor( private dataService: PolicyService, - private formBuilder: FormBuilder) { - } + private formBuilder: FormBuilder + ) {} ngOnInit(): void { this.instanceForm.addControl( - 'ricSelector', new FormControl(this.ric, [ - Validators.required - ])); + "ricSelector", + new FormControl(this.ric, [Validators.required]) + ); - console.log('Ric:', this.ric); + console.log("Ric:", this.ric); this.fetchRics(); } - get selectedRic(): string { return this.ric; } + get selectedRic(): string { + return this.ric; + } get ricSelector(): AbstractControl { - return this.instanceForm.get('ricSelector'); + return this.instanceForm.get("ricSelector"); } private fetchRics() { - console.log('fetchRics ', this.policyTypeName); + console.log("fetchRics ", this.policyTypeName); const self: RicSelectorComponent = this; - this.dataService.getRics(this.policyTypeName).subscribe( - { - next(value: Rics) { - value.rics.forEach(ric => { - self.allRics.push(ric.ric_id) - }); - console.log(value); - } - }); + this.dataService.getRics(this.policyTypeName).subscribe({ + next(value: Rics) { + value.rics.forEach((ric) => { + self.allRics.push(ric.ric_id); + }); + console.log(value); + }, + }); } }