From f8c09d35a7bdec44ca7387780618cb509fb12ba6 Mon Sep 17 00:00:00 2001 From: "Jokob @NetAlertX" <96159884+jokob-sk@users.noreply.github.com> Date: Thu, 5 Mar 2026 20:24:57 +0000 Subject: [PATCH] Enhance scan ETA display logic to reload data for newly discovered devices after scanning finishes --- front/devices.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/front/devices.php b/front/devices.php index cc730aa7..fdb8f458 100755 --- a/front/devices.php +++ b/front/devices.php @@ -624,6 +624,10 @@ function hasEnabledDeviceScanners() { // Update the title-bar ETA subtitle and the DataTables empty-state message. // Called on every nax:scanEtaUpdate; the inner ticker keeps the title bar live between events. function updateScanEtaDisplay(nextScanTime, currentState) { + // Detect scan-finished transition BEFORE updating _currentStateAnchor. + // justFinishedScanning is true only when the backend transitions scanning → idle. + var justFinishedScanning = (currentState === 'Process: Idle') && isScanningState(_currentStateAnchor); + // Prefer the backend-computed values; keep previous anchors if not yet received. _nextScanTimeAnchor = nextScanTime || _nextScanTimeAnchor; _currentStateAnchor = currentState || _currentStateAnchor; @@ -670,6 +674,13 @@ function updateScanEtaDisplay(nextScanTime, currentState) { // Patch the visible cell text without triggering a server-side AJAX reload. $('#tableDevices tbody .dataTables_empty').html(newEmptyMsg); } + + // When scanning just finished and the table is still empty, reload data so + // newly discovered devices appear automatically. Skip reload if there are + // already rows — no need to disturb the user's current view. + if (justFinishedScanning && dt.page.info().recordsTotal === 0) { + dt.ajax.reload(null, false); // false = keep current page position + } } tickTitleBar();