import { useList } from "@refinedev/core"; import { Card, Col, Row, Statistic, Progress, Alert, Table, Typography } from "antd"; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts"; import { CheckCircleOutlined, WarningOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; const { Title } = Typography; // Mock data for the chart const performanceData = [ { name: '00:00', cpu: 40, memory: 55, network: 20 }, { name: '03:00', cpu: 30, memory: 58, network: 28 }, { name: '06:00', cpu: 20, memory: 40, network: 20 }, { name: '09:00', cpu: 27, memory: 60, network: 40 }, { name: '12:00', cpu: 90, memory: 76, network: 60 }, { name: '15:00', cpu: 75, memory: 65, network: 50 }, { name: '18:00', cpu: 80, memory: 70, network: 45 }, { name: '21:00', cpu: 65, memory: 60, network: 30 }, ]; // Mock data for alerts const alertsData = [ { id: 1, level: 'critical', message: 'Server CPU usage exceeds 90%', timestamp: '2025-05-08T12:30:00', status: 'active' }, { id: 2, level: 'warning', message: 'Database memory utilization above 75%', timestamp: '2025-05-08T11:15:00', status: 'active' }, { id: 3, level: 'info', message: 'Client deployment auto-scaled to 3 instances', timestamp: '2025-05-08T09:45:00', status: 'resolved' }, { id: 4, level: 'warning', message: 'Network latency spiked to 250ms', timestamp: '2025-05-08T08:20:00', status: 'resolved' }, ]; export const MonitoringDashboard = () => { const { data: deploymentsData } = useList({ resource: "deployments", }); // Calculate some stats from deployments data const activeDeployments = deploymentsData?.data?.filter(item => item.status === "active").length || 0; const totalDeployments = deploymentsData?.data?.length || 0; const healthyDeployments = deploymentsData?.data?.filter(item => item.healthStatus === "healthy").length || 0; return ( <> Infrastructure Monitoring } />
0 ? Math.round((activeDeployments / totalDeployments) * 100) : 0} size="small" />
: } suffix="deployments healthy" />
0 ? Math.round((healthyDeployments / totalDeployments) * 100) : 0} size="small" status={healthyDeployments === totalDeployments ? "success" : "exception"} />
80 ? "exception" : "active"} />
80 ? "exception" : "active"} />
{alertsData .filter(alert => alert.status === 'active') .map(alert => ( ))} { const color = text === 'critical' ? 'red' : text === 'warning' ? 'orange' : 'blue'; return {text.toUpperCase()}; } }, { title: 'Message', dataIndex: 'message', key: 'message' }, { title: 'Timestamp', dataIndex: 'timestamp', key: 'timestamp' }, { title: 'Status', dataIndex: 'status', key: 'status', render: (text) => { return text === 'active' ? ACTIVE : RESOLVED; } } ]} /> ); };