tao.chen and Claude
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
tao.chen and Claude
90eba221d4
admin: token 输入改为弹窗模式 (modal)
...
把 header 内嵌的 token 输入框 + Save 按钮拆掉,改用原生 <dialog>
弹窗。三种触发场景: 首访无 token 自动弹、API 401 自动弹 (清旧 token
后弹带错误信息)、用户主动点 Set Token 按钮弹。无有效 token 时阻止
Escape 关闭 (cancel 事件 preventDefault), 防止误操作丢失输入。
localStorage 键名 adminToken 不变, 零迁移成本。401 路径在 api()
内部清 token + 弹窗 + 记录 pendingRetry 闭包, 用户保存新 token 后
自动重试失败请求。
设计取舍:
- 选原生 <dialog> 而非自造 div + JS, 自带 modal/背板/焦点陷阱/a11y
- 选 <form> + preventDefault 而非 method='dialog', 避免自动关闭
- CSS 全部复用现有 dark theme 变量, 0 视觉割裂
- 0 新依赖 (纯 HTML5 + 原生 JS)
验证:
- go build / go vet / go test 全部通过
- 端到端 curl 确认新元素嵌入、旧元素删除、401/200 路径正常
- router_test.go 无回归 (HTML 改动不涉及 Go)
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-13 14:08:16 +08:00
tao.chen and Claude
9a48f9e68e
Phase 7 起步: Admin OpenAPI + Scalar UI + Cluster CRUD HTML
...
用户问题: 有 list_clusters MCP tool 但没简易 admin HTML。
A + B 方案:
- A: OpenAPI 文档 + Scalar UI(让人看 + 试 admin API)
- B: Cluster CRUD HTML 页面(让人填表创建/改 cluster)
实现:
- internal/admin/openapi.yaml: 手写 6 admin 端点 + Cluster/AuditEntry/Error
schema。auth_password 不在 spec(因 json:"-" tag)
- internal/admin/openapi.go: //go:embed openapi.yaml + Scalar HTML
GET /admin/docs 返 Scalar UI (CDN), GET /admin/docs/spec 返 YAML
- internal/admin/web/cluster.html: 单文件 401 行暗色 monospace 风格
cluster CRUD 页面, 14 字段表单, vanilla JS + localStorage token
+ 内嵌 CSS, 无前端框架, 无 bundler
- internal/admin/web.go: //go:embed web/cluster.html
- internal/admin/router.go: Mount 里追加 4 路由 (GET /admin, /admin/,
/admin/docs, /admin/docs/spec), 全部在 AdminAuth 组内
Linus 视角决策: 整个 /admin 子树 (含 HTML) 统一用 AdminAuth —
用户进页面前输 token, JS 存 localStorage, 后续 fetch 自动加 header。
简单且一致, 不搞"白名单 + 不带 token 也能看页"这种特殊 case。
Constraint:
- 不引第三方 Go 库 (不用 gofiber/swagger/scalar-go)
- 不引前端框架 (no React/Vue)
- 不开 JS bundler (no webpack/vite)
- HTML/CSS/JS 全内嵌在 cluster.html 一个文件
- Scalar 走 CDN (@scalar/api-reference latest)
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-10 18:17:37 +08:00