mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-20 21:33:09 +00:00
commit
dc7a9ffc51
@ -68,7 +68,8 @@ class Project:
|
||||
|
||||
def __init__(self, name=None, project_id=None, path=None, controller=None, status="opened",
|
||||
filename=None, auto_start=False, auto_open=False, auto_close=True,
|
||||
scene_height=1000, scene_width=2000):
|
||||
scene_height=1000, scene_width=2000, zoom=100, show_layers=False, snap_to_grid=False, show_grid=False,
|
||||
show_interface_labels=False):
|
||||
|
||||
self._controller = controller
|
||||
assert name is not None
|
||||
@ -79,6 +80,11 @@ class Project:
|
||||
self._status = status
|
||||
self._scene_height = scene_height
|
||||
self._scene_width = scene_width
|
||||
self._zoom = zoom
|
||||
self._show_layers = show_layers
|
||||
self._snap_to_grid = snap_to_grid
|
||||
self._show_grid = show_grid
|
||||
self._show_interface_labels = show_interface_labels
|
||||
self._loading = False
|
||||
|
||||
# Disallow overwrite of existing project
|
||||
@ -170,6 +176,81 @@ class Project:
|
||||
"""
|
||||
self._scene_width = val
|
||||
|
||||
@property
|
||||
def zoom(self):
|
||||
"""
|
||||
Zoom level in percentage
|
||||
:return: integer > 0
|
||||
"""
|
||||
return self._zoom
|
||||
|
||||
@zoom.setter
|
||||
def zoom(self, zoom):
|
||||
"""
|
||||
Setter for zoom level in percentage
|
||||
"""
|
||||
self._zoom = zoom
|
||||
|
||||
@property
|
||||
def show_layers(self):
|
||||
"""
|
||||
Show layers mode
|
||||
:return: bool
|
||||
"""
|
||||
return self._show_layers
|
||||
|
||||
@show_layers.setter
|
||||
def show_layers(self, show_layers):
|
||||
"""
|
||||
Setter for show layers mode
|
||||
"""
|
||||
self._show_layers = show_layers
|
||||
|
||||
@property
|
||||
def snap_to_grid(self):
|
||||
"""
|
||||
Snap to grid mode
|
||||
:return: bool
|
||||
"""
|
||||
return self._snap_to_grid
|
||||
|
||||
@snap_to_grid.setter
|
||||
def snap_to_grid(self, snap_to_grid):
|
||||
"""
|
||||
Setter for snap to grid mode
|
||||
"""
|
||||
self._snap_to_grid = snap_to_grid
|
||||
|
||||
@property
|
||||
def show_grid(self):
|
||||
"""
|
||||
Show grid mode
|
||||
:return: bool
|
||||
"""
|
||||
return self._show_grid
|
||||
|
||||
@show_grid.setter
|
||||
def show_grid(self, show_grid):
|
||||
"""
|
||||
Setter for showing the grid mode
|
||||
"""
|
||||
self._show_grid = show_grid
|
||||
|
||||
@property
|
||||
def show_interface_labels(self):
|
||||
"""
|
||||
Show interface labels mode
|
||||
:return: bool
|
||||
"""
|
||||
return self._show_interface_labels
|
||||
|
||||
@show_interface_labels.setter
|
||||
def show_interface_labels(self, show_interface_labels):
|
||||
"""
|
||||
Setter for show interface labels
|
||||
"""
|
||||
self._show_interface_labels = show_interface_labels
|
||||
|
||||
@property
|
||||
def auto_start(self):
|
||||
"""
|
||||
@ -798,7 +879,6 @@ class Project:
|
||||
yield from pool.join()
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {
|
||||
"name": self._name,
|
||||
"project_id": self._id,
|
||||
@ -809,7 +889,12 @@ class Project:
|
||||
"auto_close": self._auto_close,
|
||||
"auto_open": self._auto_open,
|
||||
"scene_height": self._scene_height,
|
||||
"scene_width": self._scene_width
|
||||
"scene_width": self._scene_width,
|
||||
"zoom": self._zoom,
|
||||
"show_layers": self._show_layers,
|
||||
"snap_to_grid": self._snap_to_grid,
|
||||
"show_grid": self._show_grid,
|
||||
"show_interface_labels": self._show_interface_labels
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -79,6 +79,11 @@ def project_to_topology(project):
|
||||
"auto_close": project.auto_close,
|
||||
"scene_width": project.scene_width,
|
||||
"scene_height": project.scene_height,
|
||||
"zoom": project.zoom,
|
||||
"show_layers": project.show_layers,
|
||||
"snap_to_grid": project.snap_to_grid,
|
||||
"show_grid": project.show_grid,
|
||||
"show_interface_labels": project.show_interface_labels,
|
||||
"topology": {
|
||||
"nodes": [],
|
||||
"links": [],
|
||||
|
@ -49,6 +49,26 @@ PROJECT_CREATE_SCHEMA = {
|
||||
"scene_width": {
|
||||
"type": "integer",
|
||||
"description": "Width of the drawing area"
|
||||
},
|
||||
"zoom": {
|
||||
"type": "integer",
|
||||
"description": "Zoom of the drawing area"
|
||||
},
|
||||
"show_layers": {
|
||||
"type": "boolean",
|
||||
"description": "Show layers on the drawing area"
|
||||
},
|
||||
"snap_to_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Snap to grid on the drawing area"
|
||||
},
|
||||
"show_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Show the grid on the drawing area"
|
||||
},
|
||||
"show_interface_labels": {
|
||||
"type": "boolean",
|
||||
"description": "Show interface labels on the drawing area"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False,
|
||||
@ -88,6 +108,26 @@ PROJECT_UPDATE_SCHEMA = {
|
||||
"scene_width": {
|
||||
"type": "integer",
|
||||
"description": "Width of the drawing area"
|
||||
},
|
||||
"zoom": {
|
||||
"type": "integer",
|
||||
"description": "Zoom of the drawing area"
|
||||
},
|
||||
"show_layers": {
|
||||
"type": "boolean",
|
||||
"description": "Show layers on the drawing area"
|
||||
},
|
||||
"snap_to_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Snap to grid on the drawing area"
|
||||
},
|
||||
"show_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Show the grid on the drawing area"
|
||||
},
|
||||
"show_interface_labels": {
|
||||
"type": "boolean",
|
||||
"description": "Show interface labels on the drawing area"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False,
|
||||
@ -143,6 +183,26 @@ PROJECT_OBJECT_SCHEMA = {
|
||||
"scene_width": {
|
||||
"type": "integer",
|
||||
"description": "Width of the drawing area"
|
||||
},
|
||||
"zoom": {
|
||||
"type": "integer",
|
||||
"description": "Zoom of the drawing area"
|
||||
},
|
||||
"show_layers": {
|
||||
"type": "boolean",
|
||||
"description": "Show layers on the drawing area"
|
||||
},
|
||||
"snap_to_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Snap to grid on the drawing area"
|
||||
},
|
||||
"show_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Show the grid on the drawing area"
|
||||
},
|
||||
"show_interface_labels": {
|
||||
"type": "boolean",
|
||||
"description": "Show interface labels on the drawing area"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False,
|
||||
|
@ -73,6 +73,26 @@ TOPOLOGY_SCHEMA = {
|
||||
"type": "integer",
|
||||
"description": "Width of the drawing area"
|
||||
},
|
||||
"zoom": {
|
||||
"type": "integer",
|
||||
"description": "Zoom of the drawing area"
|
||||
},
|
||||
"show_layers": {
|
||||
"type": "boolean",
|
||||
"description": "Show layers on the drawing area"
|
||||
},
|
||||
"snap_to_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Snap to grid on the drawing area"
|
||||
},
|
||||
"show_grid": {
|
||||
"type": "boolean",
|
||||
"description": "Show the grid on the drawing area"
|
||||
},
|
||||
"show_interface_labels": {
|
||||
"type": "boolean",
|
||||
"description": "Show interface labels on the drawing area"
|
||||
},
|
||||
"topology": {
|
||||
"description": "The topology content",
|
||||
"type": "object",
|
||||
|
@ -70,7 +70,12 @@ def test_json(tmpdir):
|
||||
"auto_close": True,
|
||||
"auto_open": False,
|
||||
"scene_width": 2000,
|
||||
"scene_height": 1000
|
||||
"scene_height": 1000,
|
||||
"zoom": 100,
|
||||
"show_grid": False,
|
||||
"show_interface_labels": False,
|
||||
"show_layers": False,
|
||||
"snap_to_grid": False
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,6 +40,11 @@ def test_project_to_topology_empty(tmpdir):
|
||||
"scene_width": 2000,
|
||||
"scene_height": 1000,
|
||||
"revision": GNS3_FILE_FORMAT_REVISION,
|
||||
"zoom": 100,
|
||||
"show_grid": False,
|
||||
"show_interface_labels": False,
|
||||
"show_layers": False,
|
||||
"snap_to_grid": False,
|
||||
"topology": {
|
||||
"nodes": [],
|
||||
"links": [],
|
||||
|
Loading…
Reference in New Issue
Block a user