No description
| .vscode/alive/fasl | ||
| css | ||
| img | ||
| js | ||
| node_modules | ||
| .gitignore | ||
| Dockerfile | ||
| index.html | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
Admin UI
This UI communicates with a backend via a simple REST API. The API base can be configured at runtime, and the UI manages table data via a small ObservableCollection abstraction.
Configure API base
In index.html:
<script>
// Configure backend API before any modules run
window.API_BASE = window.API_BASE || "http://localhost:9003";
</script>
The frontend computes API_ORIGIN() from window.API_BASE with support for:
- Protocol-relative URLs (e.g.
//api.example.com) - Hostnames without scheme (e.g.
api.example.com) - Full URLs (e.g.
https://api.example.com) - Falls back to
location.originif not set
Table API patterns (canonical)
All table endpoints now follow these exact shapes:
- List:
GET /api/<table> - Single:
GET /api/<table>/<id> - Schema:
GET /api/<table>/schema - Create:
POST /api/<table> - Update:
PUT /api/<table>/<id> - Delete:
DELETE /api/<table>/<id>
No trailing slashes are used on collection URLs.
Examples (replace user and 123)
# List
curl -sS "$API_BASE/api/user" -b cookies.txt
# Single
curl -sS "$API_BASE/api/user/123" -b cookies.txt
# Schema
curl -sS "$API_BASE/api/user/schema" -b cookies.txt
# Create
curl -sS -X POST "$API_BASE/api/user" \
-H "Content-Type: application/json" \
-d '{"name":"Alice"}' -b cookies.txt
# Update
curl -sS -X PUT "$API_BASE/api/user/123" \
-H "Content-Type: application/json" \
-d '{"name":"Alice B."}' -b cookies.txt
# Delete
curl -sS -X DELETE "$API_BASE/api/user/123" -b cookies.txt
Cookies are included by the UI using credentials: "include".
Frontend data access
Implemented in js/data.js:
- Base URL per table:
API_ORIGIN() + "/api/<name>" load()→GET /api/<table>loadSchema()→GET /api/<table>/schemasave(model):- Create (no id) →
POST /api/<table> - Update (has id) →
PUT /api/<table>/<id>
- Create (no id) →
deleteMany(ids)→DELETE /api/<table>/<id>for each id
Notes:
- Collection URLs are normalized to have no trailing slash.
- All requests specify
Accept: application/jsonand sendContent-Type: application/jsonwhen there is a body. credentials: "include"is set for schema/data load, save, and delete to support cookie-based auth.
Other endpoints
GET /me/(used injs/models.js) remains as-is; it is outside table CRUD scope.- Edge utilities in
js/rpc.js(/edge,/outgoing) are domain-specific and unchanged. Migrate them only if you want them under/apias well.
Where things are used
js/data.js: API origin helpers and ObservableCollection implementationjs/DataTableWidget.js: consumes collection for list + schemajs/ObjectEditorWidget.js: uses collection schema and save() for create/updatejs/CreateItemButton.js: opens editor for new item via collectionjs/models.js: declares per-table collections (getCollection('user'),getCollection('silo'))
Backend requirements
Ensure the backend routes accept the canonical forms without trailing slashes and provide GET /api/<table>/schema. If previously only /schemas/<table>/ was supported, add a compatibility route or switch the backend to the new path.