Add printer types with bed volume + add-printer UI

- PrinterType model: name, bed_x_mm/y/z, linked to Printer via type_id
- Migration 0002: creates printer_types, adds type_id to printers, drops model
- /printer-types page: table + Add Type modal form
- /printers page: Add Printer modal with type dropdown (disabled if no types)
- API: GET/POST/DELETE /api/printer-types

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martin Hohenberg
2026-06-18 21:46:26 +02:00
parent 5fb15b36bf
commit 750edbbcec
9 changed files with 309 additions and 12 deletions

View File

@@ -0,0 +1,40 @@
"""printer_types table and link to printers
Revision ID: 0002
Revises: 0001
Create Date: 2026-06-18
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "0002"
down_revision: Union[str, None] = "0001"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"printer_types",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("name", sa.String(length=100), nullable=False),
sa.Column("bed_x_mm", sa.Integer(), nullable=False),
sa.Column("bed_y_mm", sa.Integer(), nullable=False),
sa.Column("bed_z_mm", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False, server_default=sa.text("CURRENT_TIMESTAMP")),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name"),
)
op.add_column("printers", sa.Column("type_id", sa.Integer(), nullable=True))
op.create_foreign_key("fk_printer_type", "printers", "printer_types", ["type_id"], ["id"])
op.drop_column("printers", "model")
def downgrade() -> None:
op.drop_constraint("fk_printer_type", "printers", type_="foreignkey")
op.drop_column("printers", "type_id")
op.add_column("printers", sa.Column("model", sa.String(length=100), nullable=True))
op.drop_table("printer_types")