Files
ETPlot/assets/js/gallery-app.js
T
2025-07-08 17:04:55 +02:00

72 lines
2.6 KiB
JavaScript

/**
* Main Gallery Application
* Orchestrates all the different managers and functionality
*/
import { ThemeManager } from './theme-manager.js';
import { NavigationManager } from './navigation-manager.js';
import { SearchManager } from './search-manager.js';
import { RecentPlotsManager } from './recent-plots-manager.js';
import { ComparisonManager } from './comparison-manager.js';
import { StatsManager } from './stats-manager.js';
import { KeyboardManager } from './keyboard-manager.js';
import { ExportManager } from './export-manager.js';
import { Utils } from './utils.js';
/**
* Main Gallery Application Class
*/
export class GalleryApp {
constructor(config = {}) {
// Configuration from backend template variables
this.SEARCH_DEBOUNCE_MS = config.searchDebounceMs || 300;
this.MAX_RECENT_PLOTS = config.maxRecentPlots || 20;
this.stats = config.stats || null;
// Initialize managers
this.themeManager = new ThemeManager();
this.navigationManager = new NavigationManager();
this.searchManager = new SearchManager(this.SEARCH_DEBOUNCE_MS);
this.recentPlotsManager = new RecentPlotsManager(this.MAX_RECENT_PLOTS);
this.comparisonManager = new ComparisonManager();
this.statsManager = new StatsManager();
this.exportManager = new ExportManager();
this.keyboardManager = new KeyboardManager(this);
this.utils = Utils;
// Set global references for backward compatibility
window.themeManager = this.themeManager;
window.searchManager = this.searchManager;
window.recentPlotsManager = this.recentPlotsManager;
window.comparisonManager = this.comparisonManager;
window.exportManager = this.exportManager;
window.utils = this.utils;
this.init();
}
/**
* Initialize the gallery application
*/
init() {
this.navigationManager.buildBreadcrumb();
this.navigationManager.buildFolderTree();
// Update stats with backend data if available
if (this.stats) {
this.statsManager.updateWithBackendStats(this.stats);
}
// Handle URL-based thumbnail highlighting
Utils.handleThumbnailHighlight();
}
// Backward compatibility methods
toggleTheme() { this.themeManager.toggle(); }
toggleSidebar() { this.recentPlotsManager.toggleSidebar(); }
refreshGallery() { Utils.refreshGallery(); }
toggleCompareMode() { this.comparisonManager.toggleCompareMode(); }
closeComparison() { this.comparisonManager.closeComparison(); }
selectPlotForComparison(slot) { this.comparisonManager.selectPlotForComparison(slot); }
replacePlot(slot) { this.comparisonManager.replacePlot(slot); }
}