mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-02 20:22:15 +02:00
- New APIBrowser component with full OpenAPI schema integration
- Fetches and parses /openapi.json automatically
- Groups endpoints by API tags (printers, archives, settings, etc.)
- Expandable endpoint sections with color-coded method badges
- Path parameter, query parameter, and JSON body editors
- Auto-populates request body with schema examples
- Live API request execution with response display
- Response shows status code, timing, and formatted JSON
- Copy response button with clipboard fallback
- Search to filter endpoints across all categories
- Expand All / Collapse All buttons
- Link to Swagger UI (/docs)
- Two-column layout for API Keys tab
- Left: API key management + webhook documentation
- Right: API Browser with dedicated test key input
- Parameter validation
- Shows warning for missing required parameters
- Validates before sending requests to avoid 422 errors
- UX improvements
- "Use in API Browser" button on newly created keys
- Responsive layout (stacked on mobile, side-by-side on xl+)
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Float, ForeignKey, Index, Integer, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from backend.app.core.database import Base
|
|
|
|
|
|
class AMSSensorHistory(Base):
|
|
"""Historical sensor data from AMS units (humidity and temperature)."""
|
|
|
|
__tablename__ = "ams_sensor_history"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
printer_id: Mapped[int] = mapped_column(ForeignKey("printers.id", ondelete="CASCADE"))
|
|
ams_id: Mapped[int] = mapped_column(Integer) # AMS unit index (0, 1, 2, 3)
|
|
humidity: Mapped[float | None] = mapped_column(Float) # Humidity percentage
|
|
humidity_raw: Mapped[float | None] = mapped_column(Float) # Raw humidity value
|
|
temperature: Mapped[float | None] = mapped_column(Float) # Temperature in Celsius
|
|
recorded_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), index=True)
|
|
|
|
# Indexes for efficient querying
|
|
__table_args__ = (Index("ix_ams_history_printer_ams_time", "printer_id", "ams_id", "recorded_at"),)
|
|
|
|
# Relationship
|
|
printer: Mapped["Printer"] = relationship(back_populates="ams_history")
|
|
|
|
|
|
from backend.app.models.printer import Printer # noqa: E402
|