mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-03 22:57:23 -05:00
Enhance scan ETA display with current scanning state and add localization for 'Scanning...' message
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "",
|
||||
"Device_Saved_Success": "",
|
||||
"Device_Saved_Unexpected": "",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "بحث",
|
||||
"Device_Shortcut_AllDevices": "جميع الأجهزة",
|
||||
"Device_Shortcut_AllNodes": "جميع العقد",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "",
|
||||
"Device_Saved_Success": "",
|
||||
"Device_Saved_Unexpected": "",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "",
|
||||
"Device_Shortcut_AllDevices": "",
|
||||
"Device_Shortcut_AllNodes": "",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "",
|
||||
"Device_Saved_Success": "",
|
||||
"Device_Saved_Unexpected": "",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "",
|
||||
"Device_Shortcut_AllDevices": "",
|
||||
"Device_Shortcut_AllNodes": "",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "許可されていない - 無効なAPIトークン",
|
||||
"Device_Saved_Success": "デバイスが正常に保存されました",
|
||||
"Device_Saved_Unexpected": "デバイスの更新で予期せぬ応答がありました",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "検索",
|
||||
"Device_Shortcut_AllDevices": "自分のデバイス",
|
||||
"Device_Shortcut_AllNodes": "全ノード",
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "Не авторизован - недействительный токен API",
|
||||
"Device_Saved_Success": "Устройство успешно сохранено",
|
||||
"Device_Saved_Unexpected": "Обновление устройства дало неожиданный ответ",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "Поиск",
|
||||
"Device_Shortcut_AllDevices": "Мои устройства",
|
||||
"Device_Shortcut_AllNodes": "Все узлы",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "",
|
||||
"Device_Saved_Success": "",
|
||||
"Device_Saved_Unexpected": "",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "",
|
||||
"Device_Shortcut_AllDevices": "",
|
||||
"Device_Shortcut_AllNodes": "",
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "Неавторизовано – недійсний токен API",
|
||||
"Device_Saved_Success": "Пристрій успішно збережено",
|
||||
"Device_Saved_Unexpected": "Оновлення пристрою повернуло неочікувану відповідь",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "Пошук",
|
||||
"Device_Shortcut_AllDevices": "Мої пристрої",
|
||||
"Device_Shortcut_AllNodes": "Усі вузли",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "",
|
||||
"Device_Saved_Success": "",
|
||||
"Device_Saved_Unexpected": "",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "",
|
||||
"Device_Shortcut_AllDevices": "",
|
||||
"Device_Shortcut_AllNodes": "",
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"Device_Save_Unauthorized": "未授权 - API 令牌无效",
|
||||
"Device_Saved_Success": "设备保存成功",
|
||||
"Device_Saved_Unexpected": "设备更新返回了一个意外的响应",
|
||||
"Device_Scanning": "",
|
||||
"Device_Searchbox": "搜索",
|
||||
"Device_Shortcut_AllDevices": "我的设备",
|
||||
"Device_Shortcut_AllNodes": "全部节点",
|
||||
|
||||
Reference in New Issue
Block a user