Feature 10910: Migration of Openstack based VM instances
[osm/NG-UI.git] / src / app / utilities / ns-instances-action / NSInstancesActionComponent.ts
index ed24a67..fb52423 100644 (file)
@@ -35,6 +35,7 @@ import { ScalingComponent } from 'ScalingComponent';
 import { SharedService } from 'SharedService';
 import { ShowInfoComponent } from 'ShowInfoComponent';
 import { isNullOrUndefined } from 'util';
+import { VmMigrationComponent } from 'VmMigrationComponent';
 import { DF, VDU, VNFD } from 'VNFDModel';
 /**
  * Creating component
@@ -77,15 +78,18 @@ export class NSInstancesActionComponent {
   /** Assign the VNF Details @public */
   public vnfDetails: VNFD[] = [];
 
+  /** Contains instance ID @public */
+  public instanceID: string;
+
+  /** Contains operational dashboard view @public */
+  public isShowOperationalDashboard: boolean = false;
+
   /** Instance of the modal service @private */
   private modalService: NgbModal;
 
   /** Holds teh instance of AuthService class of type AuthService @private */
   private router: Router;
 
-  /** Contains instance ID @private */
-  private instanceID: string;
-
   /** Contains all methods related to shared @private */
   private sharedService: SharedService;
 
@@ -120,6 +124,8 @@ export class NSInstancesActionComponent {
     this.operationalStatus = this.value.OperationalStatus;
     this.instanceID = this.value.identifier;
     this.getAdminDetails = this.value.adminDetails;
+    this.isShowOperationalDashboard = !isNullOrUndefined(this.value.vcaStatus) ?
+      Object.keys(this.value.vcaStatus).length === 0 && typeof this.value.vcaStatus === 'object' : true;
   }
 
   /** Shows information using modalservice @public */
@@ -179,7 +185,7 @@ export class NSInstancesActionComponent {
                 window.open(location);
               } else {
                 this.isLoadingNSInstanceAction = false;
-                this.notifierService.notify('error', this.translateService.instant('GRAFANA.METRICSERROR'));
+                this.notifierService.notify('error', this.translateService.instant('PAGE.NSMETRIC.METRICERROR'));
               }
             });
             this.doChanges();
@@ -251,6 +257,19 @@ export class NSInstancesActionComponent {
     }).catch();
   }
 
+  /** To open VM Migration in NS Instances */
+  public openVmMigration(): void {
+    const modalRef: NgbModalRef = this.modalService.open(VmMigrationComponent, { backdrop: 'static' });
+    modalRef.componentInstance.params = {
+      id: this.instanceID
+    };
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch();
+  }
+
   /**
    * Check any changes in the child component @public
    */