NG-UI Bug 1119 - VDU-configuration not supported in primitives execution 80/9380/3
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Fri, 10 Jul 2020 06:40:15 +0000 (12:10 +0530)
committerguzman <jmguzman@whitestack.com>
Tue, 14 Jul 2020 14:13:10 +0000 (16:13 +0200)
 * Added the one more option for the VDU Level Primitive in the select.
 * Checking for the primitives from the key ['VDU-Configuration']['config-primitive'].

Change-Id: Ic1eb0a6fe6c3aa22deda27aca3de00790b86bfbf
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
src/app/instances/ns-primitive/NSPrimitiveComponent.html
src/app/instances/ns-primitive/NSPrimitiveComponent.ts
src/assets/i18n/de.json
src/assets/i18n/en.json
src/assets/i18n/es.json
src/assets/i18n/pt.json
src/models/NSDModel.ts

index 646c8ae..087eac6 100644 (file)
@@ -32,19 +32,27 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
                     [ngModelOptions]="{standalone: true}"></ng-select>
             </div>
         </div>
+        <div class="form-group row" *ngIf="primitiveType === 'VNF_Primitive' || primitiveType === 'VDU_Primitive'">
+            <label class="col-sm-4 col-form-label">VNF {{'MEMBERINDEX' | translate}}*</label>
+            <div class="col-sm-3">
+                <ng-select (change)="indexChange($event, primitiveType)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
+                    [items]="params.memberIndex" bindLabel="member-vnf-index" bindValue="member-vnf-index"
+                    formControlName="vnf_member_index" id="vnf_member_index"
+                    [ngClass]="{ 'is-invalid': submitted && f.vnf_member_index.errors }"></ng-select>
+            </div>
+        </div>
+        <div class="form-group row" *ngIf="primitiveType === 'VDU_Primitive'">
+            <label class="col-sm-4 col-form-label">{{'SELECT' | translate}} VDU *</label>
+            <div class="col-sm-8">
+                <ng-select (change)="getVDUPrimitive($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
+                    [items]="vduList" bindLabel="name" bindValue="id" formControlName="vdu_id" id="vdu_id"
+                    [ngClass]="{ 'is-invalid': submitted && f.vdu_id.errors }"></ng-select>
+            </div>
+        </div>
         <div class="form-group row">
-            <ng-container *ngIf="primitiveType == 'VNF_Primitive'">
-                <label class="col-sm-4 col-form-label">VNF {{'MEMBERINDEX' | translate}}*</label>
-                <div class="col-sm-3">
-                    <ng-select (change)="indexChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
-                        [items]="params.memberIndex" bindLabel="member-vnf-index" bindValue="member-vnf-index"
-                        formControlName="vnf_member_index" id="vnf_member_index"
-                        [ngClass]="{ 'is-invalid': submitted && f.vnf_member_index.errors }"></ng-select>
-                </div>
-            </ng-container>
-            <label [ngClass]="{ 'col-sm-4': primitiveType != 'VNF_Primitive', 'col-sm-2': primitiveType == 'VNF_Primitive' }" class="col-form-label">
+            <label class="col-sm-4 col-form-label">
                 {{'PAGE.NSPRIMITIVE.PRIMITIVE' | translate}}*</label>
-            <div [ngClass]="{ 'col-sm-8': primitiveType != 'VNF_Primitive', 'col-sm-3': primitiveType == 'VNF_Primitive' }" class="col-sm-3">
+            <div class="col-sm-8">
                 <ng-select (change)="primitiveChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
                     [items]="primitiveList" bindLabel="name" bindValue="name" formControlName="primitive" id="primitive"
                     [ngClass]="{ 'is-invalid': submitted && f.primitive.errors }"></ng-select>
index 02269d3..4b9616b 100644 (file)
@@ -26,7 +26,7 @@ import { NotifierService } from 'angular-notifier';
 import { APIURLHEADER, ERRORDATA, URLPARAMS } from 'CommonModel';
 import { DataService } from 'DataService';
 import { environment } from 'environment';
