File size: 3,433 Bytes
de5da9f
315134b
 
 
 
 
 
901ba54
 
 
 
 
 
 
 
 
 
 
315134b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de5da9f
315134b
 
 
de5da9f
 
315134b
de5da9f
 
 
 
 
315134b
 
 
 
 
 
de5da9f
 
901ba54
de5da9f
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

document.addEventListener('DOMContentLoaded', function() {
    // Theme Toggle
    const themeToggle = document.getElementById('theme-toggle');
    const sunIcon = '<i data-feather="sun" class="w-5 h-5"></i>';
    const moonIcon = '<i data-feather="moon" class="w-5 h-5"></i>';
    
    if (themeToggle) {
        themeToggle.addEventListener('click', function() {
            document.body.classList.toggle('dark');
            if (document.body.classList.contains('dark')) {
                themeToggle.innerHTML = sunIcon;
            } else {
                themeToggle.innerHTML = moonIcon;
            }
            feather.replace();
        });
    }

    // Initialize tooltips
    const tooltips = document.querySelectorAll('[data-tooltip]');
    tooltips.forEach(tooltip => {
        tooltip.addEventListener('mouseenter', function() {
            const tooltipText = this.getAttribute('data-tooltip');
            const tooltipEl = document.createElement('div');
            tooltipEl.className = 'absolute z-10 px-3 py-2 text-xs font-medium text-white bg-gray-900 rounded-lg shadow-sm tooltip';
            tooltipEl.textContent = tooltipText;
            document.body.appendChild(tooltipEl);
            
            const rect = this.getBoundingClientRect();
            tooltipEl.style.top = rect.bottom + 10 + 'px';
            tooltipEl.style.left = rect.left + (rect.width/2) - (tooltipEl.offsetWidth/2) + 'px';
        });
        
        tooltip.addEventListener('mouseleave', function() {
            const tooltips = document.querySelectorAll('.tooltip');
            tooltips.forEach(tip => tip.remove());
        });
    });

    // Simulate live data updates
    function updateStats() {
        const stats = document.querySelectorAll('.text-2xl.font-bold');
        stats.forEach(stat => {
            const currentValue = parseInt(stat.textContent);
            const change = Math.floor(Math.random() * 3) - 1; // -1, 0, or 1
            const newValue = Math.max(0, currentValue + change);
            stat.textContent = newValue;
        });
    }

    // Update stats every 30 seconds
    setInterval(updateStats, 30000);

    // Service status simulation
    function updateServiceStatus() {
        const services = document.querySelectorAll('.service-card');
        services.forEach(service => {
            const random = Math.random();
            if (random > 0.7) {
                service.style.borderColor = '#10B981';
                service.style.boxShadow = '0 0 10px rgba(16, 185, 129, 0.3)';
            } else if (random > 0.4) {
                service.style.borderColor = '#F59E0B';
                service.style.boxShadow = '0 0 10px rgba(245, 158, 11, 0.3)';
            } else {
                service.style.borderColor = '';
                service.style.boxShadow = '';
            }
        });
    }

    // Update service status every minute
    setInterval(updateServiceStatus, 60000);
    
    // Add hover effects to sidebar items
    const sidebarLinks = document.querySelectorAll('custom-sidebar nav a');
    sidebarLinks.forEach(link => {
        link.addEventListener('mouseenter', function() {
            if (!this.classList.contains('active')) {
                this.style.transform = 'translateX(5px)';
            }
        });
        
        link.addEventListener('mouseleave', function() {
            this.style.transform = '';
        });
    });
});