v0.2.1. many features added and cleaned up.

This commit is contained in:
serversdwn
2025-12-03 21:23:18 +00:00
parent dc853806bb
commit 4cef580185
13 changed files with 1815 additions and 181 deletions

View File

@@ -35,7 +35,12 @@
<span class="text-gray-600 dark:text-gray-400">Deployed</span>
<span id="deployed-units" class="text-2xl font-bold text-blue-600 dark:text-blue-400">--</span>
</div>
<div class="flex justify-between items-center">
<span class="text-gray-600 dark:text-gray-400">Benched</span>
<span id="benched-units" class="text-2xl font-bold text-gray-600 dark:text-gray-400">--</span>
</div>
<div class="border-t border-gray-200 dark:border-gray-700 pt-3 mt-3">
<p class="text-xs text-gray-500 dark:text-gray-500 mb-2 italic">Deployed Status:</p>
<div class="flex justify-between items-center mb-2">
<div class="flex items-center">
<span class="w-3 h-3 rounded-full bg-green-500 mr-2"></span>
@@ -176,14 +181,16 @@ function updateDashboard(event) {
// ===== Fleet summary numbers =====
document.getElementById('total-units').textContent = data.summary?.total ?? 0;
document.getElementById('deployed-units').textContent = data.summary?.active ?? 0;
document.getElementById('benched-units').textContent = data.summary?.benched ?? 0;
document.getElementById('status-ok').textContent = data.summary?.ok ?? 0;
document.getElementById('status-pending').textContent = data.summary?.pending ?? 0;
document.getElementById('status-missing').textContent = data.summary?.missing ?? 0;
// ===== Alerts =====
const alertsList = document.getElementById('alerts-list');
const missingUnits = Object.entries(data.units).filter(([_, u]) => u.status === 'Missing');
const pendingUnits = Object.entries(data.units).filter(([_, u]) => u.status === 'Pending');
// Only show alerts for deployed units (not benched)
const missingUnits = Object.entries(data.active).filter(([_, u]) => u.status === 'Missing');
const pendingUnits = Object.entries(data.active).filter(([_, u]) => u.status === 'Pending');
if (!missingUnits.length && !pendingUnits.length) {
alertsList.innerHTML =
@@ -243,6 +250,7 @@ document.addEventListener('DOMContentLoaded', function() {
let fleetMap = null;
let fleetMarkers = [];
let fleetMapInitialized = false;
function initFleetMap() {
// Initialize the map centered on the US (can adjust based on your deployment area)
@@ -262,8 +270,8 @@ function updateFleetMap(data) {
fleetMarkers.forEach(marker => fleetMap.removeLayer(marker));
fleetMarkers = [];
// Get deployed units with location data
const deployedUnits = Object.entries(data.units).filter(([_, u]) => u.deployed && u.location);
// Get deployed units with coordinates data
const deployedUnits = Object.entries(data.units).filter(([_, u]) => u.deployed && u.coordinates);
if (deployedUnits.length === 0) {
return;
@@ -272,7 +280,7 @@ function updateFleetMap(data) {
const bounds = [];
deployedUnits.forEach(([id, unit]) => {
const coords = parseLocation(unit.location);
const coords = parseLocation(unit.coordinates);
if (coords) {
const [lat, lon] = coords;
@@ -304,9 +312,10 @@ function updateFleetMap(data) {
}
});
// Fit map to show all markers
if (bounds.length > 0) {
// Fit map to show all markers only on first load
if (bounds.length > 0 && !fleetMapInitialized) {
fleetMap.fitBounds(bounds, { padding: [50, 50] });
fleetMapInitialized = true;
}
}