/** * @fileoverview Time tracking summary panel for the Day view. * * Collapsible section showing: * - Today's total tracked time * - This week's per-project breakdown (CSS bar chart, no library) */ (function() { 'use strict'; const esc = (s) => GoingsOn.utils.escapeHtml(s); /** * Format a minute count as a human-readable duration. * @param {number} mins - Minutes to format * @returns {string} Formatted string (e.g., "2h 15m", "45m", "3h") */ function formatMinutes(mins) { if (mins < 60) return `${mins}m`; const h = Math.floor(mins / 60); const m = mins % 60; return m > 0 ? `${h}h ${m}m` : `${h}h`; } // ============ Render ============ /** * Render the time tracking summary panel (today's total + weekly per-project bars). * @param {HTMLElement} container - DOM element to render into */ async function render(container) { if (!container) return; // Rust computes the week window, aggregates by project, sorts, and rolls up // the percentages (see get_time_summary_panel). The JS only renders. let panel; try { panel = await GoingsOn.api.timeTracking.getSummaryPanel(); } catch (err) { console.error('Failed to load time summary:', err); return; } const projects = panel.projects || []; let html = `