2026-05-22 21:53:42 +00:00
|
|
|
<!doctype html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
|
<title>Live Fleet · rahamafresh</title>
|
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css" />
|
|
|
|
|
<style>
|
|
|
|
|
:root {
|
|
|
|
|
--bg: #0f172a;
|
|
|
|
|
--panel: #1e293b;
|
|
|
|
|
--text: #f1f5f9;
|
|
|
|
|
--muted: #94a3b8;
|
|
|
|
|
--accent: #10b981;
|
|
|
|
|
--warn: #f59e0b;
|
|
|
|
|
--bad: #ef4444;
|
|
|
|
|
}
|
|
|
|
|
* { box-sizing: border-box; }
|
|
|
|
|
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
|
|
|
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
|
|
|
|
|
body { display: grid; grid-template-rows: auto 1fr; }
|
|
|
|
|
header {
|
|
|
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
|
|
|
padding: 10px 16px; background: var(--panel); border-bottom: 1px solid #0b1220;
|
|
|
|
|
}
|
|
|
|
|
header h1 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
|
|
|
|
|
header .right { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--muted); }
|
|
|
|
|
main { display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
|
|
|
|
|
aside { padding: 12px; overflow: auto; border-right: 1px solid #0b1220; background: var(--panel); }
|
|
|
|
|
#map { width: 100%; height: 100%; }
|
|
|
|
|
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
|
|
|
|
|
.tile { background: #0b1220; padding: 10px; border-radius: 6px; }
|
|
|
|
|
.tile-label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
|
|
|
|
|
.tile-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
|
|
|
|
|
h3 { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; letter-spacing: 0.06em; }
|
|
|
|
|
.slo { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; padding: 6px 8px; border-radius: 4px; font-size: 12px; margin-bottom: 4px; background: #0b1220; }
|
|
|
|
|
.slo-name { color: var(--muted); }
|
|
|
|
|
.slo-status { text-transform: uppercase; font-size: 10px; letter-spacing: 0.06em; }
|
|
|
|
|
.slo-green .slo-status { color: var(--accent); }
|
|
|
|
|
.slo-red .slo-status { color: var(--bad); }
|
|
|
|
|
.slo-unknown .slo-status { color: var(--muted); }
|
|
|
|
|
.slo-empty { color: var(--muted); font-size: 12px; }
|
2026-05-23 06:29:04 +00:00
|
|
|
|
|
|
|
|
/* hover popup matching the dark theme */
|
|
|
|
|
.fleet-popup .maplibregl-popup-content {
|
|
|
|
|
background: #1e293b !important;
|
|
|
|
|
color: var(--text) !important;
|
|
|
|
|
padding: 14px 16px !important;
|
|
|
|
|
border-radius: 8px !important;
|
|
|
|
|
min-width: 240px;
|
|
|
|
|
box-shadow: 0 12px 32px rgba(0,0,0,0.55);
|
|
|
|
|
border: 1px solid #0b1220;
|
|
|
|
|
}
|
|
|
|
|
.fleet-popup .maplibregl-popup-tip { display: none; }
|
|
|
|
|
.popup-card { font-family: inherit; }
|
|
|
|
|
.popup-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
|
|
|
|
|
.popup-plate { font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
|
|
|
|
|
.popup-pill {
|
|
|
|
|
font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
|
|
|
|
|
padding: 3px 8px; border-radius: 4px; font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
.pill-moving { background: rgba(16,185,129,0.18); color: var(--accent); }
|
|
|
|
|
.pill-parked { background: rgba(148,163,184,0.15); color: var(--muted); }
|
|
|
|
|
.pill-offline { background: rgba(148,163,184,0.15); color: var(--muted); }
|
|
|
|
|
.pill-unknown { background: rgba(148,163,184,0.15); color: var(--muted); }
|
2026-05-23 20:13:46 +00:00
|
|
|
.popup-driver { color: var(--text); font-size: 13.5px; margin: 4px 0 2px; font-weight: 500; }
|
2026-05-23 20:06:25 +00:00
|
|
|
.popup-meta { color: var(--muted); font-size: 12px; margin: 2px 0 4px; }
|
|
|
|
|
.popup-address { color: var(--text); font-size: 13.5px; margin: 6px 0 8px; font-weight: 500; }
|
2026-05-23 06:29:04 +00:00
|
|
|
.popup-row { color: #cbd5e1; font-size: 12.5px; margin: 4px 0; }
|
2026-05-22 21:53:42 +00:00
|
|
|
form.filters { display: grid; gap: 8px; }
|
|
|
|
|
form.filters input, form.filters select { width: 100%; background: #0b1220; color: var(--text); border: 1px solid #0b1220; border-radius: 4px; padding: 6px 8px; font-size: 12px; }
|
|
|
|
|
form.filters label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.06em; }
|
|
|
|
|
button.logout { background: transparent; color: var(--muted); border: 1px solid var(--muted); padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
|
|
|
|
|
button.logout:hover { color: var(--text); border-color: var(--text); }
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<header>
|
|
|
|
|
<h1>fleet-platform · live</h1>
|
|
|
|
|
<div class="right">
|
|
|
|
|
<span id="clock"></span>
|
|
|
|
|
<button class="logout" onclick="window.fleetLogout()">Sign out</button>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
<main>
|
|
|
|
|
<aside>
|
|
|
|
|
<h3>Fleet now</h3>
|
|
|
|
|
<div id="summary" class="tile-grid"></div>
|
|
|
|
|
|
|
|
|
|
<h3>SLOs</h3>
|
|
|
|
|
<div id="slos"></div>
|
|
|
|
|
|
|
|
|
|
<h3>Filters</h3>
|
|
|
|
|
<form class="filters" id="filters">
|
|
|
|
|
<label for="f-cost">Cost centre</label>
|
|
|
|
|
<input id="f-cost" name="cost_centre" placeholder="e.g. Nairobi-North" />
|
|
|
|
|
<label for="f-city">Assigned city</label>
|
|
|
|
|
<input id="f-city" name="assigned_city" placeholder="e.g. Nairobi" />
|
|
|
|
|
</form>
|
|
|
|
|
</aside>
|
|
|
|
|
<div id="map"></div>
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<script src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
|
|
|
|
|
<script type="module">
|
|
|
|
|
import { authClient, apiFetch, initMap, renderView, initFilters, clockEAT } from '/fleet-core.js';
|
|
|
|
|
|
|
|
|
|
if (!authClient.requireSession()) { /* redirected */ }
|
|
|
|
|
|
|
|
|
|
window.fleetLogout = () => { authClient.logout(); window.location.href = '/login.html'; };
|
|
|
|
|
|
|
|
|
|
clockEAT('clock');
|
|
|
|
|
|
|
|
|
|
const map = initMap('map');
|
|
|
|
|
const summaryEl = document.getElementById('summary');
|
|
|
|
|
const slosEl = document.getElementById('slos');
|
|
|
|
|
let currentFilters = {};
|
|
|
|
|
|
|
|
|
|
async function refresh() {
|
|
|
|
|
try {
|
|
|
|
|
const params = Object.keys(currentFilters).length ? { filters: currentFilters } : {};
|
|
|
|
|
const payload = await apiFetch('/api/views/live', { params });
|
|
|
|
|
renderView(map, payload, { summaryRoot: summaryEl, sloRoot: slosEl });
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('refresh.failed', err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initFilters(document.getElementById('filters'), (filters) => {
|
|
|
|
|
currentFilters = filters;
|
|
|
|
|
refresh();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
setInterval(refresh, 15000);
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|