Files
homelable/backend/app/schemas/nodes.py
T
Pouzor 3d89ba3b6f feat: replace static hardware fields with dynamic node properties
Replaces the 4 fixed hardware columns (cpu_count, cpu_model, ram_gb,
disk_gb) with a flexible properties system. Each property has a key,
value, icon (from a curated Lucide picker), and a visibility toggle
that controls whether it appears on the canvas node card.

- Backend: add `properties` JSON column to Node model; data migration
  converts existing hardware rows to properties with correct icons
  (idempotent, old columns kept for safety)
- Backend: add `properties` to NodeBase, NodeUpdate, NodeSave schemas
  and canvasSerializer so values survive canvas save/load
- Frontend: add NodeProperty type; new propertyIcons.ts registry (20
  icons); BaseNode renders visible properties with legacy hardware
  fallback for unmigrated nodes
- Frontend: DetailPanel gains interactive properties section (add /
  edit / remove / toggle visibility / icon picker) replacing the
  read-only hardware block; hardware section removed from NodeModal
- Tests: 6 migration tests, 7 API tests, 8 DetailPanel property tests,
  6 BaseNode render/fallback tests, 9 propertyIcons util tests
2026-04-09 13:47:36 +02:00

77 lines
2.0 KiB
Python

from datetime import datetime
from typing import Any
from pydantic import BaseModel
class NodeBase(BaseModel):
type: str
label: str
hostname: str | None = None
ip: str | None = None
mac: str | None = None
os: str | None = None
status: str = "unknown"
check_method: str | None = None
check_target: str | None = None
services: list[Any] = []
notes: str | None = None
pos_x: float = 0
pos_y: float = 0
parent_id: str | None = None
container_mode: bool = False
custom_colors: dict[str, Any] | None = None
custom_icon: str | None = None
cpu_count: int | None = None
cpu_model: str | None = None
ram_gb: float | None = None
disk_gb: float | None = None
show_hardware: bool = False
properties: list[dict[str, Any]] = []
width: float | None = None
height: float | None = None
bottom_handles: int = 1
class NodeCreate(NodeBase):
pass
class NodeUpdate(BaseModel):
type: str | None = None
label: str | None = None
hostname: str | None = None
ip: str | None = None
mac: str | None = None
os: str | None = None
status: str | None = None
check_method: str | None = None
check_target: str | None = None
services: list[Any] | None = None
notes: str | None = None
pos_x: float | None = None
pos_y: float | None = None
parent_id: str | None = None
container_mode: bool | None = None
custom_colors: dict[str, Any] | None = None
custom_icon: str | None = None
cpu_count: int | None = None
cpu_model: str | None = None
ram_gb: float | None = None
disk_gb: float | None = None
show_hardware: bool | None = None
properties: list[dict[str, Any]] | None = None
width: float | None = None
height: float | None = None
bottom_handles: int | None = None
class NodeResponse(NodeBase):
id: str
last_seen: datetime | None = None
response_time_ms: int | None = None
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}