Fix Bug 2148: VDU Id issue & Multivdu Count Index Error in VM Action 88/12488/1
authorSANDHYA.JS <sandhya.j@tataelxsi.co.in>
Thu, 25 Aug 2022 02:49:13 +0000 (08:19 +0530)
committerjssan <sandhya.j@tataelxsi.co.in>
Thu, 25 Aug 2022 03:52:56 +0000 (05:52 +0200)
- Resolved vduId dropdown issue by removing the duplicate values
  from the array
- Resolved multivdu countIndex error by filtering count index
  with selected vduId

Change-Id: I1231afb4bb3b013816cd8d7b8c50ae3decf5dbea
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.html
src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts
src/app/utilities/vertical-scaling/VerticalScalingComponent.html
src/app/utilities/vertical-scaling/VerticalScalingComponent.ts
src/app/utilities/vm-migration/VmMigrationComponent.html
src/app/utilities/vm-migration/VmMigrationComponent.ts

index b0bba96..2965ad4 100644 (file)
@@ -44,8 +44,8 @@ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
                 <label for="vdu-id"> {{'VDUID' | translate}} *</label>
             </div>
             <div class="col-sm-6">
-                <ng-select formControlName="vduId" [clearable]="false"
-                    placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vdu" bindLabel="VDU"
+                <ng-select formControlName="vduId" [clearable]="false" (change)="getCountIndex($event.VDU)"
+                    placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vduId" bindLabel="VDU"
                     bindValue="VDU" [ngClass]="{ 'is-invalid': submitted && f.vduId.errors }">
                 </ng-select>
             </div>
@@ -56,7 +56,7 @@ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
             </div>
             <div class="col-sm-6">
                 <ng-select formControlName="countIndex" [clearable]="false"
-                    placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="vdu"
+                    placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="countIndex"
                     bindLabel="count-index" bindValue="count-index"
                     [ngClass]="{ 'is-invalid': submitted && f.countIndex.errors }">
                 </ng-select>
index 18b6058..4b0afe0 100644 (file)
@@ -68,6 +68,10 @@ export class StartStopRebuildComponent implements OnInit {
     public nsIdFilteredData: {}[] = [];
     /** Form valid on submit trigger @public */
     public submitted: boolean = false;
+    /** Contains vduId @public */
+    public vduId: {};
+    /** Items for countIndex @public */
+    public countIndex: {}[];
     /** Input contains Modal dialog component Instance @public */
     @Input() public instanceType: string;
     /** Input contains Modal dialog component Instance @public */
@@ -152,7 +156,6 @@ export class StartStopRebuildComponent implements OnInit {
     /** Getting vdu-id & count-index from VNFInstance API */
     public getVdu(id: string): void {
         const vnfInstanceData: {}[] = [];
-        const vnfrDetails: {}[] = [];
         this.getFormControl('vduId').setValue(null);
         this.getFormControl('countIndex').setValue(null);
         if (!isNullOrUndefined(id)) {
@@ -172,6 +175,12 @@ export class StartStopRebuildComponent implements OnInit {
                             vnfInstanceData.push(vnfInstanceDataObj);
                         });
                         this.vdu = vnfInstanceData;
+                        const vduName: string = 'VDU';
+                        this.vduId = this.vdu.filter((vdu: {}, index: number, self: {}[]): {} =>
+                            index === self.findIndex((t: {}): {} => (
+                                t[vduName] === vdu[vduName]
+                            ))
+                        );
                     }
                     this.checkDay12Operation(this.selectedvnfId);
                 }, (error: ERRORDATA): void => {
@@ -181,6 +190,12 @@ export class StartStopRebuildComponent implements OnInit {
         }
     }
 
+    /** Getting count-index by filtering id */
+    public getCountIndex(id: string): void {
+        const VDU: string = 'VDU';
+        this.countIndex = this.vdu.filter((vnfdData: {}[]): boolean => vnfdData[VDU] === id);
+    }
+
     /** To check primitve actions from VNFR  */
     public checkDay12Operation(id: string): void {
         const apiUrl: string = environment.VNFPACKAGES_URL + '?id=' + id;
index cef0ff2..5525871 100644 (file)
@@ -44,8 +44,8 @@ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
                 <label for="vdu-id"> {{'VDUID' | translate}} *</label>
             </div>
             <div class="col-sm-6">
-                <ng-select formControlName="vduId" [clearable]="false"
-                    placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vdu" bindLabel="VDU"
+                <ng-select formControlName="vduId" [clearable]="false" (change)="getCountIndex($event.VDU)"
+                    placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vduId" bindLabel="VDU"
                     bindValue="VDU" [ngClass]="{ 'is-invalid': submitted && f.vduId.errors }">
                 </ng-select>
             </div>
@@ -56,7 +56,7 @@ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
             </div>
             <div class="col-sm-6">
                 <ng-select formControlName="countIndex" [clearable]="false"
-                    placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="vdu"
+                    placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="countIndex"
                     bindLabel="count-index" bindValue="count-index"
                     [ngClass]="{ 'is-invalid': submitted && f.countIndex.errors }">
                 </ng-select>
index 69eb9eb..949506a 100644 (file)
@@ -67,6 +67,10 @@ export class VerticalScalingComponent implements OnInit {
     public nsIdFilteredData: {}[] = [];
     /** Form valid on submit trigger @public */
     public submitted: boolean = false;
+     /** Contains vduId @public */
+    public vduId: {};
+    /** Items for countIndex @public */
+    public countIndex: {}[];
     /** Input contains component objects @private */
     @Input() private params: URLPARAMS;
     /** FormBuilder instance added to the formBuilder @private */
@@ -175,6 +179,12 @@ export class VerticalScalingComponent implements OnInit {
                             vnfInstanceData.push(vnfInstanceDataObj);
                         });
                         this.vdu = vnfInstanceData;
+                        const vduName: string = 'VDU';
+                        this.vduId = this.vdu.filter((vdu: {}, index: number, self: {}[]): {} =>
+                            index === self.findIndex((t: {}): {} => (
+                                t[vduName] === vdu[vduName]
+                            ))
+                        );
                     }
                 }, (error: ERRORDATA): void => {
                     this.restService.handleError(error, 'get');
@@ -183,6 +193,12 @@ export class VerticalScalingComponent implements OnInit {
         }
     }
 
