- dashboard.html: each section sits in OPTIONAL:<name> BEGIN/END blocks in the style, markup and script, with sample answers so a page with no bot shows it working. Core change: setUser records the role on <body>, so CSS hides admin-only parts from operators. - templates/sections.py keeps the chosen sections and deletes the rest, markers included; it stops on a broken marker. - templates/sections.md: what each section needs from the host (events, actions, desktop slot snippets, the role re-check, the login hand-off). - SKILL.md step 5 asks one multi-select question and runs sections.py. - Page check: checkpoint states, admin visibility by role and assign/remove, login theme and hand-off to auth or the stub. Cases skip on a generated page without the section; the template must carry all three. The harness signs in when the page has a login screen. - tests/test_sections.py: no sections leave no trace, and that page still passes the page check. - Eval runner: a-empty-sections variant (all three) and per-section checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
2.1 KiB
Markdown
33 lines
2.1 KiB
Markdown
# Dashboard data contract (no-AI)
|
|
|
|
All updates use one envelope: `{"event": "<name>", "data": {...}}`.
|
|
- **Desktop (PyQt):** Python calls `window.__pyMsg(json)` via `runJavaScript` (see `bridge.py`).
|
|
- **Web:** the page polls `GET {API_BASE}/dashboard` (returns `dashboard_data`) and
|
|
`GET {API_BASE}/run/status` → `{"running": bool, "events": [envelope, ...]}`. Poll fast (2s) only while running.
|
|
- **No bot yet:** with `SAMPLE_DATA = true`, the page answers its own data actions with sample envelopes.
|
|
|
|
## Bot/backend → page
|
|
|
|
| event | data |
|
|
|---|---|
|
|
| `status` | `{state: "ready"\|"running"\|"done"\|"error", msg}` |
|
|
| `step` | `{label: <one of STEPS>, pct: 0-100}` |
|
|
| `log` | `{msg: <plain English>, type: "info"\|"success"\|"warn"\|"error"}` |
|
|
| `dashboard_data` | `{batches: [{batch_id, date, state: "completed"\|"inprogress"\|"notcompleted"\|"cleared", items_total, items_done, ...}]}` |
|
|
| `report_data` | `{rows: [{...REPORT_COLUMNS keys, status, bucket: "success"\|"attention"\|"failed"}]}` |
|
|
| `set_user` | `{username, emp_id, role}` |
|
|
| `apply_dark` | `{on: bool}` |
|
|
|
|
Optional sections (only if chosen) add `cpstate`, `admin_data` and `login_result`, and the actions `load_admin`, `assign_role`, `remove_role` and `login`. See `sections.md`.
|
|
|
|
## Page → bot/backend (Qt `@pyqtSlot` names / web `POST {API_BASE}/<slot-with-dashes>`)
|
|
|
|
`load_dashboard`, `start_automation`, `request_stop`, `load_latest_report`, `download_report`, `set_dark(on)`, `logout`.
|
|
|
|
## Rules (learned on Tebra)
|
|
- Log the raw bot line to a file/DB; show only **friendly** text on screen. Never hide an error line.
|
|
- Step markers: match the bot's printed lines by **specific** substring (e.g. `[step 3]`), not a bare word. A bare word matches unrelated lines.
|
|
- Derive `state`: Pending + today = `inprogress`; Pending + older day = `notcompleted`.
|
|
- Report `bucket`: success = {processed successfully, posted, completed}; failed = {error, failed}; everything else = attention.
|
|
- Run the bot in a **separate process** that writes to a log file, and have the UI tail that file. When pywinauto/UIA runs inside a Qt worker thread, its reads are unreliable (Tebra bug-094).
|