-import { NSData } from 'NSDModel';
+import { NSData, VDUPRIMITIVELEVEL } from 'NSDModel';
 import { NSPrimitiveParams } from 'NSInstanceModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
@@ -81,6 +81,9 @@ export class NSPrimitiveComponent implements OnInit {
     /** Model value used to hold selected primitive type @public */
     public primitiveType: string;
 
+    /** Contains list of VDU primitive lists @public */
+    public vduList: {}[];
+
     /** FormBuilder instance added to the formBuilder @private */
     private formBuilder: FormBuilder;
 
@@ -111,7 +114,16 @@ export class NSPrimitiveComponent implements OnInit {
         this.sharedService = this.injector.get(SharedService);
         this.activeModal = this.injector.get(NgbActiveModal);
         this.formBuilder = this.injector.get(FormBuilder);
-        this.primitiveTypeList = [{ title: this.translateService.instant('VNFPRIMITIVE'), value: 'VNF_Primitive' }];
+        this.primitiveTypeList = [
+            {
+                title: this.translateService.instant('VNFPRIMITIVE'),
+                value: 'VNF_Primitive'
+            },
+            {
+                title: this.translateService.instant('VDUPRIMITIVE'),
+                value: 'VDU_Primitive'
+            }
+        ];
         this.primitiveType = 'VNF_Primitive';
     }
 
@@ -139,6 +151,7 @@ export class NSPrimitiveComponent implements OnInit {
         this.primitiveForm = this.formBuilder.group({
             primitive: [null, [Validators.required]],
             vnf_member_index: [null, [Validators.required]],
+            vdu_id: [null, [Validators.required]],
             primitive_params: this.formBuilder.array([this.primitiveParamsBuilder()])
         });
     }
@@ -187,6 +200,12 @@ export class NSPrimitiveComponent implements OnInit {
             // tslint:disable-next-line: no-string-literal
             primitiveParamsPayLoads['vnf_member_index'] = this.primitiveForm.value.vnf_member_index;
         }
+        if (this.primitiveType === 'VDU_Primitive') {
+            // tslint:disable-next-line: no-string-literal
+            primitiveParamsPayLoads['vnf_member_index'] = this.primitiveForm.value.vnf_member_index;
+            // tslint:disable-next-line: no-string-literal
+            primitiveParamsPayLoads['vdu_id'] = this.primitiveForm.value.vdu_id;
+        }
         const apiURLHeader: APIURLHEADER = {
             url: environment.NSDINSTANCES_URL + '/' + this.nsdId + '/action'
         };
@@ -209,18 +228,24 @@ export class NSPrimitiveComponent implements OnInit {
             this.primitiveList = !isNullOrUndefined(this.params.nsConfig['config-primitive']) ?
                 this.params.nsConfig['config-primitive'] : [];
             this.getFormControl('vnf_member_index').setValidators([]);
+            this.getFormControl('vdu_id').setValidators([]);
         }
     }
     /** Member index change event */
