diff --git a/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts b/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts index 0c8f096a..73cf9ddd 100644 --- a/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/http-console-new-tab/http-console-new-tab-action.component.ts @@ -1,8 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; +import { NodeConsoleService } from '../../../../../services/nodeConsole.service'; import { Node } from '../../../../../cartography/models/node'; import { Server } from '../../../../../models/server'; -import { ToasterService } from '../../../../../services/toaster.service'; @Component({ selector: 'app-http-console-new-tab-action', @@ -12,19 +11,11 @@ export class HttpConsoleNewTabActionComponent implements OnInit { @Input() server: Server; @Input() nodes: Node[]; - constructor(private toasterService: ToasterService, private router: Router) {} + constructor(private nodeConsoleService: NodeConsoleService) {} ngOnInit() {} openConsole() { - this.nodes.forEach((n) => { - if (n.status === 'started') { - let url = this.router.url.split('/'); - let urlString = `/static/web-ui/${url[1]}/${url[2]}/${url[3]}/${url[4]}/nodes/${n.node_id}`; - window.open(urlString); - } else { - this.toasterService.error('To open console please start the node ' + n.name); - } - }); + this.nodeConsoleService.openConsolesForAllNodesInNewTabs(this.nodes); } } diff --git a/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts b/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts index 36e3ab37..523cdb4c 100644 --- a/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/http-console/http-console-action.component.ts @@ -1,9 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { Node } from '../../../../../cartography/models/node'; import { Server } from '../../../../../models/server'; -import { MapSettingsService } from '../../../../../services/mapsettings.service'; import { NodeConsoleService } from '../../../../../services/nodeConsole.service'; -import { ToasterService } from '../../../../../services/toaster.service'; @Component({ selector: 'app-http-console-action', @@ -13,23 +11,11 @@ export class HttpConsoleActionComponent implements OnInit { @Input() server: Server; @Input() nodes: Node[]; - constructor( - private consoleService: NodeConsoleService, - private toasterService: ToasterService, - private mapSettingsService: MapSettingsService - ) {} + constructor(private nodeConsoleService: NodeConsoleService) {} ngOnInit() {} openConsole() { - this.nodes.forEach((n) => { - if (n.status === 'started') { - this.mapSettingsService.logConsoleSubject.next(true); - // this timeout is required due to xterm.js implementation - setTimeout(() => { this.consoleService.openConsoleForNode(n); }, 500); - } else { - this.toasterService.error('To open console please start the node ' + n.name); - } - }); + this.nodeConsoleService.openConsolesForAllNodesInWidget(this.nodes); } } diff --git a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts index 1bcfd7c4..a1debfd8 100644 --- a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts +++ b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts @@ -1,4 +1,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { MapSettingsService } from '../../../services/mapsettings.service'; import { ElectronService } from 'ngx-electron'; import { NodesDataSource } from '../../../cartography/datasources/nodes-datasource'; import { Project } from '../../../models/project'; @@ -7,6 +8,7 @@ import { NodeService } from '../../../services/node.service'; import { ServerService } from '../../../services/server.service'; import { SettingsService } from '../../../services/settings.service'; import { ToasterService } from '../../../services/toaster.service'; +import { NodeConsoleService } from '../../../services/nodeConsole.service'; @Component({ selector: 'app-nodes-menu', @@ -20,10 +22,12 @@ export class NodesMenuComponent { constructor( private nodeService: NodeService, + private nodeConsoleService: NodeConsoleService, private nodesDataSource: NodesDataSource, private toasterService: ToasterService, private serverService: ServerService, private settingsService: SettingsService, + private mapSettingsService: MapSettingsService, private electronService: ElectronService ) {} @@ -48,7 +52,11 @@ export class NodesMenuComponent { await this.electronService.remote.require('./console-executor.js').openConsole(request); } } else { - this.toasterService.error('Option to start all nodes not available in web browser.'); + if (this.mapSettingsService.openConsolesInWidget) { + this.nodeConsoleService.openConsolesForAllNodesInWidget(this.nodesDataSource.getItems()); + } else { + this.nodeConsoleService.openConsolesForAllNodesInNewTabs(this.nodesDataSource.getItems()); + } } } diff --git a/src/app/components/settings/settings.component.html b/src/app/components/settings/settings.component.html index dd09dcf4..9f725333 100644 --- a/src/app/components/settings/settings.component.html +++ b/src/app/components/settings/settings.component.html @@ -11,7 +11,8 @@