152 Commits

Author SHA1 Message Date
jesxion
9197417839 fix: align h5 dev proxy with server port
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-28 10:21:49 +08:00
jesxion
d02cb71891 docs: add readme cleanup implementation plan
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-27 19:56:33 +08:00
jesxion
d5b5733420 docs: fix h5-app dev proxy port and admin-web test mode note
- Correct h5-app DEV_API_TARGET example from 3000 to 3201, matching
  h5-app/.env and vite.config.ts (which both use 3201 as the dev proxy
  target for the backend API)
- Update h5-app dev server inline comment to show :3201 consistently
- Clarify that admin-web `npm test` (vitest) runs in watch/interactive
  mode by default; show `-- --run` flag for one-shot CI-style execution

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-27 19:34:37 +08:00
jesxion
f10edb5716 docs: add root-level README.md in Chinese
Cover repository overview, directory structure, tech stack, environment
prerequisites, local development workflow, build commands, production
deployment suggestions, Nginx reverse proxy examples, database/env var
notes, and FAQ.

Clearly distinguish the current runnable implementation (server /
h5-app / admin-web) from the target production architecture described
in SPEC.md and docs/ (Aliyun OSS, Henan Sannong device push, full
multi-tenant isolation).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-27 19:25:28 +08:00
jesxion
699a8e749f docs: add readme and branch cleanup design
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-27 19:13:58 +08:00
jesxion
8d560524f9 feat: sync released server and h5 updates
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 21:12:52 +08:00
jesxion
845b313739 feat: expand project user role labels
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 21:12:31 +08:00
jesxion
d5855295d8 fix: polish admin shell header and logout
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 19:57:50 +08:00
jesxion
72140b1461 fix: support production platform login response
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 19:43:36 +08:00
jesxion
479304e74a fix: use same-origin admin api by default
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 19:39:32 +08:00
jesxion
7c81419613 fix: support admin deployment base path
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 19:26:09 +08:00
jesxion
08102f6992 fix: finalize admin redesign release
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 19:23:08 +08:00
jesxion
f4c38e696f feat(admin): restore edit/reset capabilities on redesigned detail page
- Add EditProjectModal, EditProjectUserModal, ResetProjectUserPasswordModal
  to the redesign worktree (ported from main workspace)
- Update ProjectDetailPage to integrate all three modals while preserving
  the admin-panel/admin-kpi-grid redesigned visual language
- Add 编辑项目信息 button (with aria-label) in the hero section alongside
  新增项目账号 button
- Add per-row 编辑/重置密码 action buttons (with aria-label) to the users table
- Refactor useEffect fetch into async inner function to satisfy
  react-hooks/set-state-in-effect lint rule
- Fix no-explicit-any in request.ts (any → unknown for generic defaults)
- Fix no-explicit-any in tests/setup.ts (globalThis cast)
- Fix no-explicit-any in tests/project-detail-page.test.tsx (options type)
- Add TDD tests for edit-project, edit-user, and reset-password flows;
  all 25 tests pass, lint clean, build succeeds

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 19:13:02 +08:00
jesxion
8873ec7dfc feat(admin-web): polish responsive behavior and accessibility states
- Add focus-visible outline for a/button/input inside .admin-shell
- Add @media (max-width:1100px) 2-col breakpoint for kpi/detail grids
- Add @media (max-width:860px) single-col breakpoint, hide sidebar,
  stack toolbar/section-heading, reduce horizontal padding
- Add aria-label="项目总览" to overview section in ProjectListPage
- Add aria-label="项目工作台" to hero section in ProjectDetailPage
- Add tests: named region landmark for overview + hero sections,
  searchbox accessible name (4 new tests, all green; 19 total)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:58:16 +08:00
jesxion
e58a74bc28 feat: redesign admin project detail workspace
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:52:17 +08:00
jesxion
8fcf6b7c17 fix(task3): gate detail sections on project, fix copy, fix brittle test
- Gate admin-detail-grid and accounts table on project existence;
  renders a fallback panel instead of zero-count workspace panels when
  project data is unavailable (prevents misleading partial-success UI)
- Correct '管理员与普通成员' to '项目管理员与项目经理' - the system only
  supports these two roles; also fix '管理员' to '项目管理员' in the
  账号概览 copy
- Replace brittle DOM-order test (findAllByText + last index) with
  findByTitle, which matches the title attribute Ant Design sets on
  each visual option element in the Select dropdown - unambiguous and
  not order-dependent
