fix: media thumbnails, product dimensions, inline 3D viewer, GLB export
Bug A: Media Library thumbnails were gray because <img src> cannot send JWT auth headers. Added useAuthBlob() hook (fetch + createObjectURL) in MediaBrowser.tsx. Also fixed publish_asset Celery task to populate product_id + cad_file_id on MediaAsset for thumbnail fallback resolution. Bug B: Product dimensions now shown in Product Details card with Ruler icon and "from CAD" label when cad_mesh_attributes.dimensions_mm exists. Bug C: Replaced 128×128 CAD thumbnail with InlineCadViewer component. Queries gltf_geometry MediaAssets, fetches GLB via auth fetch → blob URL → Three.js Canvas with OrbitControls. Falls back to thumbnail + "Load 3D Model" button. Polling when GLB generation is in progress. Bug D: trimesh was in [cad] optional extra but Dockerfile only installed [dev]. Changed to pip install -e ".[dev,cad]" — trimesh now available in backend container, GLB + Colors export works. Also added bbox extraction (STL-first numpy parsing) in render_step_thumbnail and admin "Re-extract CAD Metadata" bulk endpoint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,13 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.domains.media.models import MediaAsset, MediaAssetType
|
||||
|
||||
|
||||
_SORT_COLUMNS = {
|
||||
"created_at": MediaAsset.created_at,
|
||||
"file_size_bytes": MediaAsset.file_size_bytes,
|
||||
"storage_key": MediaAsset.storage_key,
|
||||
}
|
||||
|
||||
|
||||
async def list_media_assets(
|
||||
db: AsyncSession,
|
||||
product_id: uuid.UUID | None = None,
|
||||
@@ -15,8 +22,13 @@ async def list_media_assets(
|
||||
is_archived: bool | None = False,
|
||||
skip: int = 0,
|
||||
limit: int = 50,
|
||||
sort_by: str = "created_at",
|
||||
sort_dir: str = "desc",
|
||||
) -> list[MediaAsset]:
|
||||
q = select(MediaAsset).order_by(MediaAsset.created_at.desc())
|
||||
from sqlalchemy import asc, desc
|
||||
col = _SORT_COLUMNS.get(sort_by, MediaAsset.created_at)
|
||||
order = desc(col) if sort_dir == "desc" else asc(col)
|
||||
q = select(MediaAsset).order_by(order)
|
||||
if product_id:
|
||||
q = q.where(MediaAsset.product_id == product_id)
|
||||
if order_line_id:
|
||||
|
||||
Reference in New Issue
Block a user