/** * Dashboard JavaScript functionality */ let productivityChart = null; let toolsChart = null; async function loadDashboardData() { try { // Show loading state showLoadingState(); // Load data in parallel const [ analyticsSummary, productivityMetrics, toolUsageStats, recentProjects ] = await Promise.all([ apiClient.getAnalyticsSummary(), apiClient.getProductivityMetrics(null, 30), apiClient.getToolUsageStats(null, null, 30), apiClient.getProjects(5, 0) ]); // Update summary cards updateSummaryCards(analyticsSummary); // Update engagement metrics updateEngagementMetrics(productivityMetrics); // Update charts updateProductivityChart(productivityMetrics.productivity_trends); updateToolsChart(toolUsageStats); // Update recent projects updateRecentProjects(recentProjects); // Update quick stats updateQuickStats(analyticsSummary); } catch (error) { console.error('Failed to load dashboard data:', error); showErrorState('Failed to load dashboard data. Please try refreshing the page.'); } } function showLoadingState() { // Update cards with loading state document.getElementById('total-sessions').textContent = '-'; document.getElementById('total-time').textContent = '-'; document.getElementById('active-projects').textContent = '-'; document.getElementById('productivity-score').textContent = '-'; } function showErrorState(message) { // Show error message const alertHtml = `
No projects found