mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-22 14:22:21 +00:00
Unit tests fixed
This commit is contained in:
parent
8764a417d3
commit
a242c1c66f
@ -96,6 +96,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
|
|||||||
const selected = this.selectionManager.getSelected();
|
const selected = this.selectionManager.getSelected();
|
||||||
// update nodes
|
// update nodes
|
||||||
let mapNodes = selected.filter(item => item instanceof MapNode);
|
let mapNodes = selected.filter(item => item instanceof MapNode);
|
||||||
|
const lockedNodes = mapNodes.filter((item: MapNode) => item.locked);
|
||||||
const selectedNodes = mapNodes.filter((item: MapNode) => !item.locked);
|
const selectedNodes = mapNodes.filter((item: MapNode) => !item.locked);
|
||||||
selectedNodes.forEach((node: MapNode) => {
|
selectedNodes.forEach((node: MapNode) => {
|
||||||
node.x += evt.dx;
|
node.x += evt.dx;
|
||||||
@ -127,7 +128,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// update labels
|
// update labels
|
||||||
let mapLabels = selected.filter(item => item instanceof MapLabel);
|
let mapLabels = selected.filter(item => item instanceof MapLabel);
|
||||||
const selectedLabels = mapLabels.filter((item: MapLabel) => selectedNodes.filter((node) => node.id === item.nodeId).length > 0);
|
const selectedLabels = mapLabels.filter((item: MapLabel) => lockedNodes.filter((node) => node.id === item.nodeId).length === 0);
|
||||||
selectedLabels.forEach((label: MapLabel) => {
|
selectedLabels.forEach((label: MapLabel) => {
|
||||||
const isParentNodeSelected = selectedNodes.filter(node => node.id === label.nodeId).length > 0;
|
const isParentNodeSelected = selectedNodes.filter(node => node.id === label.nodeId).length > 0;
|
||||||
if (isParentNodeSelected) {
|
if (isParentNodeSelected) {
|
||||||
@ -142,7 +143,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// update interface labels
|
// update interface labels
|
||||||
let mapLinkNodes = selected.filter(item => item instanceof MapLinkNode);
|
let mapLinkNodes = selected.filter(item => item instanceof MapLinkNode);
|
||||||
const selectedLinkNodes = mapLinkNodes.filter((item: MapLinkNode) => selectedNodes.filter((node) => node.id === item.nodeId).length > 0);
|
const selectedLinkNodes = mapLinkNodes.filter((item: MapLinkNode) => lockedNodes.filter((node) => node.id === item.nodeId).length === 0);
|
||||||
selectedLinkNodes.forEach((interfaceLabel: MapLinkNode) => {
|
selectedLinkNodes.forEach((interfaceLabel: MapLinkNode) => {
|
||||||
const isParentNodeSelected = selectedNodes.filter(node => node.id === interfaceLabel.nodeId).length > 0;
|
const isParentNodeSelected = selectedNodes.filter(node => node.id === interfaceLabel.nodeId).length > 0;
|
||||||
if (isParentNodeSelected) {
|
if (isParentNodeSelected) {
|
||||||
@ -176,6 +177,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
|
|||||||
const selected = this.selectionManager.getSelected();
|
const selected = this.selectionManager.getSelected();
|
||||||
|
|
||||||
let mapNodes = selected.filter(item => item instanceof MapNode);
|
let mapNodes = selected.filter(item => item instanceof MapNode);
|
||||||
|
const lockedNodes = mapNodes.filter((item: MapNode) => item.locked);
|
||||||
const selectedNodes = mapNodes.filter((item: MapNode) => !item.locked);
|
const selectedNodes = mapNodes.filter((item: MapNode) => !item.locked);
|
||||||
selectedNodes.forEach((item: MapNode) => {
|
selectedNodes.forEach((item: MapNode) => {
|
||||||
this.nodesEventSource.dragged.emit(new DraggedDataEvent<MapNode>(item, evt.dx, evt.dy));
|
this.nodesEventSource.dragged.emit(new DraggedDataEvent<MapNode>(item, evt.dx, evt.dy));
|
||||||
@ -188,7 +190,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mapLabels = selected.filter(item => item instanceof MapLabel);
|
let mapLabels = selected.filter(item => item instanceof MapLabel);
|
||||||
const selectedLabels = mapLabels.filter((item: MapLabel) => selectedNodes.filter((node) => node.id === item.nodeId).length > 0);
|
const selectedLabels = mapLabels.filter((item: MapLabel) => lockedNodes.filter((node) => node.id === item.nodeId).length === 0);
|
||||||
selectedLabels.forEach((label: MapLabel) => {
|
selectedLabels.forEach((label: MapLabel) => {
|
||||||
const isParentNodeSelected = selectedNodes.filter(node => node.id === label.nodeId).length > 0;
|
const isParentNodeSelected = selectedNodes.filter(node => node.id === label.nodeId).length > 0;
|
||||||
if (isParentNodeSelected) {
|
if (isParentNodeSelected) {
|
||||||
@ -199,7 +201,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mapLinkNodes = selected.filter(item => item instanceof MapLinkNode);
|
let mapLinkNodes = selected.filter(item => item instanceof MapLinkNode);
|
||||||
const selectedLinkNodes = mapLinkNodes.filter((item: MapLinkNode) => selectedNodes.filter((node) => node.id === item.nodeId).length > 0);
|
const selectedLinkNodes = mapLinkNodes.filter((item: MapLinkNode) => lockedNodes.filter((node) => node.id === item.nodeId).length === 0)
|
||||||
selectedLinkNodes.forEach((label: MapLinkNode) => {
|
selectedLinkNodes.forEach((label: MapLinkNode) => {
|
||||||
const isParentNodeSelected = selectedNodes.filter(node => node.id === label.nodeId).length > 0;
|
const isParentNodeSelected = selectedNodes.filter(node => node.id === label.nodeId).length > 0;
|
||||||
if (isParentNodeSelected) {
|
if (isParentNodeSelected) {
|
||||||
|
@ -48,6 +48,7 @@ describe('DrawingDraggedComponent', () => {
|
|||||||
};
|
};
|
||||||
const mapDrawing: MapDrawing = {
|
const mapDrawing: MapDrawing = {
|
||||||
id: 'sampleId',
|
id: 'sampleId',
|
||||||
|
locked: false,
|
||||||
projectId: 'sampleprojectId',
|
projectId: 'sampleprojectId',
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
svg: 'sampleSvg',
|
svg: 'sampleSvg',
|
||||||
|
@ -51,6 +51,7 @@ describe('DrawingResizedComponent', () => {
|
|||||||
};
|
};
|
||||||
const mapDrawing: MapDrawing = {
|
const mapDrawing: MapDrawing = {
|
||||||
id: 'sampleId',
|
id: 'sampleId',
|
||||||
|
locked: false,
|
||||||
projectId: 'sampleprojectId',
|
projectId: 'sampleprojectId',
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
svg: 'sampleSvg',
|
svg: 'sampleSvg',
|
||||||
|
@ -72,6 +72,7 @@ describe('LinkCreatedComponent', () => {
|
|||||||
firstPortName: 'sampleFirstPortName',
|
firstPortName: 'sampleFirstPortName',
|
||||||
height: 0,
|
height: 0,
|
||||||
label: {} as MapLabel,
|
label: {} as MapLabel,
|
||||||
|
locked: false,
|
||||||
name: 'sampleName',
|
name: 'sampleName',
|
||||||
nodeDirectory: 'sampleNodeDirectory',
|
nodeDirectory: 'sampleNodeDirectory',
|
||||||
nodeType: 'sampleNodeType',
|
nodeType: 'sampleNodeType',
|
||||||
|
@ -52,6 +52,7 @@ describe('NodeDraggedComponent', () => {
|
|||||||
firstPortName: 'sampleFirstPortName',
|
firstPortName: 'sampleFirstPortName',
|
||||||
height: 0,
|
height: 0,
|
||||||
label: {} as MapLabel,
|
label: {} as MapLabel,
|
||||||
|
locked: false,
|
||||||
name: 'sampleName',
|
name: 'sampleName',
|
||||||
nodeDirectory: 'sampleNodeDirectory',
|
nodeDirectory: 'sampleNodeDirectory',
|
||||||
nodeType: 'sampleNodeType',
|
nodeType: 'sampleNodeType',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<button mat-menu-item (click)="lock()">
|
<button mat-menu-item (click)="lock()">
|
||||||
<mat-icon>lock</mat-icon>
|
<mat-icon>lock</mat-icon>
|
||||||
<span>Lock</span>
|
<span>{{command}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -111,6 +111,7 @@ describe('DrawingService', () => {
|
|||||||
drawing.z = 30;
|
drawing.z = 30;
|
||||||
drawing.rotation = 0;
|
drawing.rotation = 0;
|
||||||
drawing.svg = '<svg></svg>';
|
drawing.svg = '<svg></svg>';
|
||||||
|
drawing.locked = false;
|
||||||
|
|
||||||
service.update(server, drawing).subscribe();
|
service.update(server, drawing).subscribe();
|
||||||
|
|
||||||
@ -121,7 +122,8 @@ describe('DrawingService', () => {
|
|||||||
y: 20,
|
y: 20,
|
||||||
z: 30,
|
z: 30,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
svg: '<svg></svg>'
|
svg: '<svg></svg>',
|
||||||
|
locked: false
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user