diff --git a/frontend/src/components/settings/admin/AdminStatsTab.jsx b/frontend/src/components/settings/admin/AdminStatsTab.jsx index 6950c8b..b8564da 100644 --- a/frontend/src/components/settings/admin/AdminStatsTab.jsx +++ b/frontend/src/components/settings/admin/AdminStatsTab.jsx @@ -1,17 +1,18 @@ import React from 'react'; -import { - Grid, - Card, - Stack, - Text, - Title, - LoadingOverlay, - Alert, - RingProgress, -} from '@mantine/core'; -import { IconUsers, IconFolders, IconAlertCircle } from '@tabler/icons-react'; +import { Table, Text, Box, LoadingOverlay, Alert } from '@mantine/core'; +import { IconAlertCircle } from '@tabler/icons-react'; import { useAdmin } from '../../../hooks/useAdmin'; -import StatCard from './StatCard'; + +const formatBytes = (bytes) => { + const units = ['B', 'KB', 'MB', 'GB']; + let size = bytes; + let unitIndex = 0; + while (size >= 1024 && unitIndex < units.length - 1) { + size /= 1024; + unitIndex++; + } + return `${size.toFixed(1)} ${units[unitIndex]}`; +}; const AdminStatsTab = () => { const { data: stats, loading, error } = useAdmin('stats'); @@ -28,61 +29,37 @@ const AdminStatsTab = () => { ); } + const statsRows = [ + { label: 'Total Users', value: stats.totalUsers }, + { label: 'Active Users', value: stats.activeUsers }, + { label: 'Total Workspaces', value: stats.totalWorkspaces }, + { label: 'Total Files', value: stats.totalFiles }, + { label: 'Total Storage Size', value: formatBytes(stats.totalSize) }, + ]; + return ( - - + + System Statistics - - - - - - - - - - - - - - Active Users - - {((stats.activeUsers / stats.totalUsers) * 100).toFixed(1)}% - - } - /> - - {stats.activeUsers} out of {stats.totalUsers} users active in - last 30 days - - - - - - + + + + Metric + Value + + + + {statsRows.map((row) => ( + + {row.label} + {row.value} + + ))} + +
+ ); }; diff --git a/frontend/src/components/settings/admin/StatCard.jsx b/frontend/src/components/settings/admin/StatCard.jsx deleted file mode 100644 index 9a2a379..0000000 --- a/frontend/src/components/settings/admin/StatCard.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { Card, Group, Box, Text } from '@mantine/core'; - -const StatCard = ({ title, value, icon: Icon, color = 'blue' }) => ( - - - - - {title} - - - {value} - - - - - -); - -export default StatCard;