mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-20 00:40:43 +03:00
Merge pull request #2745 from yueguobin/feat/link-show-filters-icon
feat: add show_filters_icon property to Link for controlling Web UI filter icon display
This commit is contained in:
commit
279ea9eed3
@ -107,6 +107,8 @@ async def create_link(project_id: UUID, link_data: schemas.LinkCreate) -> schema
|
|||||||
await link.update_link_style(link_data["link_style"])
|
await link.update_link_style(link_data["link_style"])
|
||||||
if "suspend" in link_data:
|
if "suspend" in link_data:
|
||||||
await link.update_suspend(link_data["suspend"])
|
await link.update_suspend(link_data["suspend"])
|
||||||
|
if "show_filters_icon" in link_data:
|
||||||
|
await link.update_show_filters_icon(link_data["show_filters_icon"])
|
||||||
try:
|
try:
|
||||||
for node in link_data["nodes"]:
|
for node in link_data["nodes"]:
|
||||||
await link.add_node(
|
await link.add_node(
|
||||||
@ -171,6 +173,8 @@ async def update_link(link_data: schemas.LinkUpdate, link: Link = Depends(dep_li
|
|||||||
await link.update_link_style(link_data["link_style"])
|
await link.update_link_style(link_data["link_style"])
|
||||||
if "suspend" in link_data:
|
if "suspend" in link_data:
|
||||||
await link.update_suspend(link_data["suspend"])
|
await link.update_suspend(link_data["suspend"])
|
||||||
|
if "show_filters_icon" in link_data:
|
||||||
|
await link.update_show_filters_icon(link_data["show_filters_icon"])
|
||||||
if "nodes" in link_data:
|
if "nodes" in link_data:
|
||||||
await link.update_nodes(link_data["nodes"])
|
await link.update_nodes(link_data["nodes"])
|
||||||
return link.asdict()
|
return link.asdict()
|
||||||
|
|||||||
@ -89,6 +89,7 @@ class Link:
|
|||||||
self._filters = {}
|
self._filters = {}
|
||||||
self._link_style = {}
|
self._link_style = {}
|
||||||
self._wireshark = False
|
self._wireshark = False
|
||||||
|
self._show_filters_icon = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filters(self):
|
def filters(self):
|
||||||
@ -97,6 +98,13 @@ class Link:
|
|||||||
"""
|
"""
|
||||||
return self._filters
|
return self._filters
|
||||||
|
|
||||||
|
@property
|
||||||
|
def show_filters_icon(self):
|
||||||
|
"""
|
||||||
|
Get whether to show filters icon in Web UI
|
||||||
|
"""
|
||||||
|
return getattr(self, '_show_filters_icon', True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def project(self):
|
def project(self):
|
||||||
"""
|
"""
|
||||||
@ -167,6 +175,17 @@ class Link:
|
|||||||
self._project.emit_notification("link.updated", self.asdict())
|
self._project.emit_notification("link.updated", self.asdict())
|
||||||
self._project.dump()
|
self._project.dump()
|
||||||
|
|
||||||
|
async def update_show_filters_icon(self, value):
|
||||||
|
"""
|
||||||
|
Update the show_filters_icon property.
|
||||||
|
|
||||||
|
:param value: Boolean indicating whether to show filters icon in Web UI
|
||||||
|
"""
|
||||||
|
if value != self._show_filters_icon:
|
||||||
|
self._show_filters_icon = value
|
||||||
|
self._project.emit_notification("link.updated", self.asdict())
|
||||||
|
self._project.dump()
|
||||||
|
|
||||||
async def update_link_style(self, link_style):
|
async def update_link_style(self, link_style):
|
||||||
if link_style != self._link_style:
|
if link_style != self._link_style:
|
||||||
self._link_style = link_style
|
self._link_style = link_style
|
||||||
@ -555,6 +574,7 @@ class Link:
|
|||||||
"filters": self._filters,
|
"filters": self._filters,
|
||||||
"link_style": self._link_style,
|
"link_style": self._link_style,
|
||||||
"suspend": self._suspended,
|
"suspend": self._suspended,
|
||||||
|
"show_filters_icon": getattr(self, '_show_filters_icon', True),
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
"nodes": res,
|
"nodes": res,
|
||||||
@ -569,4 +589,5 @@ class Link:
|
|||||||
"suspend": self._suspended,
|
"suspend": self._suspended,
|
||||||
"link_style": self._link_style,
|
"link_style": self._link_style,
|
||||||
"wireshark": self._wireshark,
|
"wireshark": self._wireshark,
|
||||||
|
"show_filters_icon": getattr(self, '_show_filters_icon', True),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1208,6 +1208,8 @@ class Project:
|
|||||||
await link.update_filters(link_data["filters"])
|
await link.update_filters(link_data["filters"])
|
||||||
if "link_style" in link_data:
|
if "link_style" in link_data:
|
||||||
await link.update_link_style(link_data["link_style"])
|
await link.update_link_style(link_data["link_style"])
|
||||||
|
if "show_filters_icon" in link_data:
|
||||||
|
await link.update_show_filters_icon(link_data["show_filters_icon"])
|
||||||
for node_link in link_data.get("nodes", []):
|
for node_link in link_data.get("nodes", []):
|
||||||
node = self.get_node(node_link["node_id"])
|
node = self.get_node(node_link["node_id"])
|
||||||
port = node.get_port(node_link["adapter_number"], node_link["port_number"])
|
port = node.get_port(node_link["adapter_number"], node_link["port_number"])
|
||||||
|
|||||||
@ -62,6 +62,10 @@ class LinkBase(BaseModel):
|
|||||||
suspend: Optional[bool] = None
|
suspend: Optional[bool] = None
|
||||||
link_style: Optional[LinkStyle] = None
|
link_style: Optional[LinkStyle] = None
|
||||||
filters: Optional[dict] = None
|
filters: Optional[dict] = None
|
||||||
|
show_filters_icon: Optional[bool] = Field(
|
||||||
|
True,
|
||||||
|
description="Show filters icon in Web UI"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class LinkCreate(LinkBase):
|
class LinkCreate(LinkBase):
|
||||||
|
|||||||
@ -221,6 +221,7 @@ async def test_json(project, compute):
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"filters": {},
|
"filters": {},
|
||||||
|
"show_filters_icon": True,
|
||||||
"link_style": {},
|
"link_style": {},
|
||||||
"suspend": False,
|
"suspend": False,
|
||||||
'wireshark': False,
|
'wireshark': False,
|
||||||
@ -254,6 +255,7 @@ async def test_json(project, compute):
|
|||||||
],
|
],
|
||||||
"link_style": {},
|
"link_style": {},
|
||||||
"filters": {},
|
"filters": {},
|
||||||
|
"show_filters_icon": True,
|
||||||
"suspend": False
|
"suspend": False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user