-    public indexChange(data: {}): void {
+    public indexChange(data: {}, getType?: string): void {
+        this.getFormControl('vdu_id').setValue(null);
         if (data) {
-            this.getVnfdInfo(data['vnfd-id-ref']);
+            this.getVnfdInfo(data['vnfd-id-ref'], getType);
         } else {
             this.primitiveList = [];
             this.getFormControl('primitive').setValue(null);
             this.primitiveParameter = [];
         }
     }
+    /** Get VDU Primitive from selected VDU id/name change event */
+    public getVDUPrimitive(data: {}): void {
+        this.primitiveList = data['vdu-configuration']['config-primitive'];
+    }
     /** Primivtive change event */
     public primitiveChange(data: { parameter: {}[] }): void {
         this.primitiveParameter = [];
@@ -231,6 +256,14 @@ export class NSPrimitiveComponent implements OnInit {
             this.updatePrimitive(data);
         }
     }
+    /** Generate vdu section @public */
+    public generateVDUData(vduData: VDUPRIMITIVELEVEL): VDUPRIMITIVELEVEL {
+        return {
+            id: vduData.id,
+            name: vduData.name,
+            'vdu-configuration': vduData['vdu-configuration']
+        };
+    }
     /** Update primitive value based on parameter */
     private updatePrimitive(primitive: { parameter: {}[] }): void {
         if (primitive.parameter) {
@@ -247,7 +280,7 @@ export class NSPrimitiveComponent implements OnInit {
         }
     }
     /** Get primivitive actions from vnfd data */
-    private getVnfdInfo(vnfdRef: string): void {
+    private getVnfdInfo(vnfdRef: string, getType?: string): void {
         this.primitiveList = [];
         this.primitiveParameter = [];
         this.getFormControl('primitive').setValue(null);
@@ -256,8 +289,18 @@ export class NSPrimitiveComponent implements OnInit {
         this.restService.getResource(apiUrl)
             .subscribe((vnfdInfo: {}) => {
                 if (vnfdInfo[0]['vnf-configuration']) {
+                    this.getFormControl('vdu_id').setValidators([]);
                     this.primitiveList = vnfdInfo[0]['vnf-configuration']['config-primitive'];
                 }
+                if (getType === 'VDU_Primitive') {
+                    this.vduList = [];
+                    vnfdInfo[0].vdu.forEach((vduData: VDUPRIMITIVELEVEL) => {
+                        if (vduData['vdu-configuration']) {
+                            const vduDataObj: VDUPRIMITIVELEVEL = this.generateVDUData(vduData);
+                            this.vduList.push(vduDataObj);
+                        }
+                    });
+                }
                 this.isLoadingResults = false;
             }, (error: ERRORDATA) => {
                 this.isLoadingResults = false;
index b889dd0..27cf950 100644 (file)
@@ -97,6 +97,7 @@
     "EXECUTE": "Execute",
     "EXECNSPRIMITIVE": "Exec NS Primitive",
     "PRIMITIVETYPE": "Primitiver Typ",
+    "VDUPRIMITIVE": "VDU Level Primitive",
     "VNFPRIMITIVE": "VNF Level Primitive",
     "NSPRIMITIVE": "NS Level Primitive",
     "DESCRIPTOR": "Deskriptor",
index a57dfcf..af4b196 100644 (file)
@@ -97,6 +97,7 @@
     "EXECUTE": "Execute",
     "EXECNSPRIMITIVE": "Exec NS Primitive",
     "PRIMITIVETYPE": "Primitive Type",
+    "VDUPRIMITIVE": "VDU Level Primitive",
     "VNFPRIMITIVE": "VNF Level Primitive",
     "NSPRIMITIVE": "NS Level Primitive",
     "DESCRIPTOR": "Descriptor",
index d325d99..c5796ea 100644 (file)
@@ -97,6 +97,7 @@
     "EXECUTE": "Ejecutar",
     "EXECNSPRIMITIVE": "Ejecutar NS Primitiva",
     "PRIMITIVETYPE": "Tipo primitivo",
+    "VDUPRIMITIVE": "Primitiva a nivel de VDU",
     "VNFPRIMITIVE": "Nivel VNF Primitivo",
     "NSPRIMITIVE": "NS Level Primitive",
     "DESCRIPTOR": "Descriptora",
index 3936203..496d330 100644 (file)
@@ -97,6 +97,7 @@
     "EXECUTE": "Executar",
     "EXECNSPRIMITIVE": "Exec NS Primitive",
     "PRIMITIVETYPE": "Tipo primitivo",
+    "VDUPRIMITIVE": "Primitivo de nível VDU",
     "VNFPRIMITIVE": "Primitivo de nível VNF",
     "NSPRIMITIVE": "NS Level Primitive",
     "DESCRIPTOR": "Descritora",
index 95331a2..584f4e0 100644 (file)
@@ -166,3 +166,10 @@ export interface NSICREATEPARAMS {
     'netslice-vld': string;
     ssh_keys: string[];
 }
+
+/** Interface for the VDU Primitive Levels */
+export interface VDUPRIMITIVELEVEL {
+    id: string;
+    name: string;
+    'vdu-configuration': {};
+}