From 380a45883e297c90dfa166919f2fa3cbfd659f44 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Fri, 20 Sep 2019 07:01:28 -0700 Subject: [PATCH] Custom console for particular node --- ...console-device-action-browser.component.ts | 26 ++++++++++++++++--- .../context-menu/context-menu.component.html | 3 ++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index 51a7f435..62bd7420 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -1,23 +1,43 @@ import { Component, Input } from '@angular/core'; import { Node } from '../../../../../cartography/models/node'; import { ToasterService } from '../../../../../services/toaster.service'; +import { NodeService } from '../../../../../services/node.service'; +import { Server } from '../../../../../models/server'; + @Component({ selector: 'app-console-device-action-browser', templateUrl: './console-device-action-browser.component.html' }) export class ConsoleDeviceActionBrowserComponent { + @Input() server: Server; @Input() node: Node; constructor( - private toasterService: ToasterService + private toasterService: ToasterService, + private nodeService: NodeService ) {} openConsole() { - if(this.node.status !== "started") { + this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.node = node; + this.startConsole(); + }); + } + + startConsole() { + if (this.node.status !== "started") { this.toasterService.error("This node must be started before a console can be opened"); } else { - location.assign(`telnet://${this.node.console_host}:${this.node.console}/`); + if (this.node.console_type === "telnet") { + location.assign(`gns3+telnet://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`); + } else if (this.node.console_type === "vnc") { + location.assign(`gns3+vnc://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`); + } else if(this.node.console_type === "spice") { + location.assign(`gns3+spice://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`); + } else { + this.toasterService.error("Supported console types: telnet, vnc, spice."); + } } } } diff --git a/src/app/components/project-map/context-menu/context-menu.component.html b/src/app/components/project-map/context-menu/context-menu.component.html index 177d607d..a8049403 100644 --- a/src/app/components/project-map/context-menu/context-menu.component.html +++ b/src/app/components/project-map/context-menu/context-menu.component.html @@ -21,7 +21,8 @@ [nodes]="nodes" >