No description
Find a file
2025-08-18 20:05:25 +02:00
.vscode/alive/fasl broke up UI into widgets and parsed /me properly 2025-06-20 11:29:34 +02:00
css enlargedthe logog a bit and fixed logout path 2025-06-24 16:00:01 +02:00
img broke up UI into widgets and parsed /me properly 2025-06-20 11:29:34 +02:00
js added relations editors for silos, projects, groups and users 2025-08-18 20:05:25 +02:00
node_modules init 2025-06-16 19:41:34 +02:00
.gitignore init 2025-06-16 19:41:34 +02:00
Dockerfile fixed some api bugs 2025-08-17 21:15:32 +02:00
index.html fixed some api bugs 2025-08-17 21:15:32 +02:00
LICENSE Initial commit 2025-06-16 19:36:30 +02:00
package-lock.json init 2025-06-16 19:41:34 +02:00
package.json init 2025-06-16 19:41:34 +02:00
README.md fixed some api bugs 2025-08-17 21:15:32 +02:00

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.origin if 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>/schema
  • save(model):
    • Create (no id) → POST /api/<table>
    • Update (has id) → PUT /api/<table>/<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/json and send Content-Type: application/json when 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 in js/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 /api as well.

Where things are used

  • js/data.js: API origin helpers and ObservableCollection implementation
  • js/DataTableWidget.js: consumes collection for list + schema
  • js/ObjectEditorWidget.js: uses collection schema and save() for create/update
  • js/CreateItemButton.js: opens editor for new item via collection
  • js/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.