diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index 3ded3cd..a282a60 100644 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -4,7 +4,10 @@ import { ActivityFeed, ActivityItem } from '@/components/shared/ActivityFeed'; import { DashboardGrid } from '@/components/dashboard/DashboardGrid'; import { useUnifiedContacts, useAuditLog } from '@/api/hooks'; import { useDashboardWidgets } from '@/api/dashboard'; +import { useSystemDashboard } from '@/api/systemDashboard'; +import { useAuthStore } from '@/store/authStore'; import { formatDateTime } from '@/utils/date'; +import { Database, Server, Cpu, DollarSign, Activity, TrendingUp } from 'lucide-react'; export function DashboardPage() { const { t } = useTranslation(); @@ -12,6 +15,9 @@ export function DashboardPage() { const { data: contactsData } = useUnifiedContacts(1, 1, undefined, 'person'); const { data: auditData, isError: auditError } = useAuditLog(1, 5); const { data: widgetsData, isError: widgetsError } = useDashboardWidgets(); + const { data: systemData } = useSystemDashboard(); + const user = useAuthStore((s) => s.user); + const isAdmin = user?.is_system_admin ?? false; const totalCompanies = companiesData?.total ?? 0; const totalContacts = contactsData?.total ?? 0; @@ -72,6 +78,72 @@ export function DashboardPage() { /> + {/* System Metrics (Admin only) — I-DASH, I-COST, I-USE */} + {isAdmin && systemData && ( +
+

{t('dashboard.systemMetrics', 'System Status')}

+
+
+
+ + Database +
+

{systemData.database?.status === 'up' ? '✅' : '❌'}

+

{systemData.database?.db_size_human || '—'}

+
+
+
+ + Redis +
+

{systemData.redis?.status === 'up' ? '✅' : '❌'}

+

{systemData.redis?.used_memory_human || '—'}

+
+
+
+ + Worker +
+

{systemData.worker?.status === 'up' ? '✅' : '❌'}

+

Queue: {systemData.worker?.queue_length ?? '—'}

+
+
+
+ + API +
+

{systemData.api?.total_requests ?? '—'}

+

Errors: {systemData.api?.error_count ?? 0}

+
+
+ {systemData.llm && ( +
+
+
+ + LLM Cost (24h) +
+

${systemData.llm.cost_24h?.toFixed(2) ?? '0.00'}

+
+
+
+ + LLM Tokens (24h) +
+

{systemData.llm.tokens_24h?.toLocaleString() ?? '0'}

+
+
+
+ + Active Plugins +
+

{systemData.plugins?.active_count ?? '—'}

+
+
+ )} +
+ )} + {/* Dynamic Plugin Widgets */} {widgetsError ? (