/** * Admin Dashboard Page * Main dashboard for admin users showing ML models, agents, and system health */ import { useState, useEffect } from 'react'; import { CpuChipIcon, ChartBarIcon, UserGroupIcon, ServerIcon, ArrowTrendingUpIcon, ArrowTrendingDownIcon, CheckCircleIcon, ExclamationTriangleIcon, XCircleIcon, } from '@heroicons/react/24/solid'; import { getAdminDashboard, getSystemHealth, getMLModels, getAgents, type AdminStats, type SystemHealth, type MLModel, type AgentPerformance, } from '../../../services/adminService'; export default function AdminDashboard() { const [stats, setStats] = useState(null); const [health, setHealth] = useState(null); const [models, setModels] = useState([]); const [agents, setAgents] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { loadDashboardData(); }, []); const loadDashboardData = async () => { setLoading(true); try { const [dashboardData, healthData, modelsData, agentsData] = await Promise.all([ getAdminDashboard(), getSystemHealth(), getMLModels(), getAgents(), ]); setStats(dashboardData); setHealth(healthData); setModels(Array.isArray(modelsData) ? modelsData : []); setAgents(Array.isArray(agentsData) ? agentsData : []); } catch (error) { console.error('Error loading dashboard data:', error); } finally { setLoading(false); } }; const getHealthIcon = (status: string) => { switch (status) { case 'healthy': return ; case 'degraded': return ; default: return ; } }; const formatCurrency = (value: number) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, }).format(value); }; if (loading) { return (
); } return (
{/* Header */}

Admin Dashboard

OrbiQuant IA Platform Overview

{/* System Health Banner */} {health && (
{getHealthIcon(health.status)} System Status: {health.status.charAt(0).toUpperCase() + health.status.slice(1)} Last updated: {new Date(health.timestamp).toLocaleString()}
)} {/* Stats Grid */}
{/* ML Models Card */}
ML Models

{models.length}

{models.filter(m => m.status === 'active' || m.status === 'training').length} active

{/* Trading Agents Card */}
Trading Agents

{agents.length}

{agents.filter(a => a.status === 'active').length} running

{/* Total P&L Card */}
Today's P&L

= 0 ? 'text-green-400' : 'text-red-400'}`}> {formatCurrency(stats?.total_pnl_today || 0)}

{(stats?.total_pnl_today || 0) >= 0 ? ( ) : ( )} vs yesterday
{/* Predictions Card */}
Predictions Today

{stats?.total_predictions_today || 0}

{((stats?.overall_accuracy || 0) * 100).toFixed(1)}% accuracy

{/* Services Health */} {health && (

Services Health

Database
{getHealthIcon(health.services.database.status)}
ML Engine
{getHealthIcon(health.services.mlEngine.status)}
Trading Agents
{getHealthIcon(health.services.tradingAgents.status)}
)} {/* ML Models Overview */}

ML Models

View All
{models.slice(0, 6).map((model, index) => (
{model.name || model.type} {model.status}
Accuracy: {((model.accuracy || 0) * 100).toFixed(1)}%
))}
{/* Trading Agents Overview */}

Trading Agents

View All
{agents.map((agent, index) => (
{agent.name} {agent.status}
Win Rate {((agent.win_rate || 0) * 100).toFixed(1)}%
Total P&L = 0 ? 'text-green-400' : 'text-red-400'}> {formatCurrency(agent.total_pnl || 0)}
Trades {agent.total_trades || 0}
))} {agents.length === 0 && (
No trading agents configured yet
)}
{/* System Info */} {health && (

System Info

Uptime

{Math.floor(health.system.uptime / 3600)}h {Math.floor((health.system.uptime % 3600) / 60)}m

Memory Usage

{health.system.memory.percentage.toFixed(1)}%

Last Update

{new Date(health.timestamp).toLocaleTimeString()}

)}
); }