From 5c31c53b5f2f98505962b217c913486e4cfcfbe6 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Fri, 21 Aug 2026 00:14:51 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20I.3=20Dashboard=20=E2=80=94=20system=20?= =?UTF-8?q?metrics=20(DB/Redis/Worker/API),=20cost=20tracking=20(LLM=20cos?= =?UTF-8?q?t=2024h),=20usage=20analytics=20(tokens/plugins),=20admin-only,?= =?UTF-8?q?=20tsc=20clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/Dashboard.tsx | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) 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 ? (