Commit Graph

16 Commits

Author SHA1 Message Date
Leo 510bafc919 feat: multi-role support — comma-separated roles with checkbox UI
- Added validate_roles() and roles_contain() helpers for comma-separated roles
- Updated create_user/update_user to accept role combinations (e.g. 'admin,technician')
- Changed all exact role queries (='technician', IN('technician','admin')) to LIKE
- Replaced single <select> with checkboxes in add/edit user modals
- Added renderRoleBadges() to display multiple role badges per user
- Added checkbox-group/checkbox-label CSS styles
- Updated tech-photo-upload technician query to use LIKE
- Updated db reset auth check to use roles_contain()
- Set shawn's role to 'admin,technician'
- Cleaned up unused imports (hashlib, io, etc.)

Applies to canteen-admin-server, canteen-admin-server-dev, and tech-photo-upload
2026-05-25 23:11:00 -04:00
Leo e7cdac7c44 fix: remove duplicate brace causing JS parse failure on admin page 2026-05-23 18:49:44 -04:00
Leo afc38438b0 fix: remove old raw detail tables from pending review card — use per-field approval UI only 2026-05-23 18:46:59 -04:00
Leo 8fc6a93ff2 fix: per-field review UI polish — blank-fill auto-select, btn-accent CSS, card-bg fixes, sticky bar z-index 2026-05-23 18:35:27 -04:00
Leo c35e2a1af9 feat: per-field approval backend + geotagger-style frontend
Backend (cantaloupe_sync.py):
- GET /api/admin/cantaloupe/batches/{id}/field-changes — flat list of per-field diffs
- POST /api/admin/cantaloupe/batches/{id}/apply-field-changes — apply selected changes only
- PerFieldApprovalRequest/FieldChangeItem Pydantic models
- Activity log entries for apply-field-changes

Frontend (static/index.html):
- toggleFieldReview() — loads field changes via API, shows/hides review area
- renderFieldChanges() — geotagger-style cards with checkboxes per field, grouped by machine
- applyFieldChanges() — POST selected changes with confirmation modal
- Auto-select blank-fill changes (is_blank_fill flag)
- Sticky apply bar at bottom with live selected count
- Toggle all, toggle per-asset, toggle per-field helpers
- Review Changes button in pending review card
2026-05-23 18:24:39 -04:00
Leo ea1feaaad1 feat: replacement candidate review UI + approve/reject workflow
- GET /api/admin/cantaloupe/batches/{id}/replacements returns candidates
- POST /api/admin/cantaloupe/batches/{id}/replacements resolves (approve/reject)
- Approve retires old asset (status=retired), sets install_date on new
- Reject records decision without modifying assets
- Batch approve blocks if unresolved replacements exist (use ?force=true)
- Frontend shows replacement cards with confidence badges in batch detail
- Per-replacement ✓ Approve / ✗ Reject buttons + ✓ Approve All bulk action
- History view shows replacement counts with unresolved warnings
2026-05-23 17:55:54 -04:00
Leo 8d5deb735b Fix route ordering: /search before /{asset_id}
- /api/assets/search must be registered before /api/assets/{asset_id}
  to prevent FastAPI path param from catching 'search' as an asset_id.
  Returning a 422 with array detail caused frontend to show [object Object].
- Improve error message extraction in clearAssetGps catch block.
2026-05-22 23:45:26 -04:00
Leo 9794d8076c Add clear asset GPS endpoint + UI
- DELETE /api/assets/{id}/gps: clears lat/lng to NULL
- GET /api/assets/{id}: asset lookup by ID
- GET /api/assets/search?machine_id=: asset lookup by machine ID
- Export & Admin page: Clear Asset GPS card with lookup + confirmation
- Tests: 204 success + 404 not found
2026-05-22 23:36:40 -04:00
Leo cd1f04a519 fix(admin): sidebar hamburger menu for mobile, remove auto Cantaloupe sync
- Replace broken icon-only sidebar collapse with off-canvas hamburger menu
  that slides in from left (hidden by default on <768px)
- Add sidebar overlay backdrop, auto-close on nav/logout
- Rename 'Cantaloupe Sync' to 'Import' in sidebar and 'Excel Import' in page
- Remove 'Sync Now' button and backend subprocess auto-export entirely
- Keep manual Excel file upload as the only import path
- Update empty-state text and upload handler to work without Sync Now btn
2026-05-22 16:08:07 -04:00
Leo 90a426bc9e Fix Cantaloupe Sync: use sys.executable + add Excel file upload button
- Changed subprocess from 'python' to 'sys.executable' (fixes FileNotFoundError
  in systemd — venv python not in system PATH)
- Added '📤 Upload Excel' button to admin frontend sync page
- uploadSyncFile() sends file to the same /api/admin/cantaloupe/sync endpoint
  (which already supported file upload — frontend just didn't expose it)
- Users can now use 'Sync Now' for auto-download or 'Upload Excel' for manual
2026-05-21 23:10:22 -04:00
Leo b91ed6bc7b Fix: add responsive breakpoints for mobile (480px + 768px) — sidebar, stats grid, Cantaloupe Sync page, form rows 2026-05-21 20:05:52 -04:00
Leo 20002f4fcb fix: update login password hint from Brett85!@ to changeme 2026-05-21 19:47:03 -04:00
Leo 070e8c2ddb Add Cantaloupe Sync admin UI page
- New 'Cantaloupe Sync' nav item in sidebar with sync icon
- Section 1: Sync Overview showing latest batch status, diff badges
- Section 2: Pending Batch Review with approve/reject buttons and diff detail
- Section 3: Import History with expandable rows for full diff view
- Added static file serving (FileResponse) to admin_server.py
- Fixed formatDate to handle space-separated SQLite datetimes
- Dark theme matching existing admin UI, vanilla JS with fetch()
2026-05-21 19:38:36 -04:00
Leo 19bdbf0ec3 t_6549bb2b: Align SPA with admin server API (reset endpoint, initAuth, remove SQL query) 2026-05-21 17:19:39 -04:00
Leo d1c7853877 Initial commit: Admin API server extracted from canteen-asset-tracker 2026-05-21 17:19:14 -04:00
shawn c4e45c2569 t_6549bb2b: Create admin frontend SPA with full CRUD, dashboard, activity, export 2026-05-21 17:18:36 -04:00