mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 20:55:16 +09:00
fix(ui): show the metrics error state when a poll fails
This commit is contained in:
1 parent
aa8ed23ec9
commit
65241c356b
1 file changed
+13
-4
@@ -2,7 +2,9 @@ import { useCallback, useState, useEffect, useRef } from 'react';
|
||||
import api from '../../services/api';
|
||||
import { Gauge } from '@/components/ds';
|
||||
import EmptyState from '../EmptyState';
|
||||
import ErrorState from '../ErrorState';
|
||||
import { AlertTriangle } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { errorReason } from '@/utils/errorMessage';
|
||||
import { usePolling } from '@/hooks/usePolling';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { normalizeContainerStats, resolveAppContainerId } from '@/utils/containerMetrics';
|
||||
@@ -65,9 +67,16 @@ const MetricsTabContent = ({ app }) => {
|
||||
return <EmptyState loading loadingVariant="cards" loadingRows={4} title={t('app.metricsTab.loadingMetrics', 'Loading metrics…')} />;
|
||||
}
|
||||
|
||||
// A failed poll keeps the last good numbers; only a failure with nothing to show becomes an error.
|
||||
if (loadError && !stats && !processInfo) {
|
||||
return <ErrorState title={t('app.metricsTab.failedToLoadMetrics', "Couldn't load metrics.")} error={loadError} onRetry={() => { setLoading(true); loadMetrics(); }} />;
|
||||
// A failed poll replaces the numbers: stale CPU/memory would read as live.
|
||||
if (loadError) {
|
||||
return (
|
||||
<EmptyState
|
||||
icon={AlertTriangle}
|
||||
title={t('app.metricsTab.failedToLoadMetrics', "Couldn't load metrics.")}
|
||||
description={errorReason(loadError)}
|
||||
action={<Button variant="outline" size="sm" onClick={() => { setLoading(true); loadMetrics(); }}>{t('common.actions.retry', 'Retry')}</Button>}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (isDocker && stats) {
|
||||
|
||||
Reference in new issue
Block a user