1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-25 01:38:08 +00:00

Fix link style merge

This commit is contained in:
grossmj 2021-06-12 15:26:35 +09:30
parent 6ec028ea4e
commit 229a04e2fa
7 changed files with 13 additions and 1 deletions

View File

@ -81,6 +81,8 @@ async def create_link(project_id: UUID, link_data: schemas.LinkCreate) -> schema
link_data = jsonable_encoder(link_data, exclude_unset=True) link_data = jsonable_encoder(link_data, exclude_unset=True)
if "filters" in link_data: if "filters" in link_data:
await link.update_filters(link_data["filters"]) await link.update_filters(link_data["filters"])
if "link_style" in link_data:
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"])
try: try:
@ -124,6 +126,8 @@ async def update_link(link_data: schemas.LinkUpdate, link: Link = Depends(dep_li
link_data = jsonable_encoder(link_data, exclude_unset=True) link_data = jsonable_encoder(link_data, exclude_unset=True)
if "filters" in link_data: if "filters" in link_data:
await link.update_filters(link_data["filters"]) await link.update_filters(link_data["filters"])
if "link_style" in link_data:
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 "nodes" in link_data: if "nodes" in link_data:

View File

@ -175,7 +175,7 @@ class Link:
if link_style != self._link_style: if link_style != self._link_style:
self._link_style = link_style self._link_style = link_style
await self.update() await self.update()
self._project.emit_notification("link.updated", self.__json__()) self._project.emit_notification("link.updated", self.asdict())
self._project.dump() self._project.dump()
@property @property

View File

@ -42,6 +42,13 @@ class LinkType(str, Enum):
serial = "serial" serial = "serial"
class LinkStyle(BaseModel):
color: Optional[str] = None
width: Optional[int] = None
type: Optional[int] = None
class LinkBase(BaseModel): class LinkBase(BaseModel):
""" """
Link data. Link data.
@ -49,6 +56,7 @@ class LinkBase(BaseModel):
nodes: Optional[List[LinkNode]] = Field(None, min_items=0, max_items=2) nodes: Optional[List[LinkNode]] = Field(None, min_items=0, max_items=2)
suspend: Optional[bool] = None suspend: Optional[bool] = None
link_style: Optional[LinkStyle] = None
filters: Optional[dict] = None filters: Optional[dict] = None