mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-18 10:46:35 +00:00
Manually select nodes and links
This commit is contained in:
parent
28ead48c40
commit
b819e106fc
@ -1,6 +1,7 @@
|
||||
import { Subject} from "rxjs/Subject";
|
||||
|
||||
import { Node } from "../models/node";
|
||||
import { Link } from "../models/link";
|
||||
import { Rectangle } from "../models/rectangle";
|
||||
import { SelectionManager } from "./selection-manager";
|
||||
import { NodesDataSource } from "../datasources/nodes-datasource";
|
||||
@ -54,4 +55,13 @@ describe('SelectionManager', () => {
|
||||
expect(manager.getSelectedLinks().length).toEqual(0);
|
||||
});
|
||||
|
||||
it('nodes should be manually selected', () => {
|
||||
manager.setSelectedNodes([new Node()]);
|
||||
expect(manager.getSelectedNodes().length).toEqual(1);
|
||||
});
|
||||
|
||||
it('links should be manually selected', () => {
|
||||
manager.setSelectedLinks([new Link()]);
|
||||
expect(manager.getSelectedLinks().length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
@ -8,7 +8,7 @@ import { LinksDataSource } from "../datasources/links-datasource";
|
||||
import { Node } from "../models/node";
|
||||
import { InRectangleHelper } from "../../map/helpers/in-rectangle-helper";
|
||||
import { Rectangle } from "../models/rectangle";
|
||||
import { Link } from "../models/link";
|
||||
import { Link} from "../models/link";
|
||||
import { DataSource } from "../datasources/datasource";
|
||||
|
||||
|
||||
@ -44,6 +44,14 @@ export class SelectionManager {
|
||||
return this.selectedLinks;
|
||||
}
|
||||
|
||||
public setSelectedNodes(nodes: Node[]) {
|
||||
this.selectedNodes = nodes;
|
||||
}
|
||||
|
||||
public setSelectedLinks(links: Link[]) {
|
||||
this.selectedLinks = links;
|
||||
}
|
||||
|
||||
private getSelectedItemsInRectangle<T extends Selectable>(dataSource: DataSource<T>, rectangle: Rectangle) {
|
||||
const items: T[] = [];
|
||||
dataSource.getItems().forEach((item: T) => {
|
||||
|
Loading…
Reference in New Issue
Block a user