mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 02:54:16 +00:00
Get url for console sockets moved to NodeConsoleService
This commit is contained in:
parent
f5296dd1fb
commit
700eff76eb
@ -235,11 +235,11 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
nodes.forEach(async (node: Node) => {
|
||||
node.symbol_url = `${this.server.protocol}//${this.server.host}:${this.server.port}/v2/symbols/${node.symbol}/raw`;
|
||||
|
||||
if (node.width == 0 && node.height == 0) {
|
||||
let symbolDimensions = await this.symbolService.getDimensions(this.server, node.symbol).toPromise();
|
||||
node.width = symbolDimensions.width;
|
||||
node.height = symbolDimensions.height;
|
||||
}
|
||||
// if (node.width == 0 && node.height == 0) {
|
||||
// let symbolDimensions = await this.symbolService.getDimensions(this.server, node.symbol).toPromise();
|
||||
// node.width = symbolDimensions.width;
|
||||
// node.height = symbolDimensions.height;
|
||||
// }
|
||||
});
|
||||
|
||||
this.nodes = nodes;
|
||||
@ -425,7 +425,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
setUpProjectWS(project: Project) {
|
||||
this.projectws = new WebSocket(this.projectService.notificationsPath(this.server, project.project_id));
|
||||
this.projectws = new WebSocket(this.notificationService.projectNotificationsPath(this.server, project.project_id));
|
||||
|
||||
this.projectws.onmessage = (event: MessageEvent) => {
|
||||
this.projectWebServiceHandler.handleMessage(JSON.parse(event.data));
|
||||
|
@ -53,7 +53,7 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
|
||||
if (this.isLightThemeEnabled)
|
||||
this.term.setOption('theme', { background: 'white', foreground: 'black', cursor: 'black' });
|
||||
|
||||
const socket = new WebSocket(this.getUrl());
|
||||
const socket = new WebSocket(this.consoleService.getUrl(this.server, this.node));
|
||||
|
||||
socket.onerror = (event) => {
|
||||
this.term.write('Connection lost');
|
||||
@ -78,8 +78,4 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
return `ws://${this.server.host}:${this.server.port}/v2/projects/${this.node.project_id}/nodes/${this.node.node_id}/console/ws`;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ export class WebConsoleFullWindowComponent implements OnInit {
|
||||
openTerminal() {
|
||||
setTimeout(() => {
|
||||
this.term.open(this.terminal.nativeElement);
|
||||
const socket = new WebSocket(this.getUrl());
|
||||
const socket = new WebSocket(this.consoleService.getUrl(this.server, this.node));
|
||||
|
||||
socket.onerror = (event) => {
|
||||
this.term.write('Connection lost' + '\r\n');
|
||||
@ -103,8 +103,4 @@ export class WebConsoleFullWindowComponent implements OnInit {
|
||||
this.term.resize(numberOfColumns, numberOfRows);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
return `ws://${this.server.host}:${this.server.port}/v2/projects/${this.projectId}/nodes/${this.nodeId}/console/ws`;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { EventEmitter, Injectable } from '@angular/core';
|
||||
import { Server } from '../models/server';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Node } from '../cartography/models/node';
|
||||
|
||||
@ -55,6 +56,15 @@ export class NodeConsoleService {
|
||||
getLineHeight() {
|
||||
return this.defaultConsoleHeight / this.defaultNumberOfRows;
|
||||
}
|
||||
|
||||
getUrl(server: Server, node: Node) {
|
||||
let protocol:string = "ws"
|
||||
if (server.protocol === "https:") {
|
||||
protocol = "wss"
|
||||
}
|
||||
|
||||
return `${protocol}://${server.host}:${server.port}/v2/projects/${node.project_id}/nodes/${node.node_id}/console/ws`
|
||||
}
|
||||
}
|
||||
|
||||
export interface ConsoleResizedEvent {
|
||||
|
@ -1,12 +1,24 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Server } from '../models/server';
|
||||
import { HttpServer } from './http-server.service';
|
||||
|
||||
@Injectable()
|
||||
export class NotificationService {
|
||||
constructor(private httpServer: HttpServer) {}
|
||||
|
||||
notificationsPath(server: Server): string {
|
||||
return `ws://${server.host}:${server.port}/v2/notifications/ws`;
|
||||
let protocol:string = "ws"
|
||||
if (server.protocol === "https:") {
|
||||
protocol = "wss"
|
||||
}
|
||||
|
||||
return `${protocol}://${server.host}:${server.port}/v2/notifications/ws`;
|
||||
}
|
||||
|
||||
|
||||
projectNotificationsPath(server: Server, project_id: string): string {
|
||||
let protocol:string = "ws"
|
||||
if (server.protocol === "https:") {
|
||||
protocol = "wss"
|
||||
}
|
||||
|
||||
return `${protocol}://${server.host}:${server.port}/v2/projects/${project_id}/notifications/ws`;
|
||||
}
|
||||
}
|
||||
|
@ -94,10 +94,6 @@ export class ProjectService {
|
||||
return this.httpServer.post(server, `/projects/${project_id}/duplicate`, { name: project_name });
|
||||
}
|
||||
|
||||
notificationsPath(server: Server, project_id: string): string {
|
||||
return `ws://${server.host}:${server.port}/v2/projects/${project_id}/notifications/ws`;
|
||||
}
|
||||
|
||||
isReadOnly(project: Project) {
|
||||
if (project.readonly) {
|
||||
return project.readonly;
|
||||
|
Loading…
x
Reference in New Issue
Block a user