Feature 11052: support for vms remote console for plugin vcenter

Change-Id: I328f4626dda94d9c4322c285b1e9216ed8f03673
Signed-off-by: Isabel Lloret <illoret@indra.es>
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
index c2f8a78..c19acc4 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
@@ -49,6 +49,10 @@
                 [disabled]="operationalStatus === 'failed' || configStatus === 'failed'" ngbTooltip="{{'VMMIGRATION' | translate}}">
                 <i class="fas fa-angle-double-left"></i> {{'VMMIGRATION' | translate}}
             </button>
+            <button *ngIf="showConsoleAction" type="button" class="btn btn-primary dropdown-item" (click)="openConsole()" placement="left"
+                data-container="body" ngbTooltip="{{'CONSOLE' | translate}}">
+                <i class="fas fa-desktop"></i> {{'CONSOLE' | translate}}
+            </button>
         </div>
     </div>
     <div class="btn-group" placement="bottom-right" ngbDropdown display="dynamic" container="body">
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
index 8ae776f..2d2575e 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
@@ -36,6 +36,7 @@
 import { ScalingComponent } from 'ScalingComponent';
 import { SharedService, isNullOrUndefined } from 'SharedService';
 import { ShowInfoComponent } from 'ShowInfoComponent';
+import { ShowVduConsoleComponent } from 'ShowVduConsoleComponent';
 import { StartStopRebuildComponent } from 'StartStopRebuildComponent';
 import { VmMigrationComponent } from 'VmMigrationComponent';
 import { DF, VDU, VNFD } from 'VNFDModel';
@@ -89,6 +90,12 @@
   /** Contains operational dashboard view @public */
   public isShowOperationalDashboard: boolean = false;
 
+  /** Controls to show additional operations buttons */
+  public showConsoleAction: boolean = false;
+
+  /** Vim types for wich console operation button must be show */
+  private static readonly NS_CONSOLE_OPERATION_VIM_TYPES: string[] = ['vcenter'];
+
   /** Instance of the modal service @private */
   private modalService: NgbModal;
 
@@ -146,6 +153,15 @@
     }
     this.isShowOperationalDashboard = !isNullOrUndefined(this.value.vcaStatus) ?
       Object.keys(this.value.vcaStatus).length === 0 && typeof this.value.vcaStatus === 'object' : true;
+    // Check if additional operations buttons must be showns
+    this.checkShowExtraActionsButtons();
+  }
+
+  /** Checks if the console option in the actions dropdown must be shown */
+  private checkShowExtraActionsButtons() {
+    if (NSInstancesActionComponent.NS_CONSOLE_OPERATION_VIM_TYPES.includes(this.value.vimType)) {
+      this.showConsoleAction = true;
+    }
   }
 
   /** Shows information using modalservice @public */
@@ -349,6 +365,21 @@
     });
   }
 
+  /** Open the show remote console pop-up @public */
+  public openConsole(): void {
+    const modalRef: NgbModalRef = this.modalService.open(ShowVduConsoleComponent, { backdrop: 'static' });
+    modalRef.componentInstance.params = {
+      id: this.instanceID
+    };
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
+
   /** Open the Healing pop-up @public */
   public openHealing(): void {
     // eslint-disable-next-line security/detect-non-literal-fs-filename