mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-28 04:50:16 +03:00
feat: add show_filters_icon property to Link for controlling Web UI filter icon display
This commit adds a new `show_filters_icon` property to the Link class, allowing users to control whether filter icons are displayed in the Web UI at the individual link level.
**Changes:**
- Added `_show_filters_icon` attribute to Link class (default: True)
- Added `show_filters_icon` property getter
- Added `update_show_filters_icon()` method for updating the property
- Updated `asdict()` to include the new field in both topology and regular dumps
- Added `show_filters_icon` field to LinkBase schema
- Updated API routes to handle the new field in create and update operations
**API Impact:**
- POST /v3/projects/{project_id}/links - accepts `show_filters_icon` in request body
- PUT /v3/projects/{project_id}/links/{link_id} - can update `show_filters_icon`
- GET /v3/projects/{project_id}/links/{link_id} - returns `show_filters_icon` field
**Future Applications:**
This feature provides granular control for future AI fault injection modules to manage link-level protocol failures while maintaining clean UI presentation.
This commit is contained in:
parent
8719e12c59
commit
aa6845b32b
@ -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"])
|
||||
if "suspend" in link_data:
|
||||
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:
|
||||
for node in link_data["nodes"]:
|
||||
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"])
|
||||
if "suspend" in link_data:
|
||||
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:
|
||||
await link.update_nodes(link_data["nodes"])
|
||||
return link.asdict()
|
||||
|
||||
@ -89,6 +89,7 @@ class Link:
|
||||
self._filters = {}
|
||||
self._link_style = {}
|
||||
self._wireshark = False
|
||||
self._show_filters_icon = True
|
||||
|
||||
@property
|
||||
def filters(self):
|
||||
@ -97,6 +98,13 @@ class Link:
|
||||
"""
|
||||
return self._filters
|
||||
|
||||
@property
|
||||
def show_filters_icon(self):
|
||||
"""
|
||||
Get whether to show filters icon in Web UI
|
||||
"""
|
||||
return self._show_filters_icon
|
||||
|
||||
@property
|
||||
def project(self):
|
||||
"""
|
||||
@ -167,6 +175,17 @@ class Link:
|
||||
self._project.emit_notification("link.updated", self.asdict())
|
||||
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):
|
||||
if link_style != self._link_style:
|
||||
self._link_style = link_style
|
||||
@ -555,6 +574,7 @@ class Link:
|
||||
"filters": self._filters,
|
||||
"link_style": self._link_style,
|
||||
"suspend": self._suspended,
|
||||
"show_filters_icon": self._show_filters_icon,
|
||||
}
|
||||
return {
|
||||
"nodes": res,
|
||||
@ -569,4 +589,5 @@ class Link:
|
||||
"suspend": self._suspended,
|
||||
"link_style": self._link_style,
|
||||
"wireshark": self._wireshark,
|
||||
"show_filters_icon": self._show_filters_icon,
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ class LinkBase(BaseModel):
|
||||
suspend: Optional[bool] = None
|
||||
link_style: Optional[LinkStyle] = None
|
||||
filters: Optional[dict] = None
|
||||
show_filters_icon: Optional[bool] = None
|
||||
|
||||
|
||||
class LinkCreate(LinkBase):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user