mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-23 14:52:22 +00:00
Round position of nodes and drawings during update to the closest integer
This commit is contained in:
parent
e76d6c4236
commit
f866741011
@ -58,6 +58,22 @@ describe('DrawingService', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should updatePosition of drawing and round to integer', inject([DrawingService], (service: DrawingService) => {
|
||||||
|
const drawing = new Drawing();
|
||||||
|
drawing.project_id = "myproject";
|
||||||
|
drawing.drawing_id = "id";
|
||||||
|
|
||||||
|
service.updatePosition(server, drawing, 10.1, 20.6).subscribe();
|
||||||
|
|
||||||
|
const req = httpTestingController.expectOne(
|
||||||
|
'http://127.0.0.1:3080/v2/projects/myproject/drawings/id');
|
||||||
|
expect(req.request.method).toEqual("PUT");
|
||||||
|
expect(req.request.body).toEqual({
|
||||||
|
'x': 10,
|
||||||
|
'y': 21
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should update size and position of drawing', inject([DrawingService], (service: DrawingService) => {
|
it('should update size and position of drawing', inject([DrawingService], (service: DrawingService) => {
|
||||||
const drawing = new Drawing();
|
const drawing = new Drawing();
|
||||||
drawing.project_id = "myproject";
|
drawing.project_id = "myproject";
|
||||||
@ -76,6 +92,24 @@ describe('DrawingService', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should update size and position of drawing and round to integer', inject([DrawingService], (service: DrawingService) => {
|
||||||
|
const drawing = new Drawing();
|
||||||
|
drawing.project_id = "myproject";
|
||||||
|
drawing.drawing_id = "id";
|
||||||
|
let svgSample = "<svg><test></svg>"
|
||||||
|
|
||||||
|
service.updateSizeAndPosition(server, drawing, 100.1, 100.6, svgSample).subscribe();
|
||||||
|
|
||||||
|
const req = httpTestingController.expectOne(
|
||||||
|
'http://127.0.0.1:3080/v2/projects/myproject/drawings/id');
|
||||||
|
expect(req.request.method).toEqual("PUT");
|
||||||
|
expect(req.request.body).toEqual({
|
||||||
|
'x': 100,
|
||||||
|
'y': 101,
|
||||||
|
'svg': svgSample
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should update drawing', inject([DrawingService], (service: DrawingService) => {
|
it('should update drawing', inject([DrawingService], (service: DrawingService) => {
|
||||||
const drawing = new Drawing();
|
const drawing = new Drawing();
|
||||||
drawing.project_id = "myproject";
|
drawing.project_id = "myproject";
|
||||||
|
@ -16,16 +16,16 @@ export class DrawingService {
|
|||||||
return this.httpServer
|
return this.httpServer
|
||||||
.post<Drawing>(server, `/projects/${project_id}/drawings`, {
|
.post<Drawing>(server, `/projects/${project_id}/drawings`, {
|
||||||
'svg': svg,
|
'svg': svg,
|
||||||
'x': x,
|
'x': Math.round(x),
|
||||||
'y': y
|
'y': Math.round(y)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePosition(server: Server, drawing: Drawing, x: number, y: number): Observable<Drawing> {
|
updatePosition(server: Server, drawing: Drawing, x: number, y: number): Observable<Drawing> {
|
||||||
return this.httpServer
|
return this.httpServer
|
||||||
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
||||||
'x': x,
|
'x': Math.round(x),
|
||||||
'y': y
|
'y': Math.round(y)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +33,8 @@ export class DrawingService {
|
|||||||
return this.httpServer
|
return this.httpServer
|
||||||
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
||||||
'svg': svg,
|
'svg': svg,
|
||||||
'x': x,
|
'x': Math.round(x),
|
||||||
'y': y
|
'y': Math.round(y)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ export class DrawingService {
|
|||||||
return this.httpServer
|
return this.httpServer
|
||||||
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
||||||
'svg': svg,
|
'svg': svg,
|
||||||
'x': drawing.x,
|
'x': Math.round(drawing.x),
|
||||||
'y': drawing.y,
|
'y': Math.round(drawing.y),
|
||||||
'z': drawing.z
|
'z': drawing.z
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -51,8 +51,8 @@ export class DrawingService {
|
|||||||
update(server: Server, drawing: Drawing): Observable<Drawing> {
|
update(server: Server, drawing: Drawing): Observable<Drawing> {
|
||||||
return this.httpServer
|
return this.httpServer
|
||||||
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
||||||
'x': drawing.x,
|
'x': Math.round(drawing.x),
|
||||||
'y': drawing.y,
|
'y': Math.round(drawing.y),
|
||||||
'z': drawing.z
|
'z': drawing.z
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,23 @@ describe('NodeService', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should updatePosition of node and round to integer', inject([NodeService], (service: NodeService) => {
|
||||||
|
const node = new Node();
|
||||||
|
node.project_id = "myproject";
|
||||||
|
node.node_id = "id";
|
||||||
|
|
||||||
|
service.updatePosition(server, node, 10.1, 20.6).subscribe();
|
||||||
|
|
||||||
|
const req = httpTestingController.expectOne(
|
||||||
|
'http://127.0.0.1:3080/v2/projects/myproject/nodes/id');
|
||||||
|
expect(req.request.method).toEqual("PUT");
|
||||||
|
expect(req.request.body).toEqual({
|
||||||
|
'x': 10,
|
||||||
|
'y': 21
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should update label of node', inject([NodeService], (service: NodeService) => {
|
it('should update label of node', inject([NodeService], (service: NodeService) => {
|
||||||
const node = new Node();
|
const node = new Node();
|
||||||
node.project_id = "myproject";
|
node.project_id = "myproject";
|
||||||
|
@ -38,8 +38,8 @@ export class NodeService {
|
|||||||
updatePosition(server: Server, node: Node, x: number, y: number): Observable<Node> {
|
updatePosition(server: Server, node: Node, x: number, y: number): Observable<Node> {
|
||||||
return this.httpServer
|
return this.httpServer
|
||||||
.put<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}`, {
|
.put<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}`, {
|
||||||
'x': x,
|
'x': Math.round(x),
|
||||||
'y': y
|
'y': Math.round(y)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user