Add web UI with artifact table and upload functionality
Features: - Modern web interface with table view of all artifacts - Display all metadata: filename, type, size, test info, tags - Upload form with full metadata support - Query/filter interface - Detail modal for viewing full artifact information - Download and delete actions - Integrated seed data generation via UI - Responsive design with gradient theme Technical: - Pure HTML/CSS/JavaScript (no frameworks) - FastAPI serves static files - Seed data API endpoint for easy testing - Pagination support - Real-time deployment mode display The UI is now accessible at http://localhost:8000/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
app/api/seed.py
Normal file
38
app/api/seed.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.database import SessionLocal
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add parent directory to path
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
||||
|
||||
from utils.seed_data import generate_seed_data as generate_data, clear_all_data
|
||||
|
||||
router = APIRouter(prefix="/api/v1/seed", tags=["seed"])
|
||||
|
||||
|
||||
@router.post("/generate/{count}")
|
||||
async def generate_seed_data(count: int = 10):
|
||||
"""Generate seed data"""
|
||||
if count < 1 or count > 100:
|
||||
raise HTTPException(status_code=400, detail="Count must be between 1 and 100")
|
||||
|
||||
try:
|
||||
artifact_ids = await generate_data(count)
|
||||
return {
|
||||
"message": f"Successfully generated {len(artifact_ids)} artifacts",
|
||||
"artifact_ids": artifact_ids
|
||||
}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Seed generation failed: {str(e)}")
|
||||
|
||||
|
||||
@router.delete("/clear")
|
||||
async def clear_data():
|
||||
"""Clear all data"""
|
||||
try:
|
||||
await clear_all_data()
|
||||
return {"message": "All data cleared successfully"}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Clear failed: {str(e)}")
|
||||
33
app/main.py
33
app/main.py
@@ -1,9 +1,13 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import FileResponse
|
||||
from app.api.artifacts import router as artifacts_router
|
||||
from app.api.seed import router as seed_router
|
||||
from app.database import init_db
|
||||
from app.config import settings
|
||||
import logging
|
||||
import os
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
@@ -33,6 +37,12 @@ app.add_middleware(
|
||||
|
||||
# Include routers
|
||||
app.include_router(artifacts_router)
|
||||
app.include_router(seed_router)
|
||||
|
||||
# Mount static files
|
||||
static_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "static")
|
||||
if os.path.exists(static_dir):
|
||||
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
@@ -45,9 +55,9 @@ async def startup_event():
|
||||
logger.info("Application started successfully")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
"""Root endpoint"""
|
||||
@app.get("/api")
|
||||
async def api_root():
|
||||
"""API root endpoint"""
|
||||
return {
|
||||
"message": "Test Artifact Data Lake API",
|
||||
"version": "1.0.0",
|
||||
@@ -57,6 +67,23 @@ async def root():
|
||||
}
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def ui_root():
|
||||
"""Serve the UI"""
|
||||
index_path = os.path.join(static_dir, "index.html")
|
||||
if os.path.exists(index_path):
|
||||
return FileResponse(index_path)
|
||||
else:
|
||||
return {
|
||||
"message": "Test Artifact Data Lake API",
|
||||
"version": "1.0.0",
|
||||
"docs": "/docs",
|
||||
"ui": "UI not found. Serving API only.",
|
||||
"deployment_mode": settings.deployment_mode,
|
||||
"storage_backend": settings.storage_backend
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
"""Health check endpoint"""
|
||||
|
||||
Reference in New Issue
Block a user