Merge pull request #505 from GNS3/custom-console-for-particular-node

Custom console for particular node (branch from node configurator to avoid conflicts)
This commit is contained in:
piotrpekala7 2019-09-25 10:01:34 +02:00 committed by GitHub
commit 5aedd2758d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View File

@ -1,23 +1,43 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { Node } from '../../../../../cartography/models/node'; import { Node } from '../../../../../cartography/models/node';
import { ToasterService } from '../../../../../services/toaster.service'; import { ToasterService } from '../../../../../services/toaster.service';
import { NodeService } from '../../../../../services/node.service';
import { Server } from '../../../../../models/server';
@Component({ @Component({
selector: 'app-console-device-action-browser', selector: 'app-console-device-action-browser',
templateUrl: './console-device-action-browser.component.html' templateUrl: './console-device-action-browser.component.html'
}) })
export class ConsoleDeviceActionBrowserComponent { export class ConsoleDeviceActionBrowserComponent {
@Input() server: Server;
@Input() node: Node; @Input() node: Node;
constructor( constructor(
private toasterService: ToasterService private toasterService: ToasterService,
private nodeService: NodeService
) {} ) {}
openConsole() { 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"); this.toasterService.error("This node must be started before a console can be opened");
} else { } 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.");
}
} }
} }
} }

View File

@ -21,7 +21,8 @@
[nodes]="nodes" [nodes]="nodes"
></app-console-device-action> ></app-console-device-action>
<app-console-device-action-browser <app-console-device-action-browser
*ngIf="!projectService.isReadOnly(project) && nodes.length===1 && !isElectronApp && nodes[0].console_type!=='none'" *ngIf="!projectService.isReadOnly(project) && nodes.length===1 && !isElectronApp"
[server]="server"
[node]="nodes[0]" [node]="nodes[0]"
></app-console-device-action-browser> ></app-console-device-action-browser>
<app-change-symbol-action <app-change-symbol-action