/** * Statistics manager for gallery display */ export class StatsManager { constructor() { this.updateGalleryStats(); } /** * Update gallery statistics display */ updateGalleryStats() { // Use stats passed from Python backend if available // Otherwise fallback to DOM counting const gridItems = document.querySelectorAll('.grid-item'); const subdirLinks = document.querySelectorAll('a[href$="/index.html"]'); const fileCountEl = document.getElementById('fileCount'); const folderCountEl = document.getElementById('folderCount'); const totalSizeEl = document.getElementById('totalSize'); const lastUpdatedEl = document.getElementById('lastUpdated'); if (fileCountEl) fileCountEl.textContent = gridItems.length; if (folderCountEl) folderCountEl.textContent = subdirLinks.length; if (totalSizeEl) totalSizeEl.textContent = 'Unknown'; // Set last updated time const now = new Date(); const timeStr = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); if (lastUpdatedEl) lastUpdatedEl.textContent = timeStr; } /** * Update stats with backend data */ updateWithBackendStats(stats) { const fileCountEl = document.getElementById('fileCount'); const folderCountEl = document.getElementById('folderCount'); const totalSizeEl = document.getElementById('totalSize'); if (fileCountEl && stats.file_count !== undefined) { fileCountEl.textContent = stats.file_count; } if (folderCountEl && stats.folder_count !== undefined) { folderCountEl.textContent = stats.folder_count; } if (totalSizeEl && stats.total_size !== undefined) { totalSizeEl.textContent = stats.total_size; } } }