Enhance scanning state handling and localization updates across multiple language files

This commit is contained in:
Jokob @NetAlertX
2026-03-03 06:36:31 +00:00
parent 2a4e6ba5e1
commit 0f20fb38f0
16 changed files with 42 additions and 32 deletions

View File

@@ -577,11 +577,15 @@ var _nextScanTimeAnchor = null;
var _currentStateAnchor = null;
var _scanEtaTickerId = null;
var _pluginsData = null;
var _wasImminent = false; // true once the countdown displayed "imminent"; gates the Scanning... label
var _imminentForTime = null; // the _nextScanTimeAnchor value that last set _wasImminent
// prevents re-arming on the same (already-consumed) timestamp
// Returns true when the backend is actively scanning (not idle).
// States that indicate scanning: Process: Start, Check scan, Scan processed.
// Uses an exclusion approach — only "Process: Idle" and an empty/null state are non-scanning.
// This future-proofs against new states added to the scan pipeline (e.g. "Plugin: AVAHISCAN").
function isScanningState(state) {
return ['Process: Start', 'Check scan', 'Scan processed'].indexOf(state) !== -1;
return !!state && state !== 'Process: Idle';
}
// Fetch plugins.json once on page load so we can guard ETA display to device_scanner plugins only.
@@ -603,31 +607,37 @@ function updateScanEtaDisplay(nextScanTime, currentState) {
_nextScanTimeAnchor = nextScanTime || _nextScanTimeAnchor;
_currentStateAnchor = currentState || _currentStateAnchor;
// Reset the imminent gate when the scan finishes back to idle so the next cycle starts clean.
if (currentState === 'Process: Idle') { _wasImminent = false; }
// Restart the per-second title-bar ticker
if (_scanEtaTickerId !== null) { clearInterval(_scanEtaTickerId); }
function getEtaLabel() {
if (!hasEnabledDeviceScanners()) return '';
if (isScanningState(_currentStateAnchor) && _wasImminent) return getString('Device_Scanning');
var label = computeNextScanLabel(_nextScanTimeAnchor);
// Arm _wasImminent only for a NEW next_scan_time anchor — not the already-consumed one.
// This prevents the ticker from re-arming immediately after "Process: Idle" resets the flag
// while _nextScanTimeAnchor still holds the now-past timestamp.
if (label === getString('Device_NextScan_Imminent') && _nextScanTimeAnchor !== _imminentForTime) {
_wasImminent = true;
_imminentForTime = _nextScanTimeAnchor;
}
return label;
}
function tickTitleBar() {
var eta = document.getElementById('nextScanEta');
if (!eta) return;
if (!hasEnabledDeviceScanners()) {
eta.style.display = 'none';
return;
}
// Show 'Scanning...' when the backend is actively scanning, countdown otherwise.
eta.textContent = isScanningState(_currentStateAnchor)
? getString('Device_Scanning')
: computeNextScanLabel(_nextScanTimeAnchor);
var label = getEtaLabel();
if (!label) { eta.style.display = 'none'; return; }
eta.textContent = label;
eta.style.display = '';
}
// Update DataTables empty message once per SSE event — avoids AJAX spam on server-side tables.
// 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);
}
var label = getEtaLabel();
if ($.fn.DataTable.isDataTable('#tableDevices')) {
var dt = $('#tableDevices').DataTable();
dt.settings()[0].oLanguage.sEmptyTable = buildEmptyDeviceTableMessage(label);

View File

@@ -804,4 +804,4 @@
"settings_system_label": "نظام",
"settings_update_item_warning": "قم بتحديث القيمة أدناه. احرص على اتباع التنسيق السابق. <b>لم يتم إجراء التحقق.</b>",
"test_event_tooltip": "احفظ التغييرات أولاً قبل اختبار الإعدادات."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "Sistema",
"settings_update_item_warning": "Actualitza el valor sota. Sigues curós de seguir el format anterior. <b>No hi ha validació.</b>",
"test_event_tooltip": "Deseu els canvis primer abans de comprovar la configuració."
}
}

View File

@@ -877,4 +877,4 @@
"settings_system_label": "System",
"settings_update_item_warning": "",
"test_event_tooltip": "Speichere die Änderungen, bevor Sie die Einstellungen testen."
}
}

View File

@@ -203,7 +203,7 @@
"Device_MultiEdit_MassActions": "Mass actions:",
"Device_MultiEdit_No_Devices": "No devices selected.",
"Device_MultiEdit_Tooltip": "Careful. Clicking this will apply the value on the left to all devices selected above.",
"Device_NextScan_Imminent": "imminent",
"Device_NextScan_Imminent": "Imminent...",
"Device_NextScan_In": "Next scan in ",
"Device_NoData_Help": "If devices don't appear after the scan, check your SCAN_SUBNETS setting and <a href=\"https://docs.netalertx.com/SUBNETS\" target=\"_blank\">documentation</a>.",
"Device_NoData_Scanning": "Waiting for the first scan - this may take several minutes after the initial setup.",

View File

@@ -875,4 +875,4 @@
"settings_system_label": "Sistema",
"settings_update_item_warning": "Actualice el valor a continuación. Tenga cuidado de seguir el formato anterior. <b>O la validación no se realiza.</b>",
"test_event_tooltip": "Guarda tus cambios antes de probar nuevos ajustes."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "Système",
"settings_update_item_warning": "Mettre à jour la valeur ci-dessous. Veillez à bien suivre le même format qu'auparavant. <b>Il n'y a pas de pas de contrôle.</b>",
"test_event_tooltip": "Enregistrer d'abord vos modifications avant de tester vôtre paramétrage."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "システム",
"settings_update_item_warning": "以下の値を更新してください。以前のフォーマットに従うよう注意してください。<b>検証は行われません。</b>",
"test_event_tooltip": "設定をテストする前に、まず変更を保存してください。"
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "System",
"settings_update_item_warning": "Oppdater verdien nedenfor. Pass på å følge forrige format. <b>Validering etterpå utføres ikke.</b>",
"test_event_tooltip": "Lagre endringene først, før du tester innstillingene dine."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "System",
"settings_update_item_warning": "Zaktualizuj wartość poniżej. Uważaj, aby zachować poprzedni format. <b>Walidacja nie jest wykonywana.</b>",
"test_event_tooltip": "Najpierw zapisz swoje zmiany, zanim przetestujesz ustawienia."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "",
"settings_update_item_warning": "",
"test_event_tooltip": "Guarde as alterações antes de testar as definições."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "",
"settings_update_item_warning": "",
"test_event_tooltip": "Guarde as alterações antes de testar as definições."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "Система",
"settings_update_item_warning": "Обновить значение ниже. Будьте осторожны, следуя предыдущему формату. <b>Проверка не выполняется.</b>",
"test_event_tooltip": "Сначала сохраните изменения, прежде чем проверять настройки."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "Sistem",
"settings_update_item_warning": "",
"test_event_tooltip": ""
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "Система",
"settings_update_item_warning": "Оновіть значення нижче. Слідкуйте за попереднім форматом. <b>Перевірка не виконана.</b>",
"test_event_tooltip": "Перш ніж перевіряти налаштування, збережіть зміни."
}
}

View File

@@ -804,4 +804,4 @@
"settings_system_label": "系统",
"settings_update_item_warning": "更新下面的值。请注意遵循先前的格式。<b>未执行验证。</b>",
"test_event_tooltip": "在测试设置之前,请先保存更改。"
}
}