Add tags to all entity types with chip-based input and autocomplete
- Add `tags: List[str]` field to all 13 entity types (devices, output targets, CSS sources, picture sources, audio sources, value sources, sync clocks, automations, scene presets, capture/audio/PP/pattern templates) - Update all stores, schemas, and route handlers for tag CRUD - Add GET /api/v1/tags endpoint aggregating unique tags across all stores - Create TagInput component with chip display, autocomplete dropdown, keyboard navigation, and API-backed suggestions - Display tag chips on all entity cards (searchable via existing text filter) - Add tag input to all 14 editor modals with dirty check support - Add CSS styles and i18n keys (en/ru/zh) for tag UI - Also includes code review fixes: thread safety, perf, store dedup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ parameters like brightness. Five types:
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ class ValueSource:
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
description: Optional[str] = None
|
||||
tags: List[str] = field(default_factory=list)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert source to dictionary. Subclasses extend this."""
|
||||
@@ -35,6 +36,7 @@ class ValueSource:
|
||||
"created_at": self.created_at.isoformat(),
|
||||
"updated_at": self.updated_at.isoformat(),
|
||||
"description": self.description,
|
||||
"tags": self.tags,
|
||||
# Subclass fields default to None for forward compat
|
||||
"value": None,
|
||||
"waveform": None,
|
||||
@@ -58,26 +60,27 @@ class ValueSource:
|
||||
sid: str = data["id"]
|
||||
name: str = data["name"]
|
||||
description: str | None = data.get("description")
|
||||
tags: list = data.get("tags", [])
|
||||
|
||||
raw_created = data.get("created_at")
|
||||
created_at: datetime = (
|
||||
datetime.fromisoformat(raw_created)
|
||||
if isinstance(raw_created, str)
|
||||
else raw_created if isinstance(raw_created, datetime)
|
||||
else datetime.utcnow()
|
||||
else datetime.now(timezone.utc)
|
||||
)
|
||||
raw_updated = data.get("updated_at")
|
||||
updated_at: datetime = (
|
||||
datetime.fromisoformat(raw_updated)
|
||||
if isinstance(raw_updated, str)
|
||||
else raw_updated if isinstance(raw_updated, datetime)
|
||||
else datetime.utcnow()
|
||||
else datetime.now(timezone.utc)
|
||||
)
|
||||
|
||||
if source_type == "animated":
|
||||
return AnimatedValueSource(
|
||||
id=sid, name=name, source_type="animated",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
created_at=created_at, updated_at=updated_at, description=description, tags=tags,
|
||||
waveform=data.get("waveform") or "sine",
|
||||
speed=float(data.get("speed") or 10.0),
|
||||
min_value=float(data.get("min_value") or 0.0),
|
||||
@@ -87,7 +90,7 @@ class ValueSource:
|
||||
if source_type == "audio":
|
||||
return AudioValueSource(
|
||||
id=sid, name=name, source_type="audio",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
created_at=created_at, updated_at=updated_at, description=description, tags=tags,
|
||||
audio_source_id=data.get("audio_source_id") or "",
|
||||
mode=data.get("mode") or "rms",
|
||||
sensitivity=float(data.get("sensitivity") or 1.0),
|
||||
@@ -100,7 +103,7 @@ class ValueSource:
|
||||
if source_type == "adaptive_time":
|
||||
return AdaptiveValueSource(
|
||||
id=sid, name=name, source_type="adaptive_time",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
created_at=created_at, updated_at=updated_at, description=description, tags=tags,
|
||||
schedule=data.get("schedule") or [],
|
||||
min_value=float(data.get("min_value") or 0.0),
|
||||
max_value=float(data["max_value"]) if data.get("max_value") is not None else 1.0,
|
||||
@@ -109,7 +112,7 @@ class ValueSource:
|
||||
if source_type == "adaptive_scene":
|
||||
return AdaptiveValueSource(
|
||||
id=sid, name=name, source_type="adaptive_scene",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
created_at=created_at, updated_at=updated_at, description=description, tags=tags,
|
||||
picture_source_id=data.get("picture_source_id") or "",
|
||||
scene_behavior=data.get("scene_behavior") or "complement",
|
||||
sensitivity=float(data.get("sensitivity") or 1.0),
|
||||
@@ -121,7 +124,7 @@ class ValueSource:
|
||||
# Default: "static" type
|
||||
return StaticValueSource(
|
||||
id=sid, name=name, source_type="static",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
created_at=created_at, updated_at=updated_at, description=description, tags=tags,
|
||||
value=float(data["value"]) if data.get("value") is not None else 1.0,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user