diff --git a/front/devices.php b/front/devices.php index 6be7a08d..0c6bab74 100755 --- a/front/devices.php +++ b/front/devices.php @@ -572,10 +572,17 @@ function computeNextScanLabel(nextScanTime) { return getString('Device_NextScan_In') + secsLeft + 's'; } -// Anchor for next scheduled scan time, ticker handle, and plugins data — module-level. +// Anchor for next scheduled scan time, ticker handle, plugins data, and current state — module-level. var _nextScanTimeAnchor = null; +var _currentStateAnchor = null; var _scanEtaTickerId = null; -var _pluginsData = null; +var _pluginsData = null; + +// Returns true when the backend is actively scanning (not idle). +// States that indicate scanning: Process: Start, Check scan, Scan processed. +function isScanningState(state) { + return ['Process: Start', 'Check scan', 'Scan processed'].indexOf(state) !== -1; +} // Fetch plugins.json once on page load so we can guard ETA display to device_scanner plugins only. $.get('php/server/query_json.php', { file: 'plugins.json', nocache: Date.now() }, function(res) { @@ -591,9 +598,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) { - // Prefer the backend-computed next_scan_time; keep previous anchor if not yet received. +function updateScanEtaDisplay(nextScanTime, currentState) { + // Prefer the backend-computed values; keep previous anchors if not yet received. _nextScanTimeAnchor = nextScanTime || _nextScanTimeAnchor; + _currentStateAnchor = currentState || _currentStateAnchor; // Restart the per-second title-bar ticker if (_scanEtaTickerId !== null) { clearInterval(_scanEtaTickerId); } @@ -605,13 +613,21 @@ function updateScanEtaDisplay(nextScanTime) { eta.style.display = 'none'; return; } - eta.textContent = computeNextScanLabel(_nextScanTimeAnchor); + // Show 'Scanning...' when the backend is actively scanning, countdown otherwise. + eta.textContent = isScanningState(_currentStateAnchor) + ? getString('Device_Scanning') + : computeNextScanLabel(_nextScanTimeAnchor); eta.style.display = ''; } // Update DataTables empty message once per SSE event — avoids AJAX spam on server-side tables. - // Only show the next-scan ETA line when device_scanner plugins are actually enabled. - var label = hasEnabledDeviceScanners() ? computeNextScanLabel(_nextScanTimeAnchor) : ''; + // Show 'Scanning...' when active, countdown when idle, nothing when no device_scanner enabled. + var label = ''; + if (hasEnabledDeviceScanners()) { + label = isScanningState(_currentStateAnchor) + ? getString('Device_Scanning') + : computeNextScanLabel(_nextScanTimeAnchor); + } if ($.fn.DataTable.isDataTable('#tableDevices')) { var dt = $('#tableDevices').DataTable(); dt.settings()[0].oLanguage.sEmptyTable = buildEmptyDeviceTableMessage(label); @@ -624,7 +640,7 @@ function updateScanEtaDisplay(nextScanTime) { // Listen for scan ETA updates dispatched by sse_manager.js (SSE push or poll fallback) document.addEventListener('nax:scanEtaUpdate', function(e) { - updateScanEtaDisplay(e.detail.nextScanTime); + updateScanEtaDisplay(e.detail.nextScanTime, e.detail.currentState); }); // --------------------------------------------------------- diff --git a/front/js/sse_manager.js b/front/js/sse_manager.js index a61f9930..ae9c6903 100644 --- a/front/js/sse_manager.js +++ b/front/js/sse_manager.js @@ -180,7 +180,8 @@ class NetAlertXStateManager { document.dispatchEvent(new CustomEvent('nax:scanEtaUpdate', { detail: { lastScanRun: appState["last_scan_run"], - nextScanTime: appState["next_scan_time"] + nextScanTime: appState["next_scan_time"], + currentState: appState["currentState"] } })); } diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json index 3f9f80fe..98ec45a4 100644 --- a/front/php/templates/language/ar_ar.json +++ b/front/php/templates/language/ar_ar.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "بحث", "Device_Shortcut_AllDevices": "جميع الأجهزة", "Device_Shortcut_AllNodes": "جميع العقد", diff --git a/front/php/templates/language/ca_ca.json b/front/php/templates/language/ca_ca.json index 8c6dec13..67b4292b 100644 --- a/front/php/templates/language/ca_ca.json +++ b/front/php/templates/language/ca_ca.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "Token invàlid - No autoritzat", "Device_Saved_Success": "S'ha guardat el dispositiu", "Device_Saved_Unexpected": "Actualització de dispositiu ha retornat una resposta no esperada", + "Device_Scanning": "", "Device_Searchbox": "Cerca", "Device_Shortcut_AllDevices": "Els meus dispositius", "Device_Shortcut_AllNodes": "Tots els nodes", diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json index a04566d0..d03f5774 100644 --- a/front/php/templates/language/cs_cz.json +++ b/front/php/templates/language/cs_cz.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "", "Device_Shortcut_AllDevices": "", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index ae01a670..77d4ca40 100644 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -216,6 +216,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "Gerät erfolgreich gespeichert", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "Suche", "Device_Shortcut_AllDevices": "Meine Geräte", "Device_Shortcut_AllNodes": "Alle Knoten", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index b1222f34..c83f074b 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "Unauthorized - invalid API token", "Device_Saved_Success": "Device saved successfully", "Device_Saved_Unexpected": "Device update returned an unexpected response", + "Device_Scanning": "Scanning...", "Device_Searchbox": "Search", "Device_Shortcut_AllDevices": "My devices", "Device_Shortcut_AllNodes": "All Nodes", diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index 464165ef..577e1fda 100644 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -214,6 +214,7 @@ "Device_Save_Unauthorized": "No autorizado - Token de API inválido", "Device_Saved_Success": "Dispositivo guardado exitósamente", "Device_Saved_Unexpected": "La actualización del dispositivo retornó una respuesta inesperada", + "Device_Scanning": "", "Device_Searchbox": "Búsqueda", "Device_Shortcut_AllDevices": "Mis dispositivos", "Device_Shortcut_AllNodes": "Todos los nodos", diff --git a/front/php/templates/language/fa_fa.json b/front/php/templates/language/fa_fa.json index 56394aea..8cac2dd3 100644 --- a/front/php/templates/language/fa_fa.json +++ b/front/php/templates/language/fa_fa.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "", "Device_Shortcut_AllDevices": "", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json index 1a404705..4fa8ee6e 100644 --- a/front/php/templates/language/fr_fr.json +++ b/front/php/templates/language/fr_fr.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "Non autorisé - Jeton d'API invalide", "Device_Saved_Success": "Appareil enregistré avec succès", "Device_Saved_Unexpected": "La mise à jour de l'appareil a renvoyé une réponse inattendue", + "Device_Scanning": "", "Device_Searchbox": "Rechercher", "Device_Shortcut_AllDevices": "Mes appareils", "Device_Shortcut_AllNodes": "Tous les nœuds", diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json index a0464200..d761d476 100644 --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "Non autorizzato: token API non valido", "Device_Saved_Success": "Dispositivo salvato correttamente", "Device_Saved_Unexpected": "L'aggiornamento del dispositivo ha restituito una risposta imprevista", + "Device_Scanning": "", "Device_Searchbox": "Cerca", "Device_Shortcut_AllDevices": "I miei dispositivi", "Device_Shortcut_AllNodes": "Tutti i nodi", diff --git a/front/php/templates/language/ja_jp.json b/front/php/templates/language/ja_jp.json index 07428b05..a1fe40ac 100644 --- a/front/php/templates/language/ja_jp.json +++ b/front/php/templates/language/ja_jp.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "許可されていない - 無効なAPIトークン", "Device_Saved_Success": "デバイスが正常に保存されました", "Device_Saved_Unexpected": "デバイスの更新で予期せぬ応答がありました", + "Device_Scanning": "", "Device_Searchbox": "検索", "Device_Shortcut_AllDevices": "自分のデバイス", "Device_Shortcut_AllNodes": "全ノード", diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json index 605489b3..3fc67966 100644 --- a/front/php/templates/language/nb_no.json +++ b/front/php/templates/language/nb_no.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "Søk", "Device_Shortcut_AllDevices": "Mine Enheter", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json index 48eef282..1e46dc20 100644 --- a/front/php/templates/language/pl_pl.json +++ b/front/php/templates/language/pl_pl.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "Szukaj", "Device_Shortcut_AllDevices": "Moje urządzenia", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json index 6de1d4ef..2005b90e 100644 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "Procurar", "Device_Shortcut_AllDevices": "Meus dispositivos", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/pt_pt.json b/front/php/templates/language/pt_pt.json index b72ee269..b60aa27d 100644 --- a/front/php/templates/language/pt_pt.json +++ b/front/php/templates/language/pt_pt.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "Procurar", "Device_Shortcut_AllDevices": "Os meus dispositivos", "Device_Shortcut_AllNodes": "Todos os Nodes", diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json index e19861cb..6a8cb0df 100644 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "Не авторизован - недействительный токен API", "Device_Saved_Success": "Устройство успешно сохранено", "Device_Saved_Unexpected": "Обновление устройства дало неожиданный ответ", + "Device_Scanning": "", "Device_Searchbox": "Поиск", "Device_Shortcut_AllDevices": "Мои устройства", "Device_Shortcut_AllNodes": "Все узлы", diff --git a/front/php/templates/language/sv_sv.json b/front/php/templates/language/sv_sv.json index 0f1292fd..c114cb5c 100644 --- a/front/php/templates/language/sv_sv.json +++ b/front/php/templates/language/sv_sv.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "", "Device_Shortcut_AllDevices": "", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json index 041891fe..e9e3d63c 100644 --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "Arama", "Device_Shortcut_AllDevices": "Cihazlarım", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/uk_ua.json b/front/php/templates/language/uk_ua.json index 40bdea05..3fe7e7ca 100644 --- a/front/php/templates/language/uk_ua.json +++ b/front/php/templates/language/uk_ua.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "Неавторизовано – недійсний токен API", "Device_Saved_Success": "Пристрій успішно збережено", "Device_Saved_Unexpected": "Оновлення пристрою повернуло неочікувану відповідь", + "Device_Scanning": "", "Device_Searchbox": "Пошук", "Device_Shortcut_AllDevices": "Мої пристрої", "Device_Shortcut_AllNodes": "Усі вузли", diff --git a/front/php/templates/language/vi_vn.json b/front/php/templates/language/vi_vn.json index 0f1292fd..c114cb5c 100644 --- a/front/php/templates/language/vi_vn.json +++ b/front/php/templates/language/vi_vn.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "", "Device_Saved_Success": "", "Device_Saved_Unexpected": "", + "Device_Scanning": "", "Device_Searchbox": "", "Device_Shortcut_AllDevices": "", "Device_Shortcut_AllNodes": "", diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json index 36fab9b8..36453e06 100644 --- a/front/php/templates/language/zh_cn.json +++ b/front/php/templates/language/zh_cn.json @@ -212,6 +212,7 @@ "Device_Save_Unauthorized": "未授权 - API 令牌无效", "Device_Saved_Success": "设备保存成功", "Device_Saved_Unexpected": "设备更新返回了一个意外的响应", + "Device_Scanning": "", "Device_Searchbox": "搜索", "Device_Shortcut_AllDevices": "我的设备", "Device_Shortcut_AllNodes": "全部节点",