12 Commits

Author SHA1 Message Date
Isaac Connor
c2b2de4a86 feat: show both percentage and pixel values in zone edit UI
Remove the Units selector and always store/display thresholds as
percentages. Add editable pixel inputs alongside each percentage field
with bidirectional sync. Zone area is now displayed as plain text
instead of readonly inputs. Pixel inputs are disabled/enabled in sync
with their percentage counterparts based on zone type and check method.

Server-side enforcement ensures values > 100 are converted from pixel
counts to percentages before storage and clamped to 0-100.

Add aspect-ratio to imageFeed container to prevent layout flash on load.
Hide number input spinners in zone settings panel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:14:53 -04:00
Isaac Connor
29d371313a fix: store zone thresholds as percentages and convert to pixels at runtime
Zone threshold fields (MinAlarmPixels, MaxAlarmPixels, MinFilterPixels,
MaxFilterPixels, MinBlobPixels, MaxBlobPixels) were being corrupted on
every save because the PHP conversion used monitor pixel area instead of
zone pixel area. This caused values to inflate progressively, breaking
motion detection.

The fix changes the storage model: thresholds are now stored as
percentages of zone area (DECIMAL(7,2) columns) matching the percentage
coordinate system from zm_update-1.39.2. The C++ Zone::Load() converts
percentages to pixel counts at runtime using polygon.Area(). Legacy
pixel-coordinate zones pass through unchanged.

JS changes:
- submitForm() converts to percentages when in Pixels display mode
- Init skips applyZoneUnits() since DB values are already percentages
- limitRange() only updates field.value when constrained value differs,
  preventing oninput from stripping decimal points mid-keystroke

fixes #4690

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:16:56 -04:00
Isaac Connor
e6ace6fcf4 feat: add AUDIT logging level for tracking administrative changes
Add a new AUDIT logging level (-5) between PANIC (-4) and NOLOG (shifted
to -6) across C++, PHP, and Perl loggers. AUDIT entries use code 'AUD'
and syslog priority LOG_NOTICE. They record who changed what, from where,
for monitors, filters, users, config, roles, groups, zones, states,
servers, storage, events, snapshots, control caps, and login/logout.

AUDIT entries have their own retention period (ZM_LOG_AUDIT_DATABASE_LIMIT,
default 1 year) separate from regular log pruning. The log pruning in
zmstats.pl and zmaudit.pl now excludes AUDIT rows from regular pruning
and prunes them independently.

Critical safety: the C++ termination logic is changed from
'if (level <= FATAL)' to 'if (level == FATAL || level == PANIC)' to
prevent AUDIT-level log calls from killing the process.

Includes db migration zm_update-1.39.1.sql to shift any stored NOLOG
config values from -5 to -6.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:19:20 -05:00
Isaac Connor
c0016fa00b feat: store zone coordinates as percentages for resolution independence
Convert zone coordinates from absolute pixel values to percentages
(0.00-100.00) so zones automatically adapt when monitor resolution
changes. This eliminates the need to manually reconfigure zones after
resolution adjustments.

Changes:
- Add DB migration (zm_update-1.37.81.sql) to convert existing pixel
  coords to percentages, recalculate area, and update Units default
- Add Zone::ParsePercentagePolygon() in C++ to parse percentage coords
  and convert to pixels at runtime using monitor dimensions
- Backwards compat: C++ Zone::Load() checks Units column and uses old
  pixel parser for legacy 'Pixels' zones
- Update PHP coordsToPoints/mapCoords/getPolyArea for float coords,
  replace scanline area algorithm with shoelace formula
- Update JS zone editor to work in percentage coordinate space with
  SVG viewBox "0 0 100 100" and non-scaling-stroke for consistent
  line thickness
- Position zone SVG overlay inside imageFeed container via JS to align
  with image only (not status bar)
- Support array of zone IDs in Monitor::getStreamHTML zones option
- Update monitor resize handler: percentage coords don't need rescaling,
  only threshold pixel counts are adjusted
- Add 8 Catch2 unit tests for ParsePercentagePolygon

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:19:20 -05:00
Isaac Connor
ee89169a7b Use reload instead of restart on zone save 2023-02-16 14:10:30 -05:00
Isaac Connor
105eff7a21 Remove references to zma 2021-02-01 17:29:16 -05:00
Isaac Connor
cf08010ebe Fix redirect on zone editing 2020-11-18 13:04:56 -05:00
Andrew Bauer
802e439cb5 convert controlpreset view to a modal 2020-10-02 15:46:28 -05:00
Isaac Connor
eb2269ea52 improve zone saving testing for value before doing math 2019-10-29 17:42:23 -04:00
Isaac Connor
4126554092 Move sendControlCommand out of includes/control_functions.php into Monitor.php. Make it smarted about talking to zmcontrol.pl. Fix sending the quit command 2019-10-08 18:07:33 -04:00
Isaac Connor
7e6b0058d2 Update Zone buttons. Fix double submit. Fixes #2671 2019-08-02 08:04:38 -04:00
Isaac Connor
dbe9817bc8 Split actions.php into individual files per view 2019-01-04 09:26:34 -05:00