;
@ViewChild(MapComponent) mapChild: MapComponent;
+ @ViewChild(NodeContextMenuComponent) nodeContextMenu: NodeContextMenuComponent;
+
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
@@ -109,10 +112,9 @@ export class ProjectMapComponent implements OnInit {
n.icon = this.symbolService.get(n.symbol);
});
- this.setUpNodeActions();
+ this.setUpMapCallbacks(project);
this.setUpWS(project);
});
-
}
setUpWS(project: Project) {
@@ -171,16 +173,23 @@ export class ProjectMapComponent implements OnInit {
});
}
- setUpNodeActions() {
- this.mapChild.nodeContextMenu.clearActions();
- const start_node_action = new StartNodeAction(this.server, this.nodeService);
- this.mapChild.nodeContextMenu.registerAction(start_node_action);
-
- const stop_node_action = new StopNodeAction(this.server, this.nodeService);
- this.mapChild.nodeContextMenu.registerAction(stop_node_action);
+ setUpMapCallbacks(project: Project) {
+ this.mapChild.graphLayout.getNodesWidget().setOnContextMenuCallback((event: any, node: Node) => {
+ this.nodeContextMenu.open(node, event.clientY, event.clientX);
+ });
}
+ // setUpNodeActions() {
+ // this.mapChild.nodeContextMenu.clearActions();
+ //
+ // const start_node_action = new StartNodeAction(this.server, this.nodeService);
+ // this.mapChild.nodeContextMenu.registerAction(start_node_action);
+ //
+ // const stop_node_action = new StopNodeAction(this.server, this.nodeService);
+ // this.mapChild.nodeContextMenu.registerAction(stop_node_action);
+ // }
+
public createSnapshotModal() {
const dialogRef = this.dialog.open(CreateSnapshotDialogComponent, {
width: '250px',
diff --git a/src/app/shared/node-context-menu/actions/start-node-action.ts b/src/app/shared/node-context-menu/actions/start-node-action.ts
index 4274a826..7ea20ffa 100644
--- a/src/app/shared/node-context-menu/actions/start-node-action.ts
+++ b/src/app/shared/node-context-menu/actions/start-node-action.ts
@@ -20,6 +20,6 @@ export class StartNodeAction implements NodeContextMenuAction {
}
onClick(node: Node) {
- this.nodeService.start()
+ // this.nodeService.start()
}
}
diff --git a/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.html b/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.html
index 81565936..f3acc224 100644
--- a/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.html
+++ b/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.html
@@ -1,3 +1,4 @@
-
- start-node-action works!
-
+
diff --git a/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.scss b/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.scss
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.ts b/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.ts
index 16b2c37c..a2c6f65f 100644
--- a/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.ts
+++ b/src/app/shared/node-context-menu/actions/start-node-action/start-node-action.component.ts
@@ -1,15 +1,27 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, Input, OnInit} from '@angular/core';
+import {Server} from "../../../models/server";
+import {NodeService} from "../../../services/node.service";
+import {Node} from "../../../../cartography/shared/models/node.model";
+
@Component({
selector: 'app-start-node-action',
templateUrl: './start-node-action.component.html',
- styleUrls: ['./start-node-action.component.scss']
})
export class StartNodeActionComponent implements OnInit {
+ @Input() server: Server;
+ @Input() node: Node;
- constructor() { }
+ constructor(private nodeService: NodeService) { }
- ngOnInit() {
+ ngOnInit() {}
+
+ startNode() {
+ this.nodeService
+ .start(this.server, this.node)
+ .subscribe((n: Node) => {
+
+ });
}
}
diff --git a/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.html b/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.html
new file mode 100644
index 00000000..47f4016e
--- /dev/null
+++ b/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.html
@@ -0,0 +1,4 @@
+
diff --git a/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.spec.ts b/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.spec.ts
new file mode 100644
index 00000000..30228d8f
--- /dev/null
+++ b/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { StopNodeActionComponent } from './stop-node-action.component';
+
+describe('StopNodeActionComponent', () => {
+ let component: StopNodeActionComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ StopNodeActionComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(StopNodeActionComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.ts b/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.ts
new file mode 100644
index 00000000..5cb8fc47
--- /dev/null
+++ b/src/app/shared/node-context-menu/actions/stop-node-action/stop-node-action.component.ts
@@ -0,0 +1,27 @@
+import {Component, Input, OnInit} from '@angular/core';
+import {Server} from "../../../models/server";
+import {NodeService} from "../../../services/node.service";
+import {Node} from "../../../../cartography/shared/models/node.model";
+
+
+@Component({
+ selector: 'app-stop-node-action',
+ templateUrl: './stop-node-action.component.html'
+})
+export class StopNodeActionComponent implements OnInit {
+ @Input() server: Server;
+ @Input() node: Node;
+
+ constructor(private nodeService: NodeService) { }
+
+ ngOnInit() {
+ }
+
+ stopNode() {
+ this.nodeService
+ .stop(this.server, this.node)
+ .subscribe((n: Node) => {
+
+ });
+ }
+}
diff --git a/src/app/shared/node-context-menu/node-context-menu.component.html b/src/app/shared/node-context-menu/node-context-menu.component.html
index 8c0ec14e..9d669f5b 100644
--- a/src/app/shared/node-context-menu/node-context-menu.component.html
+++ b/src/app/shared/node-context-menu/node-context-menu.component.html
@@ -1,17 +1,7 @@
diff --git a/src/app/shared/node-context-menu/node-context-menu.component.ts b/src/app/shared/node-context-menu/node-context-menu.component.ts
index 1613e8bd..944bd9c2 100644
--- a/src/app/shared/node-context-menu/node-context-menu.component.ts
+++ b/src/app/shared/node-context-menu/node-context-menu.component.ts
@@ -2,7 +2,7 @@ import {ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/c
import {MatMenuTrigger} from "@angular/material";
import {DomSanitizer} from "@angular/platform-browser";
import {Node} from "../../cartography/shared/models/node.model";
-import {NodeContextMenuAction} from "./node-context-menu-action";
+import {Server} from "../models/server";
@Component({
@@ -11,12 +11,13 @@ import {NodeContextMenuAction} from "./node-context-menu-action";
styleUrls: ['./node-context-menu.component.scss']
})
export class NodeContextMenuComponent implements OnInit {
+ @Input() server: Server;
+
@ViewChild(MatMenuTrigger) contextMenu: MatMenuTrigger;
private topPosition;
private leftPosition;
private node: Node;
- private actions: NodeContextMenuAction[] = [];
constructor(
private sanitizer: DomSanitizer,
@@ -38,12 +39,4 @@ export class NodeContextMenuComponent implements OnInit {
this.contextMenu.openMenu();
}
- public registerAction(action: NodeContextMenuAction) {
- this.actions.push(action);
- }
-
- public clearActions() {
- this.actions = [];
- }
-
}