Spaces:
Running
Running
File size: 5,658 Bytes
1fc59af cd0b80e 616dafc fcfb084 aa15735 616dafc aa15735 cd0b80e aa15735 616dafc cd0b80e aa15735 fcfb084 aa15735 fcfb084 aa15735 cd0b80e aa15735 fcfb084 616dafc aa15735 616dafc dd31b27 f5e2cbe dd31b27 f5e2cbe dd31b27 f5e2cbe dd31b27 f5e2cbe 616dafc | 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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
// Realistic device simulation data with enhanced compliance checks
const sampleData = {
stats: {
totalDevices: 30,
compliantDevices: 22,
nonCompliantDevices: 8,
missingComponents: {
ad: 3,
antivirus: 5,
tacticalRmm: 4,
glpiAgent: 2, // Corrected from gpiAgent to glpiAgent
encryption: 6,
backup: 3,
patches: 7
}
},
devices: Array.from({length: 30}, (_, i) => {
// Realistic compliance patterns
const isCritical = i % 5 === 0; // 20% critical devices
const isOld = i % 7 === 0; // ~14% older devices
const isLaptop = i % 3 === 0; // 33% laptops
const isRemote = i % 4 === 0; // 25% remote workers
// Base compliance - critical devices are always compliant
let isCompliant = isCritical || Math.random() > 0.25;
// Older devices are less likely to be compliant
if (isOld && Math.random() > 0.3) isCompliant = false;
// Remote devices have specific compliance issues
const remoteIssues = isRemote && Math.random() > 0.6;
return {
id: `DEV-${1000 + i}`,
name: `${isLaptop ? 'LT' : 'DT'}-${String(i + 1).padStart(3, '0')}`,
type: isLaptop ? 'Laptop' : 'Desktop',
user: generateRealisticUsername(i),
department: ['Finance', 'IT', 'HR', 'Marketing', 'Operations', 'Engineering'][i % 6],
os: getRandomOS(i),
ip: generateRandomIP(i),
status: isCompliant ? 'compliant' : 'non-compliant',
lastSeen: generateLastSeenDate(i, isCompliant),
ad: isCompliant && !(remoteIssues && Math.random() > 0.7),
antivirus: isCompliant && !(isOld && Math.random() > 0.4),
tacticalRmm: isCompliant && Math.random() > 0.1, // 90% compliance for Tactical RMM
glpiAgent: isCompliant && Math.random() > 0.2, // 80% compliance for GLPI
antivirus: isCompliant && Math.random() > 0.05, // 95% compliance for Antivirus
ad: isCompliant && Math.random() > 0.03, // 97% compliance for AD
encryption: isCompliant && !(isLaptop && Math.random() > 0.2),
backup: isCompliant && !(isOld && Math.random() > 0.5),
patches: isCompliant ? Math.floor(Math.random() * 3) : Math.floor(Math.random() * 8) + 3,
issues: isCompliant ? 0 : Math.floor(Math.random() * 3) + 1
};
})
};
// Helper functions for realistic data generation
function generateRealisticUsername(index) {
const firstNames = ['John', 'Jane', 'Michael', 'Sarah', 'David', 'Emily', 'Robert', 'Jennifer'];
const lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Miller', 'Davis', 'Wilson'];
const firstName = firstNames[index % firstNames.length];
const lastName = lastNames[Math.floor(index / firstNames.length) % lastNames.length];
return `${firstName.toLowerCase()}.${lastName.toLowerCase()}`;
}
function generateRandomIP(index) {
return `192.168.${Math.floor(index / 16)}.${1 + (index % 254)}`;
}
function getRandomOS(index) {
const osList = [
'Windows 10 Enterprise',
'Windows 11 Enterprise',
'Windows 10 Pro',
'Windows 11 Pro',
'Windows Server 2019',
'Windows Server 2022'
];
return osList[index % osList.length];
}
function generateLastSeenDate(index, isCompliant) {
// Compliant devices seen more recently
const maxDays = isCompliant ? 3 : 14;
const offset = Math.random() * maxDays * 24 * 60 * 60 * 1000;
return new Date(Date.now() - offset).toISOString();
}
// Auto-refresh function
function setupAutoRefresh() {
setInterval(() => {
console.log("Refreshing data...");
// In a real app, this would fetch fresh data from the API
// For now, we'll just reinitialize the charts
initCharts();
}, 5 * 60 * 1000); // 5 minutes
}
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
setupAutoRefresh();
updateLastUpdatedTime();
// Add click event to device rows
document.addEventListener('click', (e) => {
const row = e.target.closest('.device-row');
if (row) {
const deviceId = row.dataset.id;
console.log(`Device ${deviceId} clicked`);
// In a real app, this would open a device detail view
row.classList.add('bg-blue-900/10');
setTimeout(() => row.classList.remove('bg-blue-900/10'), 200);
}
});
// Update last updated time every minute
setInterval(updateLastUpdatedTime, 60000);
});
function updateLastUpdatedTime() {
const now = new Date();
const timeString = now.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
document.getElementById('last-updated').textContent = `Today at ${timeString}`;
}
// Set up event listeners for filter controls
document.querySelectorAll('.filter-select').forEach(select => {
select.addEventListener('change', () => {
console.log("Filter changed - would apply filters in real app");
});
});
// Export buttons
document.getElementById('export-csv').addEventListener('click', () => {
console.log("Exporting to CSV...");
// In a real app, this would generate and download a CSV file
});
document.getElementById('export-pdf').addEventListener('click', () => {
console.log("Exporting to PDF...");
// In a real app, this would generate and download a PDF report
});
}); |