/** * System Monitoring Page */ import React, { useState } from 'react'; import { ReadinessCard } from './components/ReadinessCard'; import { CacheStatsCard, DatabaseStatsGrid, ProxyStatsCard, QueueStatsTable, ServiceStatusGrid, SystemHealthCard, } from './components'; import { useCacheStats, useDatabaseStats, useProxyStats, useQueueStats, useServiceStatus, useSystemHealth, useSystemOverview, } from './hooks'; export function MonitoringPage() { const [refreshInterval, setRefreshInterval] = useState(5000); // 5 seconds default const [useOverview, setUseOverview] = useState(false); // Toggle between individual calls and overview // Individual API calls const { data: health, loading: healthLoading, error: healthError, } = useSystemHealth(useOverview ? 0 : refreshInterval); const { data: cache, loading: cacheLoading, error: cacheError, } = useCacheStats(useOverview ? 0 : refreshInterval); const { data: queues, loading: queuesLoading, error: queuesError, } = useQueueStats(useOverview ? 0 : refreshInterval); const { data: databases, loading: dbLoading, error: dbError, } = useDatabaseStats(useOverview ? 0 : refreshInterval); const { data: services, loading: servicesLoading, error: servicesError, } = useServiceStatus(useOverview ? 0 : refreshInterval); const { data: proxies, loading: proxiesLoading, error: proxiesError, } = useProxyStats(useOverview ? 0 : refreshInterval); // Combined overview call const { data: overview, loading: overviewLoading, error: overviewError, } = useSystemOverview(useOverview ? refreshInterval : 0); const handleRefreshIntervalChange = (e: React.ChangeEvent) => { setRefreshInterval(Number(e.target.value)); }; const handleDataSourceToggle = () => { setUseOverview(!useOverview); }; // Use overview data if enabled const displayHealth = useOverview && overview ? overview.health : health; const displayServices = useOverview && overview ? overview.services : services; const displayProxies = useOverview && overview ? overview.proxies : proxies; const displayCache = useOverview && overview ? overview.health.services.cache : cache; const displayQueues = useOverview && overview ? overview.health.services.queues : queues; const displayDatabases = useOverview && overview ? overview.health.services.databases : databases; const isLoading = useOverview ? overviewLoading : healthLoading || cacheLoading || queuesLoading || dbLoading || servicesLoading || proxiesLoading; const errors = useOverview ? overviewError ? [overviewError] : [] : [healthError, cacheError, queuesError, dbError, servicesError, proxiesError].filter(Boolean); if (isLoading) { return (

Loading monitoring data...

); } return (

System Monitoring

{errors.length > 0 && (

Errors occurred while fetching data:

    {errors.map((error, index) => (
  • {error}
  • ))}
)} {useOverview && overview && (

System Environment

Node:{' '} {overview.environment.nodeVersion}
Platform:{' '} {overview.environment.platform}
Architecture:{' '} {overview.environment.architecture}
Hostname:{' '} {overview.environment.hostname}
)}
{/* Service Status */} {displayServices && displayServices.length > 0 && (

Microservices Status

)} {/* System Health and Cache */} {displayHealth && (
{displayCache && }
{displayProxies && }
)} {/* Database Stats */} {displayDatabases && displayDatabases.length > 0 && (

Database Connections

)} {/* Queue Stats */} {displayQueues && displayQueues.length > 0 && (

Queue Status

)}
); }