mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-19 07:18:14 +00:00
Use node names in HTTP console tabs
This commit is contained in:
@ -8,6 +8,8 @@ import { FitAddon } from 'xterm-addon-fit';
|
|||||||
import { NodeConsoleService } from '../../services/nodeConsole.service';
|
import { NodeConsoleService } from '../../services/nodeConsole.service';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { ServerService } from '../../services/server.service';
|
import { ServerService } from '../../services/server.service';
|
||||||
|
import { Title } from '@angular/platform-browser';
|
||||||
|
import { NodeService } from '../../services/node.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -21,6 +23,9 @@ export class WebConsoleFullWindowComponent implements OnInit, AfterViewInit {
|
|||||||
private projectId: string;
|
private projectId: string;
|
||||||
private nodeId: string;
|
private nodeId: string;
|
||||||
|
|
||||||
|
private server: Server;
|
||||||
|
private node: Node;
|
||||||
|
|
||||||
public term: Terminal = new Terminal();
|
public term: Terminal = new Terminal();
|
||||||
public fitAddon: FitAddon = new FitAddon();
|
public fitAddon: FitAddon = new FitAddon();
|
||||||
|
|
||||||
@ -29,7 +34,9 @@ export class WebConsoleFullWindowComponent implements OnInit, AfterViewInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private consoleService: NodeConsoleService,
|
private consoleService: NodeConsoleService,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute,
|
||||||
|
private title: Title,
|
||||||
|
private nodeService: NodeService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -40,6 +47,14 @@ export class WebConsoleFullWindowComponent implements OnInit, AfterViewInit {
|
|||||||
this.consoleService.consoleResized.subscribe(ev => {
|
this.consoleService.consoleResized.subscribe(ev => {
|
||||||
this.fitAddon.fit();
|
this.fitAddon.fit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.serverService.get(+this.serverId).then((server: Server) => {
|
||||||
|
this.server = server;
|
||||||
|
this.nodeService.getNodeById(this.server, this.projectId, this.nodeId).subscribe((node: Node) => {
|
||||||
|
this.node = node;
|
||||||
|
this.title.setTitle(this.node.name);
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngAfterViewInit() {
|
async ngAfterViewInit() {
|
||||||
@ -76,7 +91,6 @@ export class WebConsoleFullWindowComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getUrl() {
|
async getUrl() {
|
||||||
let server: Server = await this.serverService.get(+this.serverId);
|
return `ws://${this.server.host}:${this.server.port}/v2/projects/${this.projectId}/nodes/${this.nodeId}/console/ws`
|
||||||
return `ws://${server.host}:${server.port}/v2/projects/${this.projectId}/nodes/${this.nodeId}/console/ws`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ import { Label } from '../cartography/models/label';
|
|||||||
export class NodeService {
|
export class NodeService {
|
||||||
constructor(private httpServer: HttpServer) {}
|
constructor(private httpServer: HttpServer) {}
|
||||||
|
|
||||||
|
getNodeById(server: Server, projectId: string, nodeId: string) {
|
||||||
|
return this.httpServer.get(server, `/projects/${projectId}/nodes/${nodeId}`);
|
||||||
|
}
|
||||||
|
|
||||||
start(server: Server, node: Node) {
|
start(server: Server, node: Node) {
|
||||||
return this.httpServer.post<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}/start`, {});
|
return this.httpServer.post<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}/start`, {});
|
||||||
}
|
}
|
||||||
@ -138,7 +142,7 @@ export class NodeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNode(server: Server, node: Node) {
|
getNode(server: Server, node: Node) {
|
||||||
return this.httpServer.get(server, `/projects/${node.project_id}/nodes/${node.node_id}`)
|
return this.httpServer.get(server, `/projects/${node.project_id}/nodes/${node.node_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCommand(): string {
|
getDefaultCommand(): string {
|
||||||
|
Reference in New Issue
Block a user