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