round63: Geraeteuebergreifende Sichtbarkeit fuer manuelle Einzelgeraete-Scans, automatische Logs-Aktualisierung danach

This commit is contained in:
2026-07-26 16:34:49 +02:00
parent 9abfdba707
commit c05562c4cd
4 changed files with 45 additions and 2 deletions

View File

@@ -22,18 +22,29 @@ export function useScanActivity(): ScanActivity {
async function poll() {
try {
const [devicesRes, apisRes, fritzboxRes] = await Promise.all([
const [devicesRes, apisRes, fritzboxRes, activeDevicesRes] = await Promise.all([
fetch("/api/scan/devices/all/status"),
fetch("/api/scan/apis/status"),
fetch("/api/scan/fritzbox/status"),
fetch("/api/scan/devices/active"),
]);
if (cancelled) return;
const devicesStatus = devicesRes.ok ? await devicesRes.json() : null;
const apisStatus = apisRes.ok ? await apisRes.json() : null;
const fritzboxStatus = fritzboxRes.ok ? await fritzboxRes.json() : null;
// Manuelle Einzelgeräte-Scans (Button auf der Geräteseite) laufen
// NICHT über den Sammel-Scan-Job, sondern über eine einfache,
// blockierende Anfrage - ohne diesen zusätzlichen Abruf wäre so ein
// Scan für jeden anderen Browser/jedes andere Gerät unsichtbar
// gewesen (siehe Bugreport).
const activeDevices = activeDevicesRes.ok ? await activeDevicesRes.json() : null;
const running = !!devicesStatus?.running || !!apisStatus?.running || !!fritzboxStatus?.running;
const running =
!!devicesStatus?.running ||
!!apisStatus?.running ||
!!fritzboxStatus?.running ||
(activeDevices?.deviceIds?.length ?? 0) > 0;
const lastResult = devicesStatus?.lastResult;
const pendingCount = lastResult

View File

@@ -343,9 +343,16 @@ function DeviceRow({ device }: { device: DeviceWithServices }) {
setDeviceNameSuggestion(result.deviceNameSuggestion);
queryClient.invalidateQueries({ queryKey: ["devices"] });
queryClient.invalidateQueries({ queryKey: ["services"] });
// War bisher vergessen: der Scan selbst schreibt zwar schon einen
// Log-Eintrag (siehe performDeviceScan in routes/scan.ts, gilt für
// Einzelgerät- UND Sammel-Scan gleichermaßen), aber ohne diese
// Invalidierung blieb eine bereits geöffnete Admin -> Logs-Seite auf
// dem alten Stand, bis man sie manuell neu lädt (siehe Bugreport).
queryClient.invalidateQueries({ queryKey: ["logs"] });
},
onError: (err: Error) => {
setScanMessage(err.name === "AbortError" ? "Scan abgebrochen." : err.message);
queryClient.invalidateQueries({ queryKey: ["logs"] });
},
onSettled: () => setScanAbort(null),
});