mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Handle locking/unlocking items independently from the layer position.
This commit is contained in:
parent
3f7c4c0474
commit
724eda1f35
@ -37,7 +37,7 @@ class Drawing:
|
|||||||
text, images, rectangle... They are pure SVG elements.
|
text, images, rectangle... They are pure SVG elements.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, project, drawing_id=None, svg="<svg></svg>", x=0, y=0, z=2, rotation=0):
|
def __init__(self, project, drawing_id=None, svg="<svg></svg>", x=0, y=0, z=2, locked=False, rotation=0):
|
||||||
self._project = project
|
self._project = project
|
||||||
if drawing_id is None:
|
if drawing_id is None:
|
||||||
self._id = str(uuid.uuid4())
|
self._id = str(uuid.uuid4())
|
||||||
@ -49,6 +49,7 @@ class Drawing:
|
|||||||
self._y = y
|
self._y = y
|
||||||
self._z = z
|
self._z = z
|
||||||
self._rotation = rotation
|
self._rotation = rotation
|
||||||
|
self._locked = locked
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
@ -157,6 +158,14 @@ class Drawing:
|
|||||||
def z(self, val):
|
def z(self, val):
|
||||||
self._z = val
|
self._z = val
|
||||||
|
|
||||||
|
@property
|
||||||
|
def locked(self):
|
||||||
|
return self._locked
|
||||||
|
|
||||||
|
@locked.setter
|
||||||
|
def locked(self, val):
|
||||||
|
self._locked = val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rotation(self):
|
def rotation(self):
|
||||||
return self._rotation
|
return self._rotation
|
||||||
@ -198,6 +207,7 @@ class Drawing:
|
|||||||
"x": self._x,
|
"x": self._x,
|
||||||
"y": self._y,
|
"y": self._y,
|
||||||
"z": self._z,
|
"z": self._z,
|
||||||
|
"locked": self._locked,
|
||||||
"rotation": self._rotation,
|
"rotation": self._rotation,
|
||||||
"svg": self._svg
|
"svg": self._svg
|
||||||
}
|
}
|
||||||
@ -207,6 +217,7 @@ class Drawing:
|
|||||||
"x": self._x,
|
"x": self._x,
|
||||||
"y": self._y,
|
"y": self._y,
|
||||||
"z": self._z,
|
"z": self._z,
|
||||||
|
"locked": self._locked,
|
||||||
"rotation": self._rotation,
|
"rotation": self._rotation,
|
||||||
"svg": self.svg
|
"svg": self.svg
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class Node:
|
class Node:
|
||||||
# This properties are used only on controller and are not forwarded to the compute
|
# This properties are used only on controller and are not forwarded to the compute
|
||||||
CONTROLLER_ONLY_PROPERTIES = ["x", "y", "z", "width", "height", "symbol", "label", "console_host",
|
CONTROLLER_ONLY_PROPERTIES = ["x", "y", "z", "locked", "width", "height", "symbol", "label", "console_host",
|
||||||
"port_name_format", "first_port_name", "port_segment_size", "ports",
|
"port_name_format", "first_port_name", "port_segment_size", "ports",
|
||||||
"category", "console_auto_start"]
|
"category", "console_auto_start"]
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ class Node:
|
|||||||
self._x = 0
|
self._x = 0
|
||||||
self._y = 0
|
self._y = 0
|
||||||
self._z = 1 # default z value is 1
|
self._z = 1 # default z value is 1
|
||||||
|
self._locked = False
|
||||||
self._ports = None
|
self._ports = None
|
||||||
self._symbol = None
|
self._symbol = None
|
||||||
self._custom_adapters = []
|
self._custom_adapters = []
|
||||||
@ -236,6 +237,14 @@ class Node:
|
|||||||
def z(self, val):
|
def z(self, val):
|
||||||
self._z = val
|
self._z = val
|
||||||
|
|
||||||
|
@property
|
||||||
|
def locked(self):
|
||||||
|
return self._locked
|
||||||
|
|
||||||
|
@locked.setter
|
||||||
|
def locked(self, val):
|
||||||
|
self._locked = val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def width(self):
|
def width(self):
|
||||||
return self._width
|
return self._width
|
||||||
@ -681,6 +690,7 @@ class Node:
|
|||||||
"x": self._x,
|
"x": self._x,
|
||||||
"y": self._y,
|
"y": self._y,
|
||||||
"z": self._z,
|
"z": self._z,
|
||||||
|
"locked": self._locked,
|
||||||
"width": self._width,
|
"width": self._width,
|
||||||
"height": self._height,
|
"height": self._height,
|
||||||
"symbol": self._symbol,
|
"symbol": self._symbol,
|
||||||
@ -708,6 +718,7 @@ class Node:
|
|||||||
"x": self._x,
|
"x": self._x,
|
||||||
"y": self._y,
|
"y": self._y,
|
||||||
"z": self._z,
|
"z": self._z,
|
||||||
|
"locked": self._locked,
|
||||||
"width": self._width,
|
"width": self._width,
|
||||||
"height": self._height,
|
"height": self._height,
|
||||||
"symbol": self._symbol,
|
"symbol": self._symbol,
|
||||||
|
@ -160,7 +160,7 @@ def load_topology(path):
|
|||||||
topo = _convert_2_1_0(topo, path)
|
topo = _convert_2_1_0(topo, path)
|
||||||
|
|
||||||
# Version GNS3 2.2 dev (for project created with 2.2dev).
|
# Version GNS3 2.2 dev (for project created with 2.2dev).
|
||||||
# Appliance ID has been repleace by Template ID
|
# Appliance ID has been replaced by Template ID
|
||||||
if topo["revision"] == 9:
|
if topo["revision"] == 9:
|
||||||
for node in topo.get("topology", {}).get("nodes", []):
|
for node in topo.get("topology", {}).get("nodes", []):
|
||||||
if "appliance_id" in node:
|
if "appliance_id" in node:
|
||||||
@ -177,7 +177,7 @@ def load_topology(path):
|
|||||||
try:
|
try:
|
||||||
with open(path, "w+", encoding="utf-8") as f:
|
with open(path, "w+", encoding="utf-8") as f:
|
||||||
json.dump(topo, f, indent=4, sort_keys=True)
|
json.dump(topo, f, indent=4, sort_keys=True)
|
||||||
except (OSError) as e:
|
except OSError as e:
|
||||||
raise aiohttp.web.HTTPConflict(text="Can't write the topology {}: {}".format(path, str(e)))
|
raise aiohttp.web.HTTPConflict(text="Can't write the topology {}: {}".format(path, str(e)))
|
||||||
return topo
|
return topo
|
||||||
|
|
||||||
|
@ -47,6 +47,10 @@ DRAWING_OBJECT_SCHEMA = {
|
|||||||
"description": "Z property",
|
"description": "Z property",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"locked": {
|
||||||
|
"description": "Whether the element locked or not",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"rotation": {
|
"rotation": {
|
||||||
"description": "Rotation of the element",
|
"description": "Rotation of the element",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -193,6 +193,10 @@ NODE_OBJECT_SCHEMA = {
|
|||||||
"description": "Z position of the node",
|
"description": "Z position of the node",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"locked": {
|
||||||
|
"description": "Whether the element locked or not",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"port_name_format": {
|
"port_name_format": {
|
||||||
"description": "Formating for port name {0} will be replace by port number",
|
"description": "Formating for port name {0} will be replace by port number",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -280,6 +284,10 @@ NODE_DUPLICATE_SCHEMA = {
|
|||||||
"z": {
|
"z": {
|
||||||
"description": "Z position of the node",
|
"description": "Z position of the node",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"description": "Whether the element locked or not",
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
|
@ -56,6 +56,7 @@ def test_json(project):
|
|||||||
"x": i.x,
|
"x": i.x,
|
||||||
"y": i.y,
|
"y": i.y,
|
||||||
"z": i.z,
|
"z": i.z,
|
||||||
|
"locked": i.locked,
|
||||||
"svg": i.svg,
|
"svg": i.svg,
|
||||||
"rotation": i.rotation
|
"rotation": i.rotation
|
||||||
}
|
}
|
||||||
@ -65,6 +66,7 @@ def test_json(project):
|
|||||||
"y": i.y,
|
"y": i.y,
|
||||||
"z": i.z,
|
"z": i.z,
|
||||||
"rotation": i.rotation,
|
"rotation": i.rotation,
|
||||||
|
"locked": i.locked,
|
||||||
"svg": i.svg
|
"svg": i.svg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ def test_json(node, compute):
|
|||||||
"x": node.x,
|
"x": node.x,
|
||||||
"y": node.y,
|
"y": node.y,
|
||||||
"z": node.z,
|
"z": node.z,
|
||||||
|
"locked": node.locked,
|
||||||
"width": node.width,
|
"width": node.width,
|
||||||
"height": node.height,
|
"height": node.height,
|
||||||
"symbol": node.symbol,
|
"symbol": node.symbol,
|
||||||
@ -167,6 +168,7 @@ def test_json(node, compute):
|
|||||||
"x": node.x,
|
"x": node.x,
|
||||||
"y": node.y,
|
"y": node.y,
|
||||||
"z": node.z,
|
"z": node.z,
|
||||||
|
"locked": node.locked,
|
||||||
"width": node.width,
|
"width": node.width,
|
||||||
"height": node.height,
|
"height": node.height,
|
||||||
"symbol": node.symbol,
|
"symbol": node.symbol,
|
||||||
|
Loading…
Reference in New Issue
Block a user