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

More options for drawing area

This commit is contained in:
ziajka 2017-07-03 10:01:22 +02:00
parent cc34f45677
commit dadbb0ab09
6 changed files with 65 additions and 4 deletions

View File

@ -68,7 +68,8 @@ class Project:
def __init__(self, name=None, project_id=None, path=None, controller=None, status="opened", 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, 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): 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 self._controller = controller
assert name is not None assert name is not None
@ -83,6 +84,7 @@ class Project:
self._show_layers = show_layers self._show_layers = show_layers
self._snap_to_grid = snap_to_grid self._snap_to_grid = snap_to_grid
self._show_grid = show_grid self._show_grid = show_grid
self._show_interface_labels = show_interface_labels
self._loading = False self._loading = False
# Disallow overwrite of existing project # Disallow overwrite of existing project
@ -230,10 +232,25 @@ class Project:
@show_grid.setter @show_grid.setter
def show_grid(self, show_grid): def show_grid(self, show_grid):
""" """
Setter for snam to grid mode Setter for showing the grid mode
""" """
self._show_grid = show_grid 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 @property
def auto_start(self): def auto_start(self):
""" """
@ -876,7 +893,8 @@ class Project:
"zoom": self._zoom, "zoom": self._zoom,
"show_layers": self._show_layers, "show_layers": self._show_layers,
"snap_to_grid": self._snap_to_grid, "snap_to_grid": self._snap_to_grid,
"show_grid": self._show_grid "show_grid": self._show_grid,
"show_interface_labels": self._show_interface_labels
} }
def __repr__(self): def __repr__(self):

View File

@ -83,6 +83,7 @@ def project_to_topology(project):
"show_layers": project.show_layers, "show_layers": project.show_layers,
"snap_to_grid": project.snap_to_grid, "snap_to_grid": project.snap_to_grid,
"show_grid": project.show_grid, "show_grid": project.show_grid,
"show_interface_labels": project.show_interface_labels,
"topology": { "topology": {
"nodes": [], "nodes": [],
"links": [], "links": [],

View File

@ -65,6 +65,10 @@ PROJECT_CREATE_SCHEMA = {
"show_grid": { "show_grid": {
"type": "boolean", "type": "boolean",
"description": "Show the grid on the drawing area" "description": "Show the grid on the drawing area"
},
"show_interface_labels": {
"type": "boolean",
"description": "Show interface labels on the drawing area"
} }
}, },
"additionalProperties": False, "additionalProperties": False,
@ -120,6 +124,10 @@ PROJECT_UPDATE_SCHEMA = {
"show_grid": { "show_grid": {
"type": "boolean", "type": "boolean",
"description": "Show the grid on the drawing area" "description": "Show the grid on the drawing area"
},
"show_interface_labels": {
"type": "boolean",
"description": "Show interface labels on the drawing area"
} }
}, },
"additionalProperties": False, "additionalProperties": False,
@ -191,6 +199,10 @@ PROJECT_OBJECT_SCHEMA = {
"show_grid": { "show_grid": {
"type": "boolean", "type": "boolean",
"description": "Show the grid on the drawing area" "description": "Show the grid on the drawing area"
},
"show_interface_labels": {
"type": "boolean",
"description": "Show interface labels on the drawing area"
} }
}, },
"additionalProperties": False, "additionalProperties": False,

View File

@ -73,6 +73,26 @@ TOPOLOGY_SCHEMA = {
"type": "integer", "type": "integer",
"description": "Width of the drawing area" "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": { "topology": {
"description": "The topology content", "description": "The topology content",
"type": "object", "type": "object",

View File

@ -70,7 +70,12 @@ def test_json(tmpdir):
"auto_close": True, "auto_close": True,
"auto_open": False, "auto_open": False,
"scene_width": 2000, "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
} }

View File

@ -40,6 +40,11 @@ def test_project_to_topology_empty(tmpdir):
"scene_width": 2000, "scene_width": 2000,
"scene_height": 1000, "scene_height": 1000,
"revision": GNS3_FILE_FORMAT_REVISION, "revision": GNS3_FILE_FORMAT_REVISION,
"zoom": 100,
"show_grid": False,
"show_interface_labels": False,
"show_layers": False,
"snap_to_grid": False,
"topology": { "topology": {
"nodes": [], "nodes": [],
"links": [], "links": [],