mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-28 15:02:49 +00:00
Code clean
This commit is contained in:
parent
1d1cf149bb
commit
e279a1403f
@ -16,6 +16,7 @@ import { Subscription } from 'rxjs';
|
|||||||
import { InterfaceLabelWidget } from '../../widgets/interface-label';
|
import { InterfaceLabelWidget } from '../../widgets/interface-label';
|
||||||
import { SelectionTool } from '../../tools/selection-tool';
|
import { SelectionTool } from '../../tools/selection-tool';
|
||||||
import { MovingTool } from '../../tools/moving-tool';
|
import { MovingTool } from '../../tools/moving-tool';
|
||||||
|
import { LinksWidget } from '../../widgets/links';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -51,6 +52,7 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
protected element: ElementRef,
|
protected element: ElementRef,
|
||||||
protected d3Service: D3Service,
|
protected d3Service: D3Service,
|
||||||
protected nodesWidget: NodesWidget,
|
protected nodesWidget: NodesWidget,
|
||||||
|
protected linksWidget: LinksWidget,
|
||||||
protected interfaceLabelWidget: InterfaceLabelWidget,
|
protected interfaceLabelWidget: InterfaceLabelWidget,
|
||||||
protected selectionToolWidget: SelectionTool,
|
protected selectionToolWidget: SelectionTool,
|
||||||
protected movingToolWidget: MovingTool,
|
protected movingToolWidget: MovingTool,
|
||||||
@ -122,26 +124,21 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.createGraph(this.parentNativeElement);
|
this.createGraph(this.parentNativeElement);
|
||||||
}
|
}
|
||||||
this.context.size = this.getSize();
|
this.context.size = this.getSize();
|
||||||
|
|
||||||
|
this.onNodeDraggingSubscription = this.nodesWidget.onNodeDragging.subscribe((eventNode: NodeEvent) => {
|
||||||
|
const links = this.links.filter((link) => link.target.node_id === eventNode.node.node_id || link.source.node_id === eventNode.node.node_id)
|
||||||
|
|
||||||
|
links.forEach((link) => {
|
||||||
|
this.linksWidget.redrawLink(this.svg, link);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public createGraph(domElement: HTMLElement) {
|
public createGraph(domElement: HTMLElement) {
|
||||||
const rootElement = this.d3.select(domElement);
|
const rootElement = this.d3.select(domElement);
|
||||||
this.svg = rootElement.select<SVGSVGElement>('svg');
|
this.svg = rootElement.select<SVGSVGElement>('svg');
|
||||||
|
|
||||||
this.graphLayout.connect(this.svg, this.context);
|
this.graphLayout.connect(this.svg, this.context);
|
||||||
|
|
||||||
this.onNodeDraggingSubscription = this.graphLayout.getNodesWidget().onNodeDragging.subscribe((eventNode: NodeEvent) => {
|
|
||||||
const linksWidget = this.graphLayout.getLinksWidget();
|
|
||||||
|
|
||||||
const links = this.links.filter((link) => link.target.node_id === eventNode.node.node_id || link.source.node_id === eventNode.node.node_id)
|
|
||||||
|
|
||||||
links.forEach((link) => {
|
|
||||||
linksWidget.redrawLink(this.svg, link);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.graphLayout.draw(this.svg, this.context);
|
this.graphLayout.draw(this.svg, this.context);
|
||||||
|
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,14 +48,6 @@ export class GraphLayout implements Widget {
|
|||||||
return this.nodesWidget;
|
return this.nodesWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLinksWidget() {
|
|
||||||
return this.linksWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getDrawingsWidget() {
|
|
||||||
return this.drawingsWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getDrawingLineTool() {
|
public getDrawingLineTool() {
|
||||||
return this.drawingLineTool;
|
return this.drawingLineTool;
|
||||||
}
|
}
|
||||||
@ -98,7 +90,6 @@ export class GraphLayout implements Widget {
|
|||||||
layersManager.setDrawings(this.drawings);
|
layersManager.setDrawings(this.drawings);
|
||||||
layersManager.setLinks(this.links);
|
layersManager.setLinks(this.links);
|
||||||
|
|
||||||
this.layersWidget.graphLayout = this;
|
|
||||||
this.layersWidget.draw(canvas, layersManager.getLayersList());
|
this.layersWidget.draw(canvas, layersManager.getLayersList());
|
||||||
|
|
||||||
this.drawingLineTool.draw(view, context);
|
this.drawingLineTool.draw(view, context);
|
||||||
|
@ -4,11 +4,18 @@ import { Widget } from "./widget";
|
|||||||
import { SVGSelection } from "../models/types";
|
import { SVGSelection } from "../models/types";
|
||||||
import { GraphLayout } from "./graph-layout";
|
import { GraphLayout } from "./graph-layout";
|
||||||
import { Layer } from "../models/layer";
|
import { Layer } from "../models/layer";
|
||||||
|
import { LinksWidget } from "./links";
|
||||||
|
import { NodesWidget } from "./nodes";
|
||||||
|
import { DrawingsWidget } from "./drawings";
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LayersWidget implements Widget {
|
export class LayersWidget implements Widget {
|
||||||
public graphLayout: GraphLayout;
|
constructor(
|
||||||
|
private linksWidget: LinksWidget,
|
||||||
|
private nodesWidget: NodesWidget,
|
||||||
|
private drawingsWidget: DrawingsWidget
|
||||||
|
) {}
|
||||||
|
|
||||||
public draw(view: SVGSelection, layers: Layer[]) {
|
public draw(view: SVGSelection, layers: Layer[]) {
|
||||||
|
|
||||||
@ -56,18 +63,9 @@ export class LayersWidget implements Widget {
|
|||||||
.exit()
|
.exit()
|
||||||
.remove();
|
.remove();
|
||||||
|
|
||||||
// @FixMe
|
this.linksWidget.draw(links_container);
|
||||||
this.graphLayout
|
this.nodesWidget.draw(nodes_container);
|
||||||
.getLinksWidget()
|
this.drawingsWidget.draw(drawings_container);
|
||||||
.draw(links_container);
|
|
||||||
|
|
||||||
this.graphLayout
|
|
||||||
.getNodesWidget()
|
|
||||||
.draw(nodes_container);
|
|
||||||
|
|
||||||
this.graphLayout
|
|
||||||
.getDrawingsWidget()
|
|
||||||
.draw(drawings_container);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user