File size: 2,696 Bytes
fee2f22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
 * MetricsOverview component - Display aggregated metrics in stat cards
 */

import React from 'react';
import {
  Box,
  Typography,
  Paper,
  Grid,
} from '@mui/material';
import {
  Work as JobsIcon,
  Speed as AccuracyIcon,
  TableRows as RowsIcon,
  Storage as DataIcon,
} from '@mui/icons-material';

interface MetricsOverviewProps {
  totalJobs: number;
  avgAccuracy: number;
  totalRowsCleaned: number;
  totalDataProcessed: number;
}

const MetricsOverview: React.FC<MetricsOverviewProps> = ({
  totalJobs,
  avgAccuracy,
  totalRowsCleaned,
  totalDataProcessed,
}) => {
  const formatDataSize = (bytes: number): string => {
    if (bytes >= 1073741824) {
      return `${(bytes / 1073741824).toFixed(1)} GB`;
    }
    if (bytes >= 1048576) {
      return `${(bytes / 1048576).toFixed(1)} MB`;
    }
    if (bytes >= 1024) {
      return `${(bytes / 1024).toFixed(1)} KB`;
    }
    return `${bytes} B`;
  };

  const statCards = [
    {
      icon: <JobsIcon fontSize="large" />,
      label: 'Total Jobs',
      value: totalJobs.toLocaleString(),
      color: '#1976d2',
    },
    {
      icon: <AccuracyIcon fontSize="large" />,
      label: 'Avg Accuracy',
      value: `${(avgAccuracy * 100).toFixed(1)}%`,
      color: '#2e7d32',
    },
    {
      icon: <RowsIcon fontSize="large" />,
      label: 'Total Rows Cleaned',
      value: totalRowsCleaned.toLocaleString(),
      color: '#ed6c02',
    },
    {
      icon: <DataIcon fontSize="large" />,
      label: 'Total Data Processed',
      value: formatDataSize(totalDataProcessed),
      color: '#9c27b0',
    },
  ];

  return (
    <Paper elevation={2} sx={{ p: 3 }}>
      <Typography variant="h6" gutterBottom sx={{ fontWeight: 600 }}>
        Metrics Overview
      </Typography>
      <Grid container spacing={2}>
        {statCards.map((card, index) => (
          <Grid size={{ xs: 6, md: 3 }} key={index}>
            <Box
              sx={{
                p: 2,
                borderRadius: 2,
                bgcolor: `${card.color}10`,
                border: '1px solid',
                borderColor: `${card.color}30`,
                textAlign: 'center',
                height: '100%',
              }}
            >
              <Box sx={{ color: card.color, mb: 1 }}>
                {card.icon}
              </Box>
              <Typography variant="h4" sx={{ fontWeight: 700, color: card.color }}>
                {card.value}
              </Typography>
              <Typography variant="body2" color="textSecondary">
                {card.label}
              </Typography>
            </Box>
          </Grid>
        ))}
      </Grid>
    </Paper>
  );
};

export default MetricsOverview;