Fix Bug 2148: VDU Id issue & Multivdu Count Index Error in VM Action
[osm/NG-UI.git] / src / app / utilities / vm-migration / VmMigrationComponent.ts
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;