diff --git a/kms/web/src/components/Dashboard.tsx b/kms/web/src/components/Dashboard.tsx index f1b5fe5..d16e9d6 100644 --- a/kms/web/src/components/Dashboard.tsx +++ b/kms/web/src/components/Dashboard.tsx @@ -41,16 +41,26 @@ const Dashboard: React.FC = () => { try { setLoading(true); - // Load applications and tokens data - const [appsResponse] = await Promise.all([ - apiService.getApplications(100, 0), - ]); + // Load applications + const appsResponse = await apiService.getApplications(100, 0); + + // Load tokens for each application and count them + let totalTokens = 0; + for (const app of appsResponse.data) { + try { + const tokensResponse = await apiService.getTokensForApplication(app.app_id, 100, 0); + totalTokens += tokensResponse.count; + } catch (error) { + // Some apps might not have tokens, that's OK + console.debug(`No tokens found for app ${app.app_id}`); + } + } // Calculate stats const dashboardStats: DashboardStats = { totalApplications: appsResponse.count, - totalTokens: 0, // We'd need to aggregate from all apps - recentActivity: 0, + totalTokens: totalTokens, + recentActivity: 0, // TODO: Could load from audit events systemHealth: 'healthy', };