import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Server } from "@/types/server.types";
import { Cpu, HardDrive, MemoryStick, Clock, Activity, Info } from "lucide-react";
import { useTheme } from "@/contexts/ThemeContext";
interface ServerMetricsOverviewProps {
server: Server;
}
export const ServerMetricsOverview = ({ server }: ServerMetricsOverviewProps) => {
const { theme } = useTheme();
const formatBytes = (bytes: number) => {
if (bytes === 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
};
const getStatusColor = (status: string) => {
switch (status) {
case 'up':
return 'text-green-500';
case 'down':
return 'text-red-500';
case 'warning':
return 'text-yellow-500';
default:
return 'text-muted-foreground';
}
};
const cpuUsagePercent = server.cpu_usage || 0;
const ramUsagePercent = server.ram_total > 0 ? (server.ram_used / server.ram_total) * 100 : 0;
const diskUsagePercent = server.disk_total > 0 ? (server.disk_used / server.disk_total) * 100 : 0;
const MetricCard = ({ title, used, total, free, percentage, icon: Icon, color, gradient, additionalInfo }: {
title: string;
used: string;
total: string;
free: string;
percentage: number;
icon: any;
color: string;
gradient: string;
additionalInfo?: string;
}) => (