Return the svg field in shape API

Ref #498
pull/638/head
Julien Duponchelle 8 years ago
parent 51dbe59e99
commit 4f78efa0c8
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

@ -24,8 +24,8 @@ class Shape:
Shape are visual element not used by the network emulation. Like
text, images, rectangle... They are pure SVG elements.
"""
def __init__(self, project, shape_id=None, svg=None, x=0, y=0, z=0):
self.svg = "<svg></svg>"
def __init__(self, project, shape_id=None, svg="<svg></svg>", x=0, y=0, z=0):
self.svg = svg
self._project = project
if shape_id is None:
self._id = str(uuid.uuid4())
@ -74,9 +74,9 @@ class Shape:
@asyncio.coroutine
def update(self, **kwargs):
"""
Update the node on the compute server
Update the shape
:param kwargs: Node properties
:param kwargs: Shape properties
"""
# Update node properties with additional elements
@ -96,6 +96,7 @@ class Shape:
"x": self._x,
"y": self._y,
"z": self._z,
"svg": self._svg
}
return {
"project_id": self._project.id,
@ -103,6 +104,7 @@ class Shape:
"x": self._x,
"y": self._y,
"z": self._z,
"svg": self._svg
}
def __repr__(self):

@ -26,7 +26,7 @@ in futur GNS3 versions.
<table border="1">
<tr>
<th>Name</th>
<th>ID</td>
<th>ID</th>
<th>Compute</th>
<th>Console</th>
</tr>
@ -43,9 +43,9 @@ in futur GNS3 versions.
<h2>Links</h2>
<table border="1">
<tr>
<th>ID</td>
<th>Capture</td>
<th>PCAP</td>
<th>ID</th>
<th>Capture</th>
<th>PCAP</th>
</tr>
{% for link in project.links.values() %}
<tr>
@ -56,6 +56,25 @@ in futur GNS3 versions.
{% endfor %}
</table>
<h2>Shapes</h2>
<table border="1">
<tr>
<th>ID</th>
<th>Position</th>
<th>Content</th>
</tr>
{% for shape in project.shapes.values() %}
<tr>
<td>{{shape.id}}</td>
<td>{{shape.x}}, {{shape.y}}, {{shape.z}}</td>
<td>{{shape.svg}}</td>
</tr>
{% endfor %}
</table>
<h2>Notifications</h2>
<div id="notifications">
</div>

@ -54,13 +54,15 @@ def test_json(project):
"project_id": project.id,
"x": i.x,
"y": i.y,
"z": i.z
"z": i.z,
"svg": i.svg
}
assert i.__json__(topology_dump=True) == {
"shape_id": i.id,
"x": i.x,
"y": i.y,
"z": i.z
"z": i.z,
"svg": i.svg
}

Loading…
Cancel
Save