+    /** Getting count-index by filtering id  */
+    public getCountIndex(id: string): void {
+        const VDU: string = 'VDU';
+        this.countIndex = this.vdu.filter((vnfdData: {}[]): boolean => vnfdData[VDU] === id);
+    }
+
     /** Vertical Scaling on submit */
     public triggerVerticalScaling(): void {
         this.submitted = true;
index 343a6be..fa1cd14 100644 (file)
@@ -44,8 +44,8 @@ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
                 <label for="vduid"> {{'VDUID' | translate}}</label>
             </div>
             <div class="col-sm-6">
-                <ng-select formControlName="vduId" [clearable]="false"
-                    placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vdu" bindLabel="VDU"
+                <ng-select formControlName="vduId" [clearable]="false" (change)="getCountIndex($event.VDU)"
+                    placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vduId" bindLabel="VDU"
                     bindValue="VDU" [ngClass]="{ 'is-invalid': submitted && f.vduId.errors }">
                 </ng-select>
             </div>
@@ -56,7 +56,7 @@ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
             </div>
             <div class="col-sm-6">
                 <ng-select formControlName="countIndex" [clearable]="false"
-                    placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="vdu"
+                    placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="countIndex"
                     bindLabel="count-index" bindValue="count-index"
                     [ngClass]="{ 'is-invalid': submitted && f.countIndex.errors }">
                 </ng-select>
index 0ec8bc4..7ac8af0 100644 (file)
@@ -65,6 +65,10 @@ export class VmMigrationComponent implements OnInit {
     public instanceId: string;
     /** Form valid on submit trigger @public */
     public submitted: boolean = false;
+     /** Contains vduId @public */
+    public vduId: {};
+    /** Items for countIndex @public */
+    public countIndex: {}[];
     /** Input contains component objects @private */
     @Input() private params: URLPARAMS;
     /** FormBuilder instance added to the formBuilder @private */
@@ -166,6 +170,12 @@ export class VmMigrationComponent implements OnInit {
                             vnfInstanceData.push(vnfInstanceDataObj);
                         });
                         this.vdu = vnfInstanceData;
+                        const vduName: string = 'VDU';
+                        this.vduId = this.vdu.filter((vdu: {}, index: number, self: {}[]): {} =>
+                            index === self.findIndex((t: {}): {} => (
+                                t[vduName] === vdu[vduName]
+                            ))
+                        );
                     }
                 }, (error: ERRORDATA): void => {
                     this.restService.handleError(error, 'get');
@@ -174,6 +184,12 @@ export class VmMigrationComponent implements OnInit {
         }
     }
 
+    /** Getting count-index by filtering id  */
+    public getCountIndex(id: string): void {
+        const VDU: string = 'VDU';
+        this.countIndex = this.vdu.filter((vnfdData: {}[]): boolean => vnfdData[VDU] === id);
+    }
+
     /** Trigger VM Migration on submit */
     public triggerMigration(): void {
         this.submitted = true;