Files
spark-mcp/internal/admin/web.go
T
tao.chenandClaude df9b01272f admin: uploads list view with search, sort, and delete
Add /admin/uploads HTML page and JSON API backed by the upload_files

DB index. The page lists file_id, name, size (KB), uploaded_at, and

sha256 with client-side search by name, column sort, and per-row delete.

DELETE /admin/uploads/:id removes the DB index row and the on-disk

data file plus .meta.json sidecar. Admin deletes are written to the

audit log.

Wire the new dependencies through admin.Mount and main.go, and run

the backfill step on startup so pre-existing sidecars are indexed.

Tests cover auth, HTML rendering, JSON search, delete removing all

artifacts, and audit entry creation.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 11:39:56 +08:00

30 lines
598 B
Go

package admin
import (
"embed"
"net/http"
"github.com/gin-gonic/gin"
)
//go:embed web
var webFS embed.FS
func webHandler(c *gin.Context) {
data, err := webFS.ReadFile("web/cluster.html")
if err != nil {
c.String(http.StatusInternalServerError, "cluster.html: %v", err)
return
}
c.Data(http.StatusOK, "text/html; charset=utf-8", data)
}
func uploadsWebHandler(c *gin.Context) {
data, err := webFS.ReadFile("web/uploads.html")
if err != nil {
c.String(http.StatusInternalServerError, "uploads.html: %v", err)
return
}
c.Data(http.StatusOK, "text/html; charset=utf-8", data)
}