Add Cantaloupe Sync admin UI page

- New 'Cantaloupe Sync' nav item in sidebar with sync icon
- Section 1: Sync Overview showing latest batch status, diff badges
- Section 2: Pending Batch Review with approve/reject buttons and diff detail
- Section 3: Import History with expandable rows for full diff view
- Added static file serving (FileResponse) to admin_server.py
- Fixed formatDate to handle space-separated SQLite datetimes
- Dark theme matching existing admin UI, vanilla JS with fetch()
This commit is contained in:
Leo
2026-05-21 19:38:36 -04:00
parent e9d18cb8b7
commit 070e8c2ddb
2 changed files with 394 additions and 2 deletions
+15
View File
@@ -24,6 +24,7 @@ from typing import Optional
from fastapi import FastAPI, HTTPException, Query, Request, UploadFile, File
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, StreamingResponse
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel
from cantaloupe_sync import router as cantaloupe_router, create_sync_tables
@@ -354,6 +355,20 @@ app.add_middleware(
# Mount Cantaloupe sync routes
app.include_router(cantaloupe_router)
# Serve admin frontend SPA (single index.html, no external assets needed)
from fastapi.responses import FileResponse
FRONTEND_INDEX = Path(__file__).parent / "static" / "index.html"
@app.get("/")
@app.get("/{full_path:path}")
async def serve_frontend(full_path: str = ""):
"""Serve the admin SPA — all routes return index.html."""
if FRONTEND_INDEX.is_file():
return FileResponse(str(FRONTEND_INDEX))
return JSONResponse({"detail": "Frontend not found"}, status_code=404)
# ─── Auth Middleware ────────────────────────────────────────────────────────