From abdd739f064b107b653bf058b187fd65c2f839cb Mon Sep 17 00:00:00 2001
From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com>
Date: Tue, 11 May 2021 01:35:07 +0200
Subject: [PATCH 01/35] Console in new tab for many nodes at one click
---
.../http-console-new-tab-action.component.ts | 2 +-
.../project-map/context-menu/context-menu.component.html | 2 +-
src/app/components/project-map/project-map.component.html | 1 -
src/app/components/project-map/project-map.component.ts | 8 --------
src/index.html | 2 +-
5 files changed, 3 insertions(+), 12 deletions(-)
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 42624197..0c8f096a 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
@@ -23,7 +23,7 @@ export class HttpConsoleNewTabActionComponent implements OnInit {
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');
+ this.toasterService.error('To open console please start the node ' + n.name);
}
});
}
diff --git a/src/app/components/project-map/context-menu/context-menu.component.html b/src/app/components/project-map/context-menu/context-menu.component.html
index 9dc61b2f..63bba5b6 100644
--- a/src/app/components/project-map/context-menu/context-menu.component.html
+++ b/src/app/components/project-map/context-menu/context-menu.component.html
@@ -13,7 +13,7 @@
[nodes]="nodes"
>
0"
[server]="server"
[nodes]="nodes"
>
diff --git a/src/app/components/project-map/project-map.component.html b/src/app/components/project-map/project-map.component.html
index b4e24a25..686d5306 100644
--- a/src/app/components/project-map/project-map.component.html
+++ b/src/app/components/project-map/project-map.component.html
@@ -64,7 +64,6 @@
-
diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts
index e74201ba..db9f6370 100644
--- a/src/app/components/project-map/project-map.component.ts
+++ b/src/app/components/project-map/project-map.component.ts
@@ -74,7 +74,6 @@ import { ImportProjectDialogComponent } from '../projects/import-project-dialog/
import { NavigationDialogComponent } from '../projects/navigation-dialog/navigation-dialog.component';
import { SaveProjectDialogComponent } from '../projects/save-project-dialog/save-project-dialog.component';
import { NodeAddedEvent } from '../template/template-list-dialog/template-list-dialog.component';
-import { ContextConsoleMenuComponent } from './context-console-menu/context-console-menu.component';
import { ContextMenuComponent } from './context-menu/context-menu.component';
import { NodeCreatedLabelStylesFixer } from './helpers/node-created-label-styles-fixer';
import { NewTemplateDialogComponent } from './new-template-dialog/new-template-dialog.component';
@@ -120,7 +119,6 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
public isLightThemeEnabled: boolean = false;
@ViewChild(ContextMenuComponent) contextMenu: ContextMenuComponent;
- @ViewChild(ContextConsoleMenuComponent) consoleContextMenu: ContextConsoleMenuComponent;
@ViewChild(D3MapComponent) mapChild: D3MapComponent;
@ViewChild(ProjectMapMenuComponent) projectMapMenuComponent: ProjectMapMenuComponent;
@@ -513,11 +511,6 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.contextMenu.openMenuForListOfElements(drawings, nodes, labels, links, event.pageY, event.pageX);
});
- const onContextConsoleMenu = this.nodeWidget.onContextConsoleMenu.subscribe((eventNode: NodeContextMenu) => {
- const node = this.mapNodeToNode.convert(eventNode.node);
- this.consoleContextMenu.openMenu(node, eventNode.event.pageY, eventNode.event.pageX);
- });
-
this.projectMapSubscription.add(onLinkContextMenu);
this.projectMapSubscription.add(onEthernetLinkContextMenu);
this.projectMapSubscription.add(onSerialLinkContextMenu);
@@ -526,7 +519,6 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.projectMapSubscription.add(onContextMenu);
this.projectMapSubscription.add(onLabelContextMenu);
this.projectMapSubscription.add(onInterfaceLabelContextMenu);
- this.projectMapSubscription.add(onContextConsoleMenu);
this.mapChangeDetectorRef.detectChanges();
}
diff --git a/src/index.html b/src/index.html
index 4ae7015b..0332bc23 100644
--- a/src/index.html
+++ b/src/index.html
@@ -35,7 +35,7 @@
-
+
From 9fd34e8253900940634e828235a786919db1fa37 Mon Sep 17 00:00:00 2001
From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com>
Date: Tue, 11 May 2021 02:09:40 +0200
Subject: [PATCH 02/35] Opening more than 1 console with one click in console
widget
---
.../actions/http-console/http-console-action.component.ts | 5 +++--
.../project-map/context-menu/context-menu.component.html | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
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 6486d9a0..36e3ab37 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
@@ -25,9 +25,10 @@ export class HttpConsoleActionComponent implements OnInit {
this.nodes.forEach((n) => {
if (n.status === 'started') {
this.mapSettingsService.logConsoleSubject.next(true);
- this.consoleService.openConsoleForNode(n);
+ // 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');
+ this.toasterService.error('To open console please start the node ' + n.name);
}
});
}
diff --git a/src/app/components/project-map/context-menu/context-menu.component.html b/src/app/components/project-map/context-menu/context-menu.component.html
index 63bba5b6..eb81e95e 100644
--- a/src/app/components/project-map/context-menu/context-menu.component.html
+++ b/src/app/components/project-map/context-menu/context-menu.component.html
@@ -8,7 +8,7 @@
0"
[server]="server"
[nodes]="nodes"
>
From cf2f0e311049e74243c61db572b4969245ff5563 Mon Sep 17 00:00:00 2001
From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com>
Date: Tue, 11 May 2021 14:57:42 +0200
Subject: [PATCH 03/35] Fix for https://github.com/GNS3/gns3-web-ui/issues/1132
---
.../http-console-new-tab-action.component.ts | 15 ++----
.../http-console-action.component.ts | 18 +-------
.../nodes-menu/nodes-menu.component.ts | 10 +++-
.../settings/settings.component.html | 3 +-
.../components/settings/settings.component.ts | 3 ++
src/app/services/mapsettings.service.ts | 14 +++++-
src/app/services/nodeConsole.service.ts | 46 ++++++++++++++++++-
7 files changed, 77 insertions(+), 32 deletions(-)
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 @@
Send anonymous crash reports
- Integrate link labels to links
+ Integrate link labels to links
+ Open consoles in the widget instead of in new tabs after clicking start consoles for all nodes