mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-03 04:24:36 +00:00
fix(web): refresh system status card when clicking Refresh Data button
Pass a refreshKey prop through OverviewCards to SystemStatusCard that increments on each Refresh Data click, triggering a re-fetch of Plugin and Box runtime status alongside the monitoring data refresh.
This commit is contained in:
@@ -15,6 +15,7 @@ interface OverviewCardsProps {
|
||||
messages?: MonitoringMessage[];
|
||||
llmCalls?: LLMCall[];
|
||||
loading?: boolean;
|
||||
refreshKey?: number;
|
||||
}
|
||||
|
||||
export default function OverviewCards({
|
||||
@@ -22,6 +23,7 @@ export default function OverviewCards({
|
||||
messages = [],
|
||||
llmCalls = [],
|
||||
loading,
|
||||
refreshKey,
|
||||
}: OverviewCardsProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -94,7 +96,7 @@ export default function OverviewCards({
|
||||
loading={loading}
|
||||
/>
|
||||
))}
|
||||
<SystemStatusCard />
|
||||
<SystemStatusCard refreshKey={refreshKey} />
|
||||
</div>
|
||||
|
||||
{/* Traffic Chart */}
|
||||
|
||||
@@ -30,7 +30,13 @@ function StatusDot({ ok }: { ok: boolean | null }) {
|
||||
);
|
||||
}
|
||||
|
||||
export default function SystemStatusCard() {
|
||||
interface SystemStatusCardProps {
|
||||
refreshKey?: number;
|
||||
}
|
||||
|
||||
export default function SystemStatusCard({
|
||||
refreshKey,
|
||||
}: SystemStatusCardProps) {
|
||||
const { t } = useTranslation();
|
||||
const [pluginStatus, setPluginStatus] =
|
||||
useState<ApiRespPluginSystemStatus | null>(null);
|
||||
@@ -52,10 +58,12 @@ export default function SystemStatusCard() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
fetchStatus(true);
|
||||
// refreshKey changes when the user clicks "Refresh Data"
|
||||
fetchStatus(refreshKey === undefined);
|
||||
const interval = setInterval(() => fetchStatus(false), 30_000);
|
||||
return () => clearInterval(interval);
|
||||
}, [fetchStatus]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [fetchStatus, refreshKey]);
|
||||
|
||||
const pluginOk = pluginStatus
|
||||
? pluginStatus.is_enable && pluginStatus.is_connected
|
||||
|
||||
Reference in New Issue
Block a user