Move the dashboard and setup pages to a Vue SPA
The pages are now a Vue 3 + Vite + TypeScript app in web/, built into internal/web/dist/app and embedded in the binary. Go still serves index.html for / and /setup behind the admin gate, plus the hashed /assets/* (public, cached forever). The router takes its base from the current URL, so it works under nginx's /tracker/ prefix unchanged. Only dist/.gitkeep is committed, so go build and go test need no Node; an unbuilt binary shows a "run make web" page at /. The Dockerfile gains a Node stage, CI typechecks and builds the app, and make build/run build it first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -79,7 +79,7 @@ tracker goal rm --id 2
|
||||
|
||||
## Dashboard and auth
|
||||
|
||||
The dashboard (`/`) and the setup page (`/setup`) have no login of their own. As in job-tracker, the tracker borrows the main site's session. It forwards the browser's cookies to the site backend's `GET /auth/validate-admin` and treats a 2xx as admin (`internal/auth`). A visitor who isn't signed in is sent to the site's `/admin/login?redirect=/tracker/`, which returns them afterwards. A "yes" is cached for 30 seconds per cookie, so signing out takes up to 30 seconds to reach the tracker. If the backend refreshes an expired token, its new cookies are passed back to the browser.
|
||||
The dashboard (`/`) and the setup page (`/setup`) are one Vue app (`web/`), built into the Go binary. They have no login of their own. As in job-tracker, the tracker borrows the main site's session. It forwards the browser's cookies to the site backend's `GET /auth/validate-admin` and treats a 2xx as admin (`internal/auth`). A visitor who isn't signed in is sent to the site's `/admin/login?redirect=/tracker/`, which returns them afterwards. A "yes" is cached for 30 seconds per cookie, so signing out takes up to 30 seconds to reach the tracker. If the backend refreshes an expired token, its new cookies are passed back to the browser.
|
||||
|
||||
Signed in, the dashboard shows every device's data without asking for a key. The setup page has step-by-step instructions for each collector, with your server URL filled in. It also lists devices and creates and revokes their API keys, so you don't need `docker exec` for keys. Each collector's section has a **Generate key** button that names the device (for example `firefox`, or `hyprland-2` if that's taken), copies the key to the clipboard and fills it into that collector's steps.
|
||||
|
||||
@@ -103,8 +103,8 @@ Collectors never use the site login. Each one sends its own bearer key.
|
||||
| GET | `/api/v1/summary/daily?date=YYYY-MM-DD` | key or admin | totals per label and kind, plus goal results |
|
||||
| GET, POST | `/api/v1/devices` | admin | list devices; create one with `{"name","kind"}`, which returns its key once |
|
||||
| DELETE | `/api/v1/devices/{name}` | admin | revoke a device's key |
|
||||
| GET | `/`, `/setup` | admin | dashboard and setup pages |
|
||||
| GET | `/tracker.user.js`, `/style.css`, `/healthz`, `/readyz` | none | the browser userscript holds no secrets |
|
||||
| GET | `/`, `/setup` | admin | the dashboard app |
|
||||
| GET | `/tracker.user.js`, `/assets/*`, `/healthz`, `/readyz` | none | the userscript and the app's scripts hold no secrets |
|
||||
|
||||
The event batch format is shared by all `*/events` endpoints. A batch holds at most 1000 events.
|
||||
|
||||
@@ -183,10 +183,13 @@ To track time outside: `tracker goal add --kind place --label away --op '>=' --t
|
||||
```sh
|
||||
make test # unit tests
|
||||
make up && make test-integration # also runs the API tests against the compose Postgres (truncates its tables!)
|
||||
make run # run the server locally against the compose Postgres
|
||||
make run # build the app, then run the server locally against the compose Postgres
|
||||
make web-dev # with `make run` going: Vite on :5173 with hot reload, proxying /api to :8080
|
||||
```
|
||||
|
||||
Layout: `cmd/tracker` (server and admin CLI), `cmd/hypr-agent`, `internal/{api,auth,ingest,store,summary,migrations,config,web}` (`web/tracker.user.js` is the browser collector), `internal/agent/hypr`, `deploy/`.
|
||||
The dashboard is a Vue 3 + Vite app in `web/`. `make web` (and `make build`, `make run`, the Docker build) builds it into `internal/web/dist/app`, which the binary embeds. That directory isn't committed, so a plain `go build` serves a "not built" page at `/` but everything else works, and `go test` needs no Node.
|
||||
|
||||
Layout: `cmd/tracker` (server and admin CLI), `cmd/hypr-agent`, `internal/{api,auth,ingest,store,summary,migrations,config,web}` (`internal/web/tracker.user.js` is the browser collector), `web/` (dashboard app), `internal/agent/hypr`, `deploy/`.
|
||||
|
||||
## Roadmap
|
||||
|
||||
|
||||
Reference in New Issue
Block a user