feat: customizable link color per edge
- Add custom_color field to EdgeData type, Edge DB model and all schemas - HomelableEdge applies custom_color as stroke override (before selected highlight) - EDGE_DEFAULT_COLORS extracted to utils/edgeColors.ts (react-refresh compliant) - EdgeModal: color picker row showing effective color (custom or type default) with hex value, Reset button when custom color is active - Auto-migration adds custom_color column to edges table
This commit is contained in:
@@ -25,6 +25,8 @@ async def init_db() -> None:
|
||||
await conn.exec_driver_sql("ALTER TABLE nodes ADD COLUMN container_mode BOOLEAN NOT NULL DEFAULT 0")
|
||||
with suppress(Exception):
|
||||
await conn.exec_driver_sql("ALTER TABLE nodes ADD COLUMN custom_colors JSON")
|
||||
with suppress(Exception):
|
||||
await conn.exec_driver_sql("ALTER TABLE edges ADD COLUMN custom_color TEXT")
|
||||
|
||||
|
||||
async def get_db():
|
||||
|
||||
@@ -54,6 +54,7 @@ class Edge(Base):
|
||||
label: Mapped[str | None] = mapped_column(String)
|
||||
vlan_id: Mapped[int | None] = mapped_column(Integer)
|
||||
speed: Mapped[str | None] = mapped_column(String)
|
||||
custom_color: Mapped[str | None] = mapped_column(String)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now)
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class EdgeSave(BaseModel):
|
||||
label: str | None = None
|
||||
vlan_id: int | None = None
|
||||
speed: str | None = None
|
||||
custom_color: str | None = None
|
||||
|
||||
|
||||
class CanvasSaveRequest(BaseModel):
|
||||
|
||||
@@ -10,6 +10,7 @@ class EdgeBase(BaseModel):
|
||||
label: str | None = None
|
||||
vlan_id: int | None = None
|
||||
speed: str | None = None
|
||||
custom_color: str | None = None
|
||||
|
||||
|
||||
class EdgeCreate(EdgeBase):
|
||||
@@ -21,6 +22,7 @@ class EdgeUpdate(BaseModel):
|
||||
label: str | None = None
|
||||
vlan_id: int | None = None
|
||||
speed: str | None = None
|
||||
custom_color: str | None = None
|
||||
|
||||
|
||||
class EdgeResponse(EdgeBase):
|
||||
|
||||
Reference in New Issue
Block a user