30fa107ef7
- 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>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
"""Postprocessing template data model."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime, timezone
|
|
from typing import List, Optional
|
|
|
|
from wled_controller.core.filters.filter_instance import FilterInstance
|
|
|
|
|
|
@dataclass
|
|
class PostprocessingTemplate:
|
|
"""Postprocessing settings template containing an ordered list of filters."""
|
|
|
|
id: str
|
|
name: str
|
|
filters: List[FilterInstance]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
description: Optional[str] = None
|
|
tags: List[str] = field(default_factory=list)
|
|
|
|
def to_dict(self) -> dict:
|
|
"""Convert template to dictionary."""
|
|
return {
|
|
"id": self.id,
|
|
"name": self.name,
|
|
"filters": [f.to_dict() for f in self.filters],
|
|
"created_at": self.created_at.isoformat(),
|
|
"updated_at": self.updated_at.isoformat(),
|
|
"description": self.description,
|
|
"tags": self.tags,
|
|
}
|
|
|
|
@classmethod
|
|
def from_dict(cls, data: dict) -> "PostprocessingTemplate":
|
|
"""Create template from dictionary."""
|
|
filters = [FilterInstance.from_dict(f) for f in data.get("filters", [])]
|
|
|
|
return cls(
|
|
id=data["id"],
|
|
name=data["name"],
|
|
filters=filters,
|
|
created_at=datetime.fromisoformat(data["created_at"])
|
|
if isinstance(data.get("created_at"), str)
|
|
else data.get("created_at", datetime.now(timezone.utc)),
|
|
updated_at=datetime.fromisoformat(data["updated_at"])
|
|
if isinstance(data.get("updated_at"), str)
|
|
else data.get("updated_at", datetime.now(timezone.utc)),
|
|
description=data.get("description"),
|
|
tags=data.get("tags", []),
|
|
)
|