Skip to content

[Agent] PTZ: UI to save presets and set home position #658

Closed

Description

@matteius

Problem and evidence

The live-view PTZ controls (web/js/components/preact/PTZControls.jsx) can only use presets that already exist. The backend can create presets and set home, but the UI exposes neither:

  • PUT /api/streams/{name}/ptz/preset with body {"name": "<preset name>"} saves the camera's current position as a new ONVIF preset and returns its token (src/web/api_handlers_ptz.c, handle_ptz_set_preset).
  • POST /api/streams/{name}/ptz/set-home saves the current position as home (handle_ptz_set_home).
  • Both require AUTHZ_PTZ_CONTROL and are audit-logged. Routes are in src/web/libuv_api_handlers.c:229-238.
  • The UI already has: move, stop, home, GET /ptz/presets, and POST /ptz/goto-preset (fixed in 38e90865).

Expected behavior and scope

  • In the PTZ panel, add "Save current position as preset…" (asks for a name, then refreshes the preset list on success) and "Set current position as home" (with confirmation).
  • Hide or disable both when GET /ptz/capabilities says presets or home aren't supported (check which capability fields exist), or when the user gets a 403.
  • Show success and failure with the existing toast pattern (live.ptzPresetFailed-style keys).
  • New strings go in en.json under live.*.
  • Optional, only if the backend already supports it: removing a preset. Don't add backend routes in this issue.

Acceptance criteria

  • Saving a preset adds it to the dropdown without a page reload, and "Go to preset" then moves the camera there.
  • Set-home followed by Home returns to the new position.
  • Buttons are keyboard accessible with aria labels (jsx-a11y lint passes).

Validation

  • cd web && npx vite build, npm run lint, npm test.
  • Jest test with fetch mocked, checking method, URL and body for both actions and the preset-list refresh.
  • Manual test on a real ONVIF PTZ camera if one is available. Mention in the PR if it was untested on hardware.

Constraints and rollback

  • Frontend only.
  • Rollback: revert.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjavascriptPull requests that update javascript code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions