Global refresh rate in Settings drives every live view and each machine's sampler; per-page pickers removed
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
a4f39859b6
commit
bbf0f2580f
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { api, LogEntry, ServiceDetail, ServiceUnit, wsURLPath } from './api'
|
||||
import { Btn, Loading, Spinner, toast } from './ui'
|
||||
import { LIST_FLOOR, useRefreshMs } from './prefs'
|
||||
|
||||
type Filter = 'all' | 'running' | 'failed' | 'enabled'
|
||||
|
||||
@@ -110,8 +111,9 @@ function Detail({ name, onChanged, onBack }: { name: string; onChanged: () => vo
|
||||
const load = useCallback(async () => {
|
||||
try { setD(await api.service(name)); setErr('') } catch (e) { setErr(e instanceof Error ? e.message : 'failed') }
|
||||
}, [name])
|
||||
const rate = useRefreshMs(LIST_FLOOR)
|
||||
useEffect(() => { setD(null); setFile(''); setTab('logs'); load() }, [load])
|
||||
useEffect(() => { const t = setInterval(load, 5000); return () => clearInterval(t) }, [load])
|
||||
useEffect(() => { const t = setInterval(load, rate); return () => clearInterval(t) }, [load, rate])
|
||||
useEffect(() => { if (tab === 'file' && !file) api.serviceFile(name).then((r) => setFile(r.content)).catch((e) => setFile(String(e))) }, [tab, file, name])
|
||||
|
||||
async function act(action: string) {
|
||||
@@ -181,8 +183,9 @@ export default function Services() {
|
||||
try { setUnits(await api.services()); setErr('') } catch (e) { setErr(e instanceof Error ? e.message : 'failed') }
|
||||
finally { setLoaded(true) }
|
||||
}, [])
|
||||
const rate = useRefreshMs(LIST_FLOOR)
|
||||
useEffect(() => { load() }, [load])
|
||||
useEffect(() => { const t = setInterval(() => { if (document.visibilityState === 'visible') load() }, 10000); return () => clearInterval(t) }, [load])
|
||||
useEffect(() => { const t = setInterval(() => { if (document.visibilityState === 'visible') load() }, rate); return () => clearInterval(t) }, [load, rate])
|
||||
|
||||
const needle = q.trim().toLowerCase()
|
||||
const shown = units.filter((u) => {
|
||||
|
||||
Reference in New Issue
Block a user