/** * admin-ui/js/core/landing-page.js * Manages the landing page that displays all available dashboards */ const DASHBOARDS = [ { id: 'dashboard', category: 'Overview', icon: '📊', title: 'Dashboard', description: 'System overview and key metrics', href: '#dashboard' }, { id: 'projects', category: 'Overview', icon: '📁', title: 'Projects', description: 'Manage and organize projects', href: '#projects' }, { id: 'services', category: 'Tools', icon: '⚙️', title: 'Services', description: 'Manage system services and endpoints', href: '#services' }, { id: 'quick-wins', category: 'Tools', icon: '⭐', title: 'Quick Wins', description: 'Quick optimization opportunities', href: '#quick-wins' }, { id: 'chat', category: 'Tools', icon: '💬', title: 'Chat', description: 'AI-powered chat assistant', href: '#chat' }, { id: 'tokens', category: 'Design System', icon: '🎨', title: 'Tokens', description: 'Design tokens and variables', href: '#tokens' }, { id: 'components', category: 'Design System', icon: '🧩', title: 'Components', description: 'Reusable component library', href: '#components' }, { id: 'figma', category: 'Design System', icon: '🎭', title: 'Figma', description: 'Figma integration and sync', href: '#figma' }, { id: 'storybook', category: 'Design System', icon: '📚', title: 'Storybook', description: 'Component documentation', href: 'http://localhost:6006', target: '_blank' }, { id: 'docs', category: 'System', icon: '📖', title: 'Documentation', description: 'System documentation and guides', href: '#docs' }, { id: 'teams', category: 'System', icon: '👥', title: 'Teams', description: 'Team management and permissions', href: '#teams' }, { id: 'audit', category: 'System', icon: '✅', title: 'Audit', description: 'Audit logs and system events', href: '#audit' }, { id: 'plugins', category: 'System', icon: '🔌', title: 'Plugins', description: 'Plugin management system', href: '#plugins' }, { id: 'settings', category: 'System', icon: '⚡', title: 'Settings', description: 'System configuration and preferences', href: '#settings' } ]; class LandingPage { constructor(appElement) { this.app = appElement; this.landingPage = null; this.pageContent = null; this.init(); } init() { this.landingPage = this.app.querySelector('#landing-page'); this.pageContent = this.app.querySelector('#page-content'); if (this.landingPage) { this.render(); this.bindEvents(); } // Listen for hash changes window.addEventListener('hashchange', () => this.handleRouteChange()); this.handleRouteChange(); } handleRouteChange() { const hash = window.location.hash.substring(1) || ''; const isLanding = hash === '' || hash === 'landing'; if (this.landingPage) { this.landingPage.classList.toggle('active', isLanding); } if (this.pageContent) { this.pageContent.style.display = isLanding ? 'none' : 'block'; } } render() { if (!this.landingPage) return; const categories = this.groupByCategory(); this.landingPage.innerHTML = `

Design System Swarm

Welcome to your design system management interface. Select a dashboard to get started.

${Object.entries(categories) .map(([category, dashboards]) => `

${category}

${dashboards .map(d => `
${d.icon}

${d.title}

${d.description}

`) .join('')}
`) .join('')}
`; } groupByCategory() { const grouped = {}; DASHBOARDS.forEach(dashboard => { if (!grouped[dashboard.category]) { grouped[dashboard.category] = []; } grouped[dashboard.category].push(dashboard); }); return grouped; } bindEvents() { const cards = this.landingPage.querySelectorAll('.dashboard-card'); cards.forEach(card => { card.addEventListener('click', (e) => { // Allow external links (Storybook) to open normally if (card.target === '_blank') { return; } e.preventDefault(); window.location.hash = card.getAttribute('href').substring(1); }); }); } } export default LandingPage;