diff --git a/src/app/components/web-console-full-window/web-console-full-window.component.ts b/src/app/components/web-console-full-window/web-console-full-window.component.ts index 9c7a55c9..d525fb8c 100644 --- a/src/app/components/web-console-full-window/web-console-full-window.component.ts +++ b/src/app/components/web-console-full-window/web-console-full-window.component.ts @@ -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` } } diff --git a/src/app/services/node.service.ts b/src/app/services/node.service.ts index 50914980..1231408c 100644 --- a/src/app/services/node.service.ts +++ b/src/app/services/node.service.ts @@ -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(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 {