Repository navigation
mactrack: restore device-level rescan, fix endless interface rescan spinner, reorder tabs - #406
Merged
Merged
Conversation
…pinner, reorder tabs Restore the Rescan action to the Device report view (mactrack_view_devices.php), which had been decontented: the row actions now render the rescan glyph (class mactrackRescanDevice, id r_<device_id>, data-device-id) for enabled devices and the view gains the shared #response results dialog. The glyph reuses the existing delegated, CSP-safe click handler. Stop the interface/device rescan icon from spinning forever: the three scan JS functions now run through a shared mactrackRunScan() helper that POSTs with the CSRF token, bounds the request with a timeout, and always clears the spinner on done/fail/timeout. The backend mactrack_rescan()/mactrack_site_scan() now always return UTF-8-safe JSON (JSON_INVALID_UTF8_SUBSTITUTE). On completion each scan returns a short "<device|site> ... completed in N.NN seconds" message that the AJAX caller surfaces as an auto-fading Cacti toast via the 1.2.x session-message mechanism (sessionMessage + displayMessages(), what raise_message_javascript() emits), while the detailed scan output stays in the results dialog. Reorder the MacTrack tabs to Dashboard, Sites, Devices, Interfaces, IP Ranges, IP Addresses, MAC Addresses, Dot1x, Graphs and pluralize the IP/MAC Address tab labels to match the rest of the UI. Update AdminActionsRequirePostTest JS assertions for the new helper structure and regenerate locales/po/cacti.pot. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drive mactrack_rescan() and mactrack_site_scan() through the full scan block with a no-op subprocess (/bin/false) so the new timing/message/content lines are exercised, satisfying the 100%% patch-coverage gate. Add cacti_escapeshellarg()/cacti_escapeshellcmd() stubs the path needs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirror Cactis variadic __() in the test stub (func_get_args) so static analysis no longer reads the parameterized __() calls as passing too many arguments (php:S930), and assign the shared toast message through window.sessionMessage so the global is explicit (javascript:S2703). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xmacan
previously approved these changes
Nov 5, 2026
Do not toast a failed scan as a success: a nonzero subprocess exit returns HTTP 200 with an error flag, so suppress the completion toast when data.error is set (the error detail is already shown in the results dialog). Report request timeouts explicitly: getPresentHTTPError() renders nothing when the failure has no response body, so show an error-level toast instead of silently clearing the spinner. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
xmacan
approved these changes
Nov 5, 2026
2 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Description
Three MacTrack fixes around the device/site Rescan action, plus a tab reorder:
Restore the device-level Rescan glyph. The Device report view
(
mactrack_view_devices.php) builds its rows inline and the rescan glyph hadbeen decontented from that path (the shared
mactrack_format_device_row()still had it). The row actions now render the rescan glyph for enabled devices
(
class='mactrackRescanDevice',id='r_<device_id>',data-device-id), andthe view gains the shared
#responseresults dialog. It reuses the existingdelegated, CSP-safe click handler.
Fix the endless interface/device rescan spinner. The three scan JS
functions now run through one
mactrackRunScan()helper that POSTs with theCSRF token, bounds the request with a timeout, and always clears the
spinner on done/fail/timeout, so a stalled subprocess can no longer leave the
icon spinning forever. The backend
mactrack_rescan()/mactrack_site_scan()now always emit UTF-8-safe JSON (
JSON_INVALID_UTF8_SUBSTITUTE), which alsoprevents an empty response when a device reports non-UTF-8 SNMP output.
Report completion with a toast. Each scan returns a short
"<device|site> ... completed in N.NN seconds"message that the AJAX callersurfaces as an auto-fading Cacti toast via the 1.2.x session-message mechanism
(
sessionMessage+displayMessages(), whatraise_message_javascript()emits), while the detailed scan output stays in the results dialog.
Reorder the tabs to Dashboard, Sites, Devices, Interfaces, IP Ranges,
IP Addresses, MAC Addresses, Dot1x, Graphs, and pluralize the IP/MAC Address
tab labels to match the rest of the UI.
Permissions are unchanged and validated on both layers: the glyph is gated by
api_user_realm_auth('mactrack_sites.php')(Mactrack Administrator realm) andhidden for disabled devices, and
mactrack_ajax_admin.phpis registered to thesame realm so
include/auth.phpenforces it server-side. All four admin actionsremain POST-only via
mactrack_require_post().Related Issue
N/A — reported directly: the device-level Rescan action was missing from the
Device report view and the interface-level rescan spun indefinitely without
reporting a result.
Motivation and Context
Prior releases exposed a Rescan action at the device and site level that forces
an immediate rescan (ports and interface updates) and reported the scan result
and timing. The device-level action had gone missing from the Device report
view, and the interface-level rescan spun forever and never surfaced a result.
This restores the action, makes the request self-limiting, and brings back the
completion/timing feedback using Cacti's native toast.
How Has This Been Tested?
plugins/mactrack):include/vendor/bin/pest --configuration=plugins/mactrack/phpunit.xml→262 passed (2045 assertions).
php tests/bin/validate-manifest.php→ OK.php tests/bin/check-i18n-pot.php origin/develop→ OK (regeneratedlocales/po/cacti.potonly;.po/.moleft to Weblate).php -lon changed PHP andnode --check js/mactrack.js→ clean.AdminActionsRequirePostTestupdated to assert the new helper structure(POST + CSRF token + timeout + always-clears-spinner + failure reporting).
Screenshots (if appropriate):
N/A
Types of changes
Checklist: