mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 01:52:20 +00:00
Update health-status-modal.tsx
This commit is contained in:
@@ -130,6 +130,9 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(getApiUrl("/api/health/full"), { headers: authHeaders })
|
const response = await fetch(getApiUrl("/api/health/full"), { headers: authHeaders })
|
||||||
|
let infoCount = 0
|
||||||
|
let dismissedCount = 0
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
// Fallback to legacy endpoint
|
// Fallback to legacy endpoint
|
||||||
const legacyResponse = await fetch(getApiUrl("/api/health/details"), { headers: authHeaders })
|
const legacyResponse = await fetch(getApiUrl("/api/health/details"), { headers: authHeaders })
|
||||||
@@ -139,18 +142,24 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
|
|||||||
setDismissedItems([])
|
setDismissedItems([])
|
||||||
setCustomSuppressions([])
|
setCustomSuppressions([])
|
||||||
newOverallStatus = data?.overall || "OK"
|
newOverallStatus = data?.overall || "OK"
|
||||||
|
|
||||||
|
// Count INFO categories from legacy data
|
||||||
|
if (data?.details) {
|
||||||
|
CATEGORIES.forEach(({ key }) => {
|
||||||
|
const cat = data.details[key as keyof typeof data.details]
|
||||||
|
if (cat && cat.status?.toUpperCase() === "INFO") {
|
||||||
|
infoCount++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const fullData: FullHealthData = await response.json()
|
const fullData: FullHealthData = await response.json()
|
||||||
setHealthData(fullData.health)
|
setHealthData(fullData.health)
|
||||||
setDismissedItems(fullData.dismissed || [])
|
setDismissedItems(fullData.dismissed || [])
|
||||||
setCustomSuppressions(fullData.custom_suppressions || [])
|
setCustomSuppressions(fullData.custom_suppressions || [])
|
||||||
newOverallStatus = fullData.health?.overall || "OK"
|
newOverallStatus = fullData.health?.overall || "OK"
|
||||||
}
|
dismissedCount = (fullData.dismissed || []).length
|
||||||
|
|
||||||
// Calculate infoCount: categories with INFO status + dismissed items
|
|
||||||
let infoCount = 0
|
|
||||||
if (response.ok) {
|
|
||||||
const fullData: FullHealthData = await response.clone().json()
|
|
||||||
// Count INFO categories
|
// Count INFO categories
|
||||||
if (fullData.health?.details) {
|
if (fullData.health?.details) {
|
||||||
CATEGORIES.forEach(({ key }) => {
|
CATEGORIES.forEach(({ key }) => {
|
||||||
@@ -160,13 +169,14 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Add dismissed items count
|
|
||||||
infoCount += (fullData.dismissed || []).length
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Total info = INFO categories + dismissed items
|
||||||
|
const totalInfoCount = infoCount + dismissedCount
|
||||||
|
|
||||||
// Emit event with the FRESH data from the response, not the stale state
|
// Emit event with the FRESH data from the response, not the stale state
|
||||||
const event = new CustomEvent("healthStatusUpdated", {
|
const event = new CustomEvent("healthStatusUpdated", {
|
||||||
detail: { status: newOverallStatus, infoCount },
|
detail: { status: newOverallStatus, infoCount: totalInfoCount },
|
||||||
})
|
})
|
||||||
window.dispatchEvent(event)
|
window.dispatchEvent(event)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user