Skip to content

mactrack: single scrollable scan dialog, i18n interface counters, Show Totals tooltip - #407

Merged
TheWitness merged 2 commits into
developfrom
fix/mactrack-single-dialog
Nov 5, 2026
Merged

TheWitness merged 2 commits into
developfrom
fix/mactrack-single-dialog

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Description

Follow-up to #406 that cleans up the scan-results UX and improves the interfaces
report:

  • One dialog, not two. The rescan/site-scan completion previously popped a
    separate Cacti toast ("Operation successful") on top of the detailed
    "Device Scan Results" dialog. The toast is removed; the completion/timing line
    is now appended to the single detailed dialog (Device '…' rescan completed in N.NN seconds), so there is exactly one dialog.
  • Scrollable results dialog. Long scanner output no longer overflows the
    dialog — results are wrapped in a .mactrackScanResults container (defined in
    the always-loaded css/cards.css) with overflow-y: auto, giving a vertical
    scrollbar.
  • Timeout feedback kept. A request that fails without a response body (e.g.
    the 5-minute timeout) now renders an error line in the same results dialog
    instead of clearing the spinner with no feedback.
  • Readable interface counters. The interfaces Errors, Discards and Unknown
    Protocol columns (both the per-poll view and the Show Totals view) now render
    through number_format_i18n().
  • Show Totals tooltip. The interfaces "Show Totals" checkbox/label gains a
    title tooltip explaining that it switches those columns to each interface's
    cumulative SNMP counter totals instead of the change since the previous poll.

The admin scan endpoints still return UTF-8-safe JSON and remain POST + CSRF +
realm gated; this change only adjusts how the client renders the result.

Related Issue

N/A — direct follow-up to the merged #406: the stacked toast + results dialog
was redundant, and the interface counter columns were hard to read.

Motivation and Context

The toast and the detailed dialog conveyed the same completion event twice and
stacked on top of each other, and the detailed dialog clipped long scanner
output. Collapsing to one scrollable dialog is clearer, and formatting the
interface counters plus explaining "Show Totals" improves the interfaces report.

How Has This Been Tested?

  • Pest suite (Cacti develop checkout, plugin at plugins/mactrack):
    include/vendor/bin/pest --configuration=plugins/mactrack/phpunit.xml →
    267 passed (2066 assertions).
  • Patch coverage: php tests/bin/patch-coverage.php coverage/clover.xml origin/develop 100 → 100.00% (12/12 lines) (added success/failure
    coverage for both scan endpoints and a Show-Totals branch test for the
    interface row).
  • php tests/bin/validate-manifest.php → OK.
  • php tests/bin/check-i18n-pot.php origin/develop → OK (regenerated
    locales/po/cacti.pot only — added the Show Totals tooltip string; .po/.mo
    left to Weblate).
  • php -l on changed PHP and node --check js/mactrack.js → clean.

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation repository accordingly.

…w Totals tooltip

Show scan results in one dialog only: drop the stacked completion toast and append the completion/timing line to the detailed results dialog instead, and give that dialog a vertical scrollbar via a .mactrackScanResults wrapper so long scanner output no longer overflows. Timeouts (no response body) now render in the same dialog rather than clearing the spinner silently.

Format the interface Errors, Discards and Unknown Protocol columns (both the per-poll and Show Totals views) with number_format_i18n(), and add a tooltip to the Show Totals control explaining that it switches those columns to cumulative SNMP counter totals.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The formatting test cannot detect removal of number formatting, and the tooltips incorrectly describe average per-second rates as counter changes.

2 open issues
What changed in this PR

This follow-up to #406 simplifies MacTrack scan feedback and improves readability in the interfaces report.

Changes:

  • Consolidates scan output and completion timing into one scrollable dialog, including feedback for timeouts without a response body.
  • Applies locale-aware formatting to interface counters and adds a Show Totals tooltip.
  • Updates scan-response tests, totals-view coverage, translations, and the changelog.
File Description
tests/​Unit/​MactrackStatusPillsTest.php Adds totals-view rendering coverage and resets request state.
tests/​Unit/​AdminActionsRequirePostTest.php Covers successful and failed scan responses without toast messages.
tests/​bootstrap-unit.php Supports configurable request values in unit tests.
mactrack_view_interfaces.php Adds tooltips to the Show Totals control.
locales/​po/​cacti.pot Adds the tooltip translation entry.
lib/​mactrack_functions.php Formats counters and appends completion timing to scan output.
js/​mactrack.js Removes scan toasts and routes empty-response failures to the results dialog.
css/​cards.css Adds a scrollable scan-results container.
CHANGELOG.md Records the scan-dialog and interface-report updates.

Review effort: Balanced

Comment thread mactrack_view_interfaces.php Resolved
Comment thread tests/Unit/MactrackStatusPillsTest.php Resolved
xmacan
xmacan previously approved these changes Nov 5, 2026
…-dup)

Reword the Show Totals tooltip to say the unchecked columns are an average per-second rate (get_link_int_value divides the delta by elapsed seconds), not a raw counter change, and regenerate the POT.

Make the interface totals test meaningful: record number_format_i18n() calls in the shared stub and assert the five total counters are routed through it at integer precision, so dropping the formatter now fails the test.

Cut SonarCloud new-code duplication: fold the per-endpoint scan tests into one data-driven test and share an interface-row fixture helper between the interface-row tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 6fea21e into develop Nov 5, 2026
7 checks passed
@TheWitness
TheWitness deleted the fix/mactrack-single-dialog branch November 5, 2026 20:07

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: scan-dialog output is escaped, no SQLi/XSS in the changed paths, i18n counters correct, $elapsed defined on all paths. Only nit: css/cards.css is missing a trailing newline.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants