1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Update schema to allow for drawing grid size to be part of project.

This commit is contained in:
Karim 2018-11-25 13:25:29 +00:00
parent e2231b1220
commit 8eb20525e8
6 changed files with 44 additions and 7 deletions

View File

@ -69,7 +69,7 @@ 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, zoom=100, show_layers=False, snap_to_grid=False, show_grid=False,
grid_size=0, show_interface_labels=False, variables=None, supplier=None):
grid_size=75, drawing_grid_size=25, show_interface_labels=False, variables=None, supplier=None):
self._controller = controller
assert name is not None
@ -85,6 +85,7 @@ class Project:
self._snap_to_grid = snap_to_grid
self._show_grid = show_grid
self._grid_size = grid_size
self._drawing_grid_size = drawing_grid_size
self._show_interface_labels = show_interface_labels
self._variables = variables
self._supplier = supplier
@ -263,6 +264,21 @@ class Project:
"""
self._grid_size = grid_size
@property
def drawing_grid_size(self):
"""
Grid size
:return: integer
"""
return self._drawing_grid_size
@drawing_grid_size.setter
def drawing_grid_size(self, grid_size):
"""
Setter for grid size
"""
self._drawing_grid_size = grid_size
@property
def show_interface_labels(self):
"""
@ -837,6 +853,7 @@ class Project:
"snap_to_grid",
"show_grid",
"grid_size",
"drawing_grid_size",
"show_interface_labels"
]
@ -1084,6 +1101,7 @@ class Project:
"snap_to_grid": self._snap_to_grid,
"show_grid": self._show_grid,
"grid_size": self._grid_size,
"drawing_grid_size": self._drawing_grid_size,
"show_interface_labels": self._show_interface_labels,
"supplier": self._supplier,
"variables": self._variables

View File

@ -84,6 +84,7 @@ def project_to_topology(project):
"snap_to_grid": project.snap_to_grid,
"show_grid": project.show_grid,
"grid_size": project.grid_size,
"drawing_grid_size": project.drawing_grid_size,
"show_interface_labels": project.show_interface_labels,
"variables": project.variables,
"supplier": project.supplier,

View File

@ -102,7 +102,11 @@ PROJECT_CREATE_SCHEMA = {
},
"grid_size": {
"type": "integer",
"description": "Grid size for the drawing area"
"description": "Grid size for the drawing area for appliances"
},
"drawing_grid_size": {
"type": "integer",
"description": "Grid size for the drawing area for labels"
},
"show_interface_labels": {
"type": "boolean",
@ -167,7 +171,11 @@ PROJECT_UPDATE_SCHEMA = {
},
"grid_size": {
"type": "integer",
"description": "Grid size for the drawing area"
"description": "Grid size for the drawing area for appliances"
},
"drawing_grid_size": {
"type": "integer",
"description": "Grid size for the drawing area for labels"
},
"show_interface_labels": {
"type": "boolean",
@ -248,7 +256,11 @@ PROJECT_OBJECT_SCHEMA = {
},
"grid_size": {
"type": "integer",
"description": "Grid size for the drawing area"
"description": "Grid size for the drawing area for appliances"
},
"drawing_grid_size": {
"type": "integer",
"description": "Grid size for the drawing area for labels"
},
"show_interface_labels": {
"type": "boolean",

View File

@ -93,7 +93,11 @@ TOPOLOGY_SCHEMA = {
},
"grid_size": {
"type": "integer",
"description": "Grid size for the drawing area"
"description": "Grid size for the drawing area for appliances"
},
"drawing_grid_size": {
"type": "integer",
"description": "Grid size for the drawing area for labels"
},
"show_interface_labels": {
"type": "boolean",

View File

@ -77,7 +77,8 @@ def test_json(tmpdir):
"show_interface_labels": False,
"show_layers": False,
"snap_to_grid": False,
"grid_size": 0,
"grid_size": 75,
"drawing_grid_size": 25,
"supplier": None,
"variables": None
}

View File

@ -45,7 +45,8 @@ def test_project_to_topology_empty(tmpdir):
"show_interface_labels": False,
"show_layers": False,
"snap_to_grid": False,
"grid_size": 0,
"grid_size": 75,
"drawing_grid_size": 25,
"topology": {
"nodes": [],
"links": [],