From 647dde1bb40d8a55c6a2a474d6c2e6e3bf44d594 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 26 Aug 2019 19:51:03 +0700 Subject: [PATCH] Make x,y optional for creating links via API. Fixes #1630 --- gns3server/controller/link.py | 5 +---- gns3server/schemas/label.py | 4 +--- tests/controller/test_link.py | 25 +++++-------------------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/gns3server/controller/link.py b/gns3server/controller/link.py index 60e19612..6700babc 100644 --- a/gns3server/controller/link.py +++ b/gns3server/controller/link.py @@ -248,11 +248,8 @@ class Link: if label is None: label = { - "x": -10, - "y": -10, - "rotation": 0, "text": html.escape("{}/{}".format(adapter_number, port_number)), - "style": "font-size: 10; font-style: Verdana" + "style": "font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;" } self._nodes.append({ diff --git a/gns3server/schemas/label.py b/gns3server/schemas/label.py index eb5c2de1..503ea64b 100644 --- a/gns3server/schemas/label.py +++ b/gns3server/schemas/label.py @@ -39,9 +39,7 @@ LABEL_OBJECT_SCHEMA = { }, }, "required": [ - "text", - "x", - "y" + "text" ], "additionalProperties": False } diff --git a/tests/controller/test_link.py b/tests/controller/test_link.py index 38797c2a..41b9fc30 100644 --- a/tests/controller/test_link.py +++ b/tests/controller/test_link.py @@ -78,11 +78,8 @@ def test_add_node(async_run, project, compute): "adapter_number": 0, "port_number": 4, 'label': { - 'y': -10, 'text': '0/4', - 'x': -10, - 'rotation': 0, - 'style': 'font-size: 10; font-style: Verdana' + 'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;' } } ] @@ -210,11 +207,8 @@ def test_json(async_run, project, compute, link): "adapter_number": 0, "port_number": 4, 'label': { - 'y': -10, 'text': '0/4', - 'x': -10, - 'rotation': 0, - 'style': 'font-size: 10; font-style: Verdana' + 'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;' } }, { @@ -222,11 +216,8 @@ def test_json(async_run, project, compute, link): "adapter_number": 1, "port_number": 3, 'label': { - 'y': -10, 'text': '1/3', - 'x': -10, - 'rotation': 0, - 'style': 'font-size: 10; font-style: Verdana' + 'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;' } } ], @@ -246,11 +237,8 @@ def test_json(async_run, project, compute, link): "adapter_number": 0, "port_number": 4, 'label': { - 'y': -10, 'text': '0/4', - 'x': -10, - 'rotation': 0, - 'style': 'font-size: 10; font-style: Verdana' + 'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;' } }, { @@ -258,11 +246,8 @@ def test_json(async_run, project, compute, link): "adapter_number": 1, "port_number": 3, 'label': { - 'y': -10, 'text': '1/3', - 'x': -10, - 'rotation': 0, - 'style': 'font-size: 10; font-style: Verdana' + 'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;' } } ],