mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
Add a chronological, table-based print log as a 4th view mode in the Archives page. Log entries are stored in a separate print_log_entries table — clearing the log never touches archives or queue items. Backend: - New PrintLogEntry model with independent table - GET /print-log/ endpoint with search, printer, user, status, date filters - DELETE /print-log/ clears only log entries - Thumbnail serving endpoint for log entries - write_log_entry() service called on print completion - Auth: ARCHIVES_READ for viewing, ARCHIVES_DELETE_ALL for clearing Frontend: - New 'log' ViewMode with ClipboardList icon toggle - Filterable/searchable table with pagination (10/25/50/100 rows) - Colored status badges, duration formatting, filament color swatches - Clear button with confirmation modal - All filter state persisted to localStorage - i18n: EN, DE, JA, FR, IT translations
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Float, Integer, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from backend.app.core.database import Base
|
|
|
|
|
|
class PrintLogEntry(Base):
|
|
"""Independent print log entry. Written when print events occur.
|
|
|
|
This is a separate table from archives/queue — clearing the log
|
|
never touches archives or queue items.
|
|
"""
|
|
|
|
__tablename__ = "print_log_entries"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
print_name: Mapped[str | None] = mapped_column(String(255))
|
|
printer_name: Mapped[str | None] = mapped_column(String(255))
|
|
printer_id: Mapped[int | None] = mapped_column(Integer)
|
|
status: Mapped[str] = mapped_column(String(20)) # completed, failed, stopped, cancelled, skipped
|
|
started_at: Mapped[datetime | None] = mapped_column(DateTime)
|
|
completed_at: Mapped[datetime | None] = mapped_column(DateTime)
|
|
duration_seconds: Mapped[int | None] = mapped_column(Integer)
|
|
filament_type: Mapped[str | None] = mapped_column(String(50))
|
|
filament_color: Mapped[str | None] = mapped_column(String(50))
|
|
filament_used_grams: Mapped[float | None] = mapped_column(Float)
|
|
thumbnail_path: Mapped[str | None] = mapped_column(String(500))
|
|
created_by_username: Mapped[str | None] = mapped_column(String(100))
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|