Fix spice+agent and none console types not supported.

This commit is contained in:
grossmj
2022-06-18 18:53:36 +02:00
parent 7e43dc77cb
commit 9efd99dccb
4 changed files with 74 additions and 65 deletions

View File

@ -33,21 +33,25 @@ export class ConsoleDeviceActionBrowserComponent {
this.node.console_host = this.server.host; this.node.console_host = this.server.host;
} }
if (
this.node.console_type === 'telnet' ||
this.node.console_type === 'vnc' ||
this.node.console_type === 'spice'
) {
try { try {
if (this.node.console_type === 'telnet') {
location.assign( location.assign(
`gns3+${this.node.console_type}://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}` `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.startsWith('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 are: telnet, vnc, spice and spice+agent.');
}
} catch (e) { } catch (e) {
this.toasterService.error(e); this.toasterService.error(e);
} }
} else {
this.toasterService.error('Supported console types: telnet, vnc, spice.');
}
} }
} }
} }

View File

@ -29,7 +29,7 @@ export class ConsoleDeviceActionComponent implements OnInit {
let consoleCommand = this.settingsService.getConsoleSettings() let consoleCommand = this.settingsService.getConsoleSettings()
? this.settingsService.getConsoleSettings() ? this.settingsService.getConsoleSettings()
: this.nodeService.getDefaultCommand(); : this.nodeService.getDefaultCommand();
const startedNodes = this.nodes.filter((node) => node.status === 'started'); const startedNodes = this.nodes.filter((node) => node.status === 'started' && node.console_type !== 'none');
if (startedNodes.length === 0) { if (startedNodes.length === 0) {
this.toasterService.error('Device needs to be started in order to console to it.'); this.toasterService.error('Device needs to be started in order to console to it.');
@ -37,7 +37,7 @@ export class ConsoleDeviceActionComponent implements OnInit {
} }
for (var node of this.nodes) { for (var node of this.nodes) {
if (node.status !== 'started') { if (node.status !== 'started' && node.console_type !== 'none') {
continue; continue;
} }

View File

@ -232,12 +232,12 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
location.assign( location.assign(
`gns3+vnc://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` `gns3+vnc://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}`
); );
} else if (node.console_type === 'spice') { } else if (node.console_type.startsWith('spice')) {
location.assign( location.assign(
`gns3+spice://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` `gns3+spice://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}`
); );
} else { } else {
this.showCommand('Supported console types: telnet, vnc, spice.'); this.showCommand('Supported console types are: telnet, vnc, spice and spice+agent');
} }
} else { } else {
this.showCommand(`This node must be started before a console can be opened.`); this.showCommand(`This node must be started before a console can be opened.`);

View File

@ -78,6 +78,7 @@ export class NodeConsoleService {
let nodesToStart = 'Please start the following nodes if you want to open consoles for them: '; let nodesToStart = 'Please start the following nodes if you want to open consoles for them: ';
let nodesToStartCounter = 0; let nodesToStartCounter = 0;
nodes.forEach((n) => { nodes.forEach((n) => {
if (n.console_type !== "none") {
if (n.status === 'started') { if (n.status === 'started') {
this.mapSettingsService.logConsoleSubject.next(true); this.mapSettingsService.logConsoleSubject.next(true);
// this timeout is required due to xterm.js implementation // this timeout is required due to xterm.js implementation
@ -86,6 +87,7 @@ export class NodeConsoleService {
nodesToStartCounter++; nodesToStartCounter++;
nodesToStart += n.name + ' ' nodesToStart += n.name + ' '
} }
}
}); });
if (nodesToStartCounter > 0) { if (nodesToStartCounter > 0) {
this.toasterService.error(nodesToStart); this.toasterService.error(nodesToStart);
@ -93,9 +95,11 @@ export class NodeConsoleService {
} }
openConsolesForAllNodesInNewTabs(nodes: Node[]) { openConsolesForAllNodesInNewTabs(nodes: Node[]) {
let nodesToStart = 'Please start the following nodes if you want to open consoles for them: '; let nodesToStart = 'Please start the following nodes if you want to open consoles in tabs for them: ';
let nodesToStartCounter = 0; let nodesToStartCounter = 0;
nodes.forEach((n) => { nodes.forEach((n) => {
// opening a console in tab is only supported for telnet type
if (n.console_type === "telnet") {
if (n.status === 'started') { if (n.status === 'started') {
let url = this.router.url.split('/'); let url = this.router.url.split('/');
let urlString = `/static/web-ui/${url[1]}/${url[2]}/${url[3]}/${url[4]}/nodes/${n.node_id}`; let urlString = `/static/web-ui/${url[1]}/${url[2]}/${url[3]}/${url[4]}/nodes/${n.node_id}`;
@ -104,6 +108,7 @@ export class NodeConsoleService {
nodesToStartCounter++; nodesToStartCounter++;
nodesToStart += n.name + ' ' nodesToStart += n.name + ' '
} }
}
}); });
if (nodesToStartCounter > 0) { if (nodesToStartCounter > 0) {
this.toasterService.error(nodesToStart); this.toasterService.error(nodesToStart);