File size: 1,169 Bytes
74c3da0
ebd0cce
 
 
 
4c08787
 
ebd0cce
4c08787
 
 
 
ebd0cce
 
 
 
 
 
 
 
 
4c08787
 
1a8e166
 
 
 
 
 
 
 
4c08787
 
74c3da0
ebd0cce
4c08787
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
async function initPage() {
    try {
        const response = await fetch('/data.json');
        const data = await response.json();
        
        // Initialize dashboard
        initDashboard(data);
        
        // Show content
        document.querySelector('.dashboard-content').classList.remove('hidden');
        document.querySelector('.skeleton-grid').classList.add('hidden');
    } catch (error) {
        console.error('Error loading dashboard:', error);
        document.body.innerHTML = `
            <div class="error-container">
                <h2>Failed to load dashboard</h2>
                <p>${error.message}</p>
                <button onclick="window.location.reload()">Retry</button>
            </div>
        `;
    }
}

function initDashboard(data) {
    const grid = document.querySelector('grid-layout');
    
    data.dashboard.widgets.forEach(widget => {
        const widgetEl = document.createElement(`${widget.type}-widget`);
        widgetEl.setAttribute('config', JSON.stringify(widget.config));
        grid.appendChild(widgetEl);
    });
    
    feather.replace();
}

document.addEventListener('DOMContentLoaded', initPage);