update 1.2.4

This commit is contained in:
MacRimi
2026-07-21 19:25:08 +02:00
parent c53289753d
commit 827ccbab57
4 changed files with 22 additions and 11 deletions

View File

@@ -126,13 +126,13 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
const [expandedCategories, setExpandedCategories] = useState<Set<string>>(new Set())
const [showUpdateTerminal, setShowUpdateTerminal] = useState(false)
const fetchHealthDetails = useCallback(async () => {
const fetchHealthDetails = useCallback(async (force = false) => {
setLoading(true)
setError(null)
try {
let newOverallStatus = "OK"
// Use the new combined endpoint for fewer round-trips
const token = getAuthToken()
const authHeaders: Record<string, string> = {}
@@ -140,7 +140,7 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
authHeaders["Authorization"] = `Bearer ${token}`
}
const response = await fetch(getApiUrl("/api/health/full"), { headers: authHeaders })
const response = await fetch(getApiUrl(force ? "/api/health/full?refresh=1" : "/api/health/full"), { headers: authHeaders })
let infoCount = 0
if (!response.ok) {
@@ -222,7 +222,7 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
if (open) {
fetchHealthDetails()
// Auto-refresh every 5 minutes while modal is open
const refreshInterval = setInterval(fetchHealthDetails, 300000)
const refreshInterval = setInterval(() => fetchHealthDetails(), 300000)
return () => clearInterval(refreshInterval)
}
}, [open, fetchHealthDetails])
@@ -872,10 +872,10 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
open={showUpdateTerminal}
onClose={() => {
setShowUpdateTerminal(false)
// Refresh health checks so the "System Updates" row updates
// (pending count / kernel version) without waiting for the
// next polling tick after the update finishes.
fetchHealthDetails().catch(() => {})
// Force a fresh read (cache-busting via ?refresh=1) so the
// "System Updates" row reflects the state right after the
// update finished, instead of the pre-update cached value.
fetchHealthDetails(true).catch(() => {})
}}
scriptPath="/usr/local/share/proxmenux/scripts/utilities/proxmox_update.sh"
scriptName="proxmox_update"

View File

@@ -230,14 +230,25 @@ def get_full_health():
Get complete health data in a single request: detailed status + active errors + dismissed.
Uses background-cached results if fresh (< 6 min) for instant response,
otherwise runs a fresh check.
?refresh=1 busts the background + per-check caches for updates/services/
security before returning, so an event that just changed underlying state
(Update Now finished, dismiss action) sees the new value immediately
instead of waiting for the next polling tick.
"""
import time as _time
try:
if request.args.get('refresh') == '1':
for ck in ('updates_check', 'pve_services', 'security_check',
'_bg_detailed', '_bg_overall', 'overall_health'):
health_monitor.last_check_times.pop(ck, None)
health_monitor.cached_results.pop(ck, None)
# Try to use the background-cached detailed result for instant response
bg_key = '_bg_detailed'
bg_last = health_monitor.last_check_times.get(bg_key, 0)
bg_age = _time.time() - bg_last
if bg_age < 360 and bg_key in health_monitor.cached_results:
# Use cached result (at most ~5 min old)
details = health_monitor.cached_results[bg_key]