- Add test case for empty-project fallback to cover the new guard

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:47:01 +08:00
jesxion
4685558e33 feat: redesign admin project detail workspace
- Replace single-card layout with hero section, 3-column KPI grid, and grouped panels
- Add admin-panel, admin-detail-hero, admin-detail-grid CSS utilities
- Add KPI cards: 账号总数, 管理员账号, 项目经理
- Add 项目信息 and 账号概览 side-by-side grid cards
- Add grouped 账号与密码管理 table section
- Preserve existing 新增项目账号 create flow with single button in hero
- Add and pass: 'shows project summary cards and grouped account operations' test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:22:13 +08:00
jesxion
d55ef56f31 feat: enrich admin project list overview
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:17:12 +08:00
jesxion
a225d0f0e3 fix(projects): resolve Task 2 signoff issues in ProjectListPage
- Clear searchQuery after project creation so newly created projects
  are visible even when a search filter is active
- Disable refresh button while loading to prevent overlapping fetches
- Fix loadProjects referenced-before-declaration lint error by moving
  it to useCallback declared before useEffect; suppress
  react-hooks/set-state-in-effect for the intentional async data-fetch
  pattern (same pattern used in ProjectDetailPage)
- Add TDD tests first: 'clears search filter after creation' and
  'disables refresh button while loading'; verified failing before impl,
  passing after; all 13 tests pass with no lint errors on this file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:04:32 +08:00
jesxion
38e5d63273 feat: redesign admin project overview
- Add KPI overview section (项目总览) with project count, account total, and latest project cards
- Add toolbar with search input and refresh button above the project table
- Extract 'new project' button into the overview heading for better hierarchy
- Add admin-overview, admin-kpi-grid, admin-kpi-card, admin-table-section, admin-toolbar CSS classes
- Extend Project type with optional user_count field
- Convert it.fails placeholder to passing overview test
- Fix modal test to use role-based selector (avoids duplicate text in KPI card + table)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 17:17:06 +08:00
jesxion
2640b243ea feat: add structured admin shell
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 17:14:40 +08:00
jesxion
12653235be feat: add structured admin shell
- Replace placeholder AppLayout with dark sidebar nav, semantic header/content zones
- Add CSS design tokens and shell utility classes to global.css
- Add shell-aware test expectation for 项目总览 (fails until Task 2 implements it)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 16:38:29 +08:00
jesxion
db0eabe3a6 feat: add project detail and account assignment ui
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:41:51 +08:00
jesxion
327b486e6d fix: polish admin project ui
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:28:24 +08:00
jesxion
7a23e81c9c feat: add platform login and project list ui
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:15:32 +08:00
jesxion
0d7f85c3e1 fix: trim admin scaffold
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:03:58 +08:00
jesxion
d1eddba8a5 feat: scaffold platform admin web app
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:57:04 +08:00
jesxion
bc489f1e7a feat: add platform project user management api
- Add user repository functions for project user CRUD
- Create platform-user-service for project user management
- Add GET /v1/platform/projects/:id/users endpoint
- Add POST /v1/platform/projects/:id/users endpoint
- Support project_admin and manager roles
- Validate username uniqueness and project existence
- Normalize real_name and phone inputs
- Add comprehensive test coverage (13 tests)
- Fix test isolation issue in platform-projects cleanup

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:40:12 +08:00
jesxion
c0b4f7f66e fix: tighten project api validation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:34:30 +08:00
jesxion
80d13a80c4 fix: tighten platform project api
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:27:09 +08:00
jesxion
c111083ce7 feat: add platform project management api
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:16:58 +08:00
jesxion
84dd09458f fix: harden platform login flows
- Add timing-attack mitigation by always verifying passwords against real or dummy hash
- Add comprehensive negative-path tests for platform login (wrong password, non-existent user, project user rejection, invalid body)
- Add focused middleware tests for requirePlatformAuth covering auth header validation and user type enforcement
- All 60 tests passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:06:01 +08:00
jesxion
003267b281 feat: add platform admin login
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:53:57 +08:00
jesxion
5e03ba3593 fix: guard nullable project_id in getProjectId
After Task 1 changed AuthUser.project_id from number to number | null, getProjectId now explicitly checks for null values and throws an error for platform users attempting to access project resources.

This fix:
- Adds null check to reject platform users (project_id === null)
- Maintains type safety by ensuring return type is always number
- Includes comprehensive unit tests for all scenarios
- Preserves existing project-side behavior for valid project users

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:52:51 +08:00
jesxion
bcd0abaf8a fix: harden project login user type check
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:47:09 +08:00
jesxion
5ec5d03f57 test: assert platform login error message
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:37:58 +08:00
jesxion
7a7cf25e50 feat: split platform and project auth users
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:31:56 +08:00
jesxion
3df38e44c6 docs: add platform admin design spec
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:23:44 +08:00
jesxion
7718330d7d chore: remove legacy h5 static prototype
The old static HTML/CSS/JS prototype in h5/ is superseded by the
React + Ant Design Mobile app in h5-app/. Removing to avoid confusion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:56:50 +08:00
jesxion
018eab2918 feat: merge Ant Design Mobile H5 app, replace legacy h5 prototype
The feature/h5-design-polish branch brings in a complete React + Ant Design
Mobile rebuild of the H5 client (in h5-app/), replacing the old static
prototype in h5/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:56:38 +08:00
jesxion
b89b58108d feat(h5-app): add mock login fallback and fix apiLogin flow
- Add MOCK_ACCOUNTS with admin/123456 and worker/123456 as fallback
  when real backend is unavailable
- apiLogin tries real backend first; falls through to mock only on failure
- Supports real JWT token flow when backend (port 3201) is available

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:53:44 +08:00
jesxion
268d9b0394 fix: reports page mock data, date display, and severity badge mapping
- apiGetReports: use mock data instead of real API (no backend available)
- reports.html: add mock.js script include
- Fix date display: was concatenating dateStr+timeStr causing duplication
- Fix severity badge: map Chinese mock values to backend enum keys

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:34:36 +08:00
jesxion
2ec5c98759 chore: add github instructions, superpowers config, and hazards plan docs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:20:45 +08:00
jesxion
6c7143329f refactor: align log module structure
- Add LogsPage.tsx re-export alias pointing to LogListPage
- Add src/tests/log-ui-model.test.ts with 26 targeted tests for log
  UI-model and helper semantics (getLogStatusMeta, findTodayLog
  integration, format helpers, equipment labels, truncate,
  getTodayDateString, WEATHER_OPTIONS)
- Refactor LogFormPage to use ADM Form/Form.Item/Form.Header for
  section layout, ADM Input for text fields, ADM Stepper for worker
  count; remove hand-rolled FieldLabel and RequiredMark helpers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 19:08:31 +08:00
jesxion
373a781b5b fix: align log flow semantics
- Make date field editable (initialized to today)
- Rename remark → note to match legacy h5/log.html semantics
- Add photo upload field to LogFormPage
- Move weather to optional (was incorrectly required)
- LogDetailPage: render note, photo gallery, author+created_at footer
- Weather block is now conditional (not forced)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 19:01:47 +08:00
jesxion
5257c1534c feat: port logs flow to ant mobile
- Add src/mocks/logs.ts: canonical in-memory log store (5 seed entries, addLog/getLog/getLogs)
- Add src/features/logs/types.ts: LogItem and Equipment types
- Add src/features/logs/utils.ts: formatLogDate, formatLogTime, getEquipmentLabels, findTodayLog, truncate
- Add src/features/logs/LogListPage.tsx: today card + history list + FAB, mirrors logs.html semantics
- Add src/features/logs/LogDetailPage.tsx: hero, body sections, meta grid, equipment tags
- Add src/features/logs/LogFormPage.tsx: core + extra fields, Selector for weather/equipment, mock submit
- Update src/lib/mock-logs.ts: shim re-export from mocks/logs.ts (backward compat for HomePage)
- Update src/App.tsx: wire /logs, /logs/new, /logs/:id routes; drop placeholder LogsPage import
- Update src/pages/LogsPage.tsx: forward-export to features/logs/LogListPage
- Update package.json: add preview:local script (port 8084, host 0.0.0.0)
- Add src/tests/logs-utils.test.ts: 14 tests covering all util helpers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:53:09 +08:00
jesxion
74f367ef90 fix: guard hazard list state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:42:17 +08:00
jesxion
d67b935882 fix: guard hazard async state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:39:52 +08:00
jesxion
e0ea692e65 fix: harden hazard upload reliability
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:35:28 +08:00
jesxion
cb6010715d fix: correct hazard upload flow
- Fix upload-token API: backend returns { uploadUrl, objectKey } directly
  (camelCase, no ApiResponse wrapper); update UploadTokenResult interface
  and remove incorrect res.data access
- Fix confirm API: backend returns { fileId, objectKey } directly (no url,
  no ApiResponse wrapper); update ConfirmResult interface accordingly
- uploadPhoto now returns { url: blobUrl, extra: { objectKey } } so the
  ImageUploader can show a local preview while HazardReportPage submits
  the confirmed objectKey (via extra) rather than the ephemeral blob URL
- Fix geolocation: getCurrentPosition returns void, not a watch ID;
  remove the incorrect cast and clearWatch cleanup call; drop unused gpsWatchId ref

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:30:39 +08:00