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>
|
2026-05-29 00:41:34 +00:00
|
|
|
<link rel="stylesheet" href="/vendor/maplibre-gl.css" />
|
2026-05-22 21:53:42 +00:00
|
|
|
<style>
|
|
|
|
|
:root {
|
|
|
|
|
--bg: #0f172a;
|
|
|
|
|
--panel: #1e293b;
|
2026-05-27 18:56:53 +00:00
|
|
|
--panel-2: #0b1220;
|
2026-05-22 21:53:42 +00:00
|
|
|
--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; }
|
2026-05-27 18:56:53 +00:00
|
|
|
|
|
|
|
|
body { display: grid; grid-template-rows: auto auto 1fr; min-height: 100%; }
|
|
|
|
|
|
|
|
|
|
/* ─────────── top header ─────────── */
|
2026-05-22 21:53:42 +00:00
|
|
|
header {
|
|
|
|
|
display: flex; align-items: center; justify-content: space-between;
|
2026-05-27 18:56:53 +00:00
|
|
|
padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--panel-2);
|
|
|
|
|
}
|
|
|
|
|
header h1 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
|
|
|
|
|
header .right { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--muted); }
|
|
|
|
|
button.logout {
|
|
|
|
|
background: transparent; color: var(--muted); border: 1px solid var(--muted);
|
|
|
|
|
padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 11px;
|
|
|
|
|
}
|
|
|
|
|
button.logout:hover { color: var(--text); border-color: var(--text); }
|
|
|
|
|
|
2026-05-27 19:14:24 +00:00
|
|
|
/* ─────────── top dashboard band: tiles + filters ─────────── */
|
2026-05-27 18:56:53 +00:00
|
|
|
.top-band {
|
|
|
|
|
display: grid;
|
2026-05-27 19:07:03 +00:00
|
|
|
grid-template-columns: minmax(260px,1fr) minmax(280px,auto);
|
2026-05-27 18:56:53 +00:00
|
|
|
gap: 16px;
|
|
|
|
|
padding: 10px 16px;
|
|
|
|
|
background: var(--panel);
|
|
|
|
|
border-bottom: 1px solid var(--panel-2);
|
|
|
|
|
}
|
|
|
|
|
.band-block { display: flex; flex-direction: column; gap: 4px; }
|
|
|
|
|
.band-title {
|
|
|
|
|
font-size: 10px; text-transform: uppercase; color: var(--muted);
|
|
|
|
|
letter-spacing: 0.08em; font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
.band-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
|
|
|
|
|
|
|
|
|
|
.tile {
|
|
|
|
|
background: var(--panel-2); padding: 4px 10px; border-radius: 4px;
|
|
|
|
|
min-width: 70px; display: flex; flex-direction: column; gap: 0;
|
|
|
|
|
}
|
|
|
|
|
.tile-label { font-size: 9px; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
|
|
|
|
|
.tile-value { font-size: 18px; font-weight: 600; line-height: 1.1; }
|
|
|
|
|
|
|
|
|
|
/* ─────────── multi-select filter widget ─────────── */
|
|
|
|
|
.ms { position: relative; min-width: 180px; }
|
|
|
|
|
.ms-btn {
|
|
|
|
|
width: 100%; display: flex; justify-content: space-between; align-items: center;
|
|
|
|
|
background: var(--panel-2); color: var(--text);
|
|
|
|
|
border: 1px solid var(--panel-2); border-radius: 4px;
|
|
|
|
|
padding: 6px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
|
|
|
|
|
}
|
|
|
|
|
.ms-btn:hover { border-color: var(--muted); }
|
|
|
|
|
.ms-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
|
|
|
.ms-caret { color: var(--muted); font-size: 10px; margin-left: 8px; }
|
|
|
|
|
.ms-pop {
|
|
|
|
|
position: absolute; top: calc(100% + 4px); left: 0; right: 0;
|
|
|
|
|
background: var(--panel); border: 1px solid var(--panel-2);
|
|
|
|
|
border-radius: 6px; padding: 6px; z-index: 20;
|
|
|
|
|
max-height: 320px; overflow-y: auto;
|
|
|
|
|
box-shadow: 0 12px 32px rgba(0,0,0,0.55);
|
|
|
|
|
}
|
|
|
|
|
.ms-row {
|
|
|
|
|
display: flex; align-items: center; gap: 8px;
|
|
|
|
|
padding: 5px 8px; border-radius: 3px; font-size: 12px; cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.ms-row:hover { background: var(--panel-2); }
|
|
|
|
|
.ms-row input[type="checkbox"] { margin: 0; accent-color: var(--accent); }
|
|
|
|
|
.ms-row-all { border-bottom: 1px solid var(--panel-2); margin-bottom: 4px; padding-bottom: 8px; }
|
|
|
|
|
.ms-swatch {
|
|
|
|
|
width: 10px; height: 10px; border-radius: 50%;
|
|
|
|
|
display: inline-block; flex-shrink: 0;
|
|
|
|
|
border: 1px solid rgba(0,0,0,0.3);
|
|
|
|
|
}
|
|
|
|
|
.ms-row-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
|
|
|
|
2026-05-29 15:00:39 +00:00
|
|
|
/* vehicle finder: single-select with a search box */
|
|
|
|
|
.ms-vehicle { min-width: 210px; }
|
|
|
|
|
.ms-search {
|
|
|
|
|
width: 100%; box-sizing: border-box; margin-bottom: 6px;
|
|
|
|
|
background: var(--panel-2); color: var(--text);
|
|
|
|
|
border: 1px solid var(--panel-2); border-radius: 4px;
|
|
|
|
|
padding: 6px 8px; font-size: 12px; font-family: inherit;
|
|
|
|
|
}
|
|
|
|
|
.ms-search:focus { outline: none; border-color: var(--muted); }
|
|
|
|
|
.ms-vehicle-row { justify-content: space-between; }
|
|
|
|
|
.ms-row-sub { color: var(--muted); font-size: 11px; margin-left: 8px; flex-shrink: 0; }
|
|
|
|
|
.ms-empty { padding: 8px; color: var(--muted); font-size: 12px; }
|
|
|
|
|
|
2026-05-27 18:56:53 +00:00
|
|
|
/* ─────────── map (fills remaining height) ─────────── */
|
|
|
|
|
#map-container { position: relative; min-height: 0; }
|
|
|
|
|
#map { position: absolute; inset: 0; }
|
|
|
|
|
|
|
|
|
|
/* ─────────── hover popup (unchanged) ─────────── */
|
2026-05-23 06:29:04 +00:00
|
|
|
.fleet-popup .maplibregl-popup-content {
|
2026-05-27 18:56:53 +00:00
|
|
|
background: var(--panel) !important; color: var(--text) !important;
|
|
|
|
|
padding: 14px 16px !important; border-radius: 8px !important;
|
2026-05-23 06:29:04 +00:00
|
|
|
min-width: 240px;
|
|
|
|
|
box-shadow: 0 12px 32px rgba(0,0,0,0.55);
|
2026-05-27 18:56:53 +00:00
|
|
|
border: 1px solid var(--panel-2);
|
2026-05-23 06:29:04 +00:00
|
|
|
}
|
|
|
|
|
.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; }
|
2026-05-27 18:56:53 +00:00
|
|
|
.popup-plate { font-size: 16px; font-weight: 700; }
|
2026-05-23 06:29:04 +00:00
|
|
|
.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-27 11:14:06 +00:00
|
|
|
|
2026-05-27 18:56:53 +00:00
|
|
|
/* ─────────── bottom trip panel (slides up) ─────────── */
|
|
|
|
|
.trip-dock {
|
|
|
|
|
position: absolute; left: 0; right: 0; bottom: 0;
|
|
|
|
|
background: var(--panel); border-top: 1px solid var(--panel-2);
|
2026-05-27 11:14:06 +00:00
|
|
|
color: var(--text);
|
2026-05-27 18:56:53 +00:00
|
|
|
display: grid; grid-template-rows: auto 1fr;
|
|
|
|
|
max-height: 60%;
|
|
|
|
|
transform: translateY(100%);
|
2026-05-27 11:14:06 +00:00
|
|
|
transition: transform 0.22s ease;
|
2026-05-27 18:56:53 +00:00
|
|
|
z-index: 3;
|
|
|
|
|
box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-dock.open { transform: translateY(0); }
|
|
|
|
|
.trip-dock-header {
|
|
|
|
|
display: flex; align-items: center; gap: 18px; padding: 10px 16px;
|
|
|
|
|
border-bottom: 1px solid var(--panel-2); flex-wrap: wrap;
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-id-block { display: flex; flex-direction: column; min-width: 160px; }
|
|
|
|
|
.trip-plate { font-size: 16px; font-weight: 700; }
|
2026-05-27 11:14:06 +00:00
|
|
|
.trip-driver { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-totals { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
|
|
|
|
|
.trip-totals strong { color: var(--text); font-weight: 600; }
|
|
|
|
|
.trip-quality { font-size: 10.5px; color: var(--muted); }
|
|
|
|
|
.trip-controls { display: flex; gap: 8px; align-items: center; margin-left: auto; }
|
|
|
|
|
.trip-controls label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; gap: 6px; align-items: center; }
|
2026-05-27 11:14:06 +00:00
|
|
|
.trip-controls input[type="date"] {
|
2026-05-27 18:56:53 +00:00
|
|
|
background: var(--panel-2); color: var(--text);
|
|
|
|
|
border: 1px solid var(--panel-2); border-radius: 4px;
|
|
|
|
|
padding: 4px 6px; font-size: 11px; font-family: inherit; color-scheme: dark;
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-csv, .trip-close {
|
2026-05-27 11:14:06 +00:00
|
|
|
background: transparent; color: var(--muted);
|
|
|
|
|
border: 1px solid var(--muted); border-radius: 4px;
|
2026-05-27 18:56:53 +00:00
|
|
|
padding: 4px 10px; cursor: pointer; font-size: 10px;
|
|
|
|
|
text-transform: uppercase; letter-spacing: 0.06em;
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-csv:hover, .trip-close:hover { color: var(--text); border-color: var(--text); }
|
|
|
|
|
|
|
|
|
|
.trip-list { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; }
|
2026-05-27 11:14:06 +00:00
|
|
|
.trip-list-empty { padding: 16px; color: var(--muted); font-size: 12.5px; }
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-card {
|
|
|
|
|
flex: 0 0 auto; min-width: 170px; max-width: 220px;
|
|
|
|
|
background: var(--panel-2); border-radius: 6px; padding: 10px 12px;
|
|
|
|
|
cursor: pointer; border-left: 3px solid transparent;
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-card:hover { background: #111a2c; }
|
2026-05-27 20:31:57 +00:00
|
|
|
/* Don't change border-left on selection — that's the per-trip colour swatch.
|
|
|
|
|
Use an outline instead so the trip colour stays readable. */
|
|
|
|
|
.trip-card.selected { background: #111a2c; outline: 2px solid var(--accent); outline-offset: 1px; }
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-card-top {
|
|
|
|
|
display: flex; justify-content: space-between; align-items: center;
|
|
|
|
|
font-size: 12.5px; font-weight: 600; margin-bottom: 4px;
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-card-times { font-size: 11px; color: var(--muted); }
|
|
|
|
|
.trip-card-meta {
|
|
|
|
|
display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 2px;
|
2026-05-27 11:14:06 +00:00
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-card-reason {
|
2026-05-27 11:14:06 +00:00
|
|
|
display: inline-block; margin-top: 6px;
|
2026-05-27 18:56:53 +00:00
|
|
|
font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
|
2026-05-27 11:14:06 +00:00
|
|
|
color: var(--muted);
|
|
|
|
|
}
|
2026-05-27 18:56:53 +00:00
|
|
|
.trip-card-reason.work-stop { color: var(--accent); }
|
|
|
|
|
.trip-card-reason.nofix-stop { color: var(--warn); }
|
|
|
|
|
.trip-card-reason.long-gap { color: var(--bad); }
|
2026-05-27 20:24:12 +00:00
|
|
|
.trip-vehicle-row { min-width: 200px; }
|
|
|
|
|
.trip-vehicle-remove {
|
|
|
|
|
background: transparent; color: var(--muted); border: 0;
|
|
|
|
|
font-size: 14px; cursor: pointer; padding: 0 4px; line-height: 1;
|
|
|
|
|
}
|
|
|
|
|
.trip-vehicle-remove:hover { color: var(--bad); }
|
2026-05-22 21:53:42 +00:00
|
|
|
</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>
|
2026-05-27 18:56:53 +00:00
|
|
|
|
|
|
|
|
<div class="top-band">
|
|
|
|
|
<div class="band-block">
|
|
|
|
|
<div class="band-title">Fleet now</div>
|
|
|
|
|
<div class="band-row" id="summary"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="band-block">
|
|
|
|
|
<div class="band-title">Filters</div>
|
|
|
|
|
<div class="band-row" id="filters">
|
2026-05-29 15:00:39 +00:00
|
|
|
<div id="flt-vehicle"></div>
|
2026-05-27 18:56:53 +00:00
|
|
|
<div id="flt-cost-centre"></div>
|
|
|
|
|
<div id="flt-assigned-city"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="map-container">
|
|
|
|
|
<div id="map"></div>
|
|
|
|
|
|
|
|
|
|
<aside id="trip-panel" class="trip-dock" aria-hidden="true">
|
|
|
|
|
<div class="trip-dock-header">
|
|
|
|
|
<div class="trip-id-block">
|
|
|
|
|
<span class="trip-plate" id="trip-plate">—</span>
|
|
|
|
|
<span class="trip-driver" id="trip-driver"></span>
|
2026-05-27 11:14:06 +00:00
|
|
|
</div>
|
2026-05-27 18:56:53 +00:00
|
|
|
<div class="trip-totals" id="trip-totals">Click a vehicle to see its trips.</div>
|
2026-05-27 11:14:06 +00:00
|
|
|
<div class="trip-controls">
|
|
|
|
|
<label>Date <input type="date" id="trip-date" /></label>
|
|
|
|
|
<button class="trip-csv" id="trip-csv" type="button">CSV</button>
|
2026-05-27 18:56:53 +00:00
|
|
|
<button class="trip-close" id="trip-close" type="button" aria-label="Close trip panel">Close</button>
|
2026-05-27 11:14:06 +00:00
|
|
|
</div>
|
2026-05-27 18:56:53 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="trip-list" id="trip-list"></div>
|
|
|
|
|
</aside>
|
|
|
|
|
</div>
|
2026-05-22 21:53:42 +00:00
|
|
|
|
2026-05-29 00:41:34 +00:00
|
|
|
<script src="/vendor/maplibre-gl.js"></script>
|
2026-05-22 21:53:42 +00:00
|
|
|
<script type="module">
|
2026-05-27 18:56:53 +00:00
|
|
|
import {
|
|
|
|
|
authClient, apiFetch, initMap, renderView,
|
|
|
|
|
initFilters, applyClientFilter, initTripPanel, clockEAT,
|
|
|
|
|
} from '/fleet-core.js';
|
2026-05-22 21:53:42 +00:00
|
|
|
|
|
|
|
|
if (!authClient.requireSession()) { /* redirected */ }
|
|
|
|
|
|
|
|
|
|
window.fleetLogout = () => { authClient.logout(); window.location.href = '/login.html'; };
|
|
|
|
|
|
|
|
|
|
clockEAT('clock');
|
|
|
|
|
|
|
|
|
|
const map = initMap('map');
|
|
|
|
|
const summaryEl = document.getElementById('summary');
|
|
|
|
|
let currentFilters = {};
|
2026-05-27 18:56:53 +00:00
|
|
|
let activeSelection = { costCentres: [], cities: [] };
|
2026-05-22 21:53:42 +00:00
|
|
|
|
|
|
|
|
async function refresh() {
|
|
|
|
|
try {
|
|
|
|
|
const params = Object.keys(currentFilters).length ? { filters: currentFilters } : {};
|
|
|
|
|
const payload = await apiFetch('/api/views/live', { params });
|
2026-05-27 19:07:03 +00:00
|
|
|
renderView(map, payload, { summaryRoot: summaryEl });
|
2026-05-27 18:56:53 +00:00
|
|
|
// Repopulate filter dropdowns from the latest features
|
|
|
|
|
const features = (payload.geojson && payload.geojson.features) || [];
|
|
|
|
|
filters.updateOptions(features);
|
|
|
|
|
applyClientFilter(map, activeSelection);
|
2026-05-22 21:53:42 +00:00
|
|
|
} catch (err) {
|
|
|
|
|
console.error('refresh.failed', err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-29 15:00:39 +00:00
|
|
|
const tripApi = initTripPanel(map, document.getElementById('trip-panel'));
|
2026-05-22 21:53:42 +00:00
|
|
|
|
2026-05-29 15:00:39 +00:00
|
|
|
const filters = initFilters(
|
|
|
|
|
document.getElementById('filters'),
|
|
|
|
|
(serverFilters, selection) => {
|
|
|
|
|
currentFilters = serverFilters;
|
|
|
|
|
activeSelection = selection;
|
|
|
|
|
refresh();
|
|
|
|
|
},
|
|
|
|
|
// Vehicle picked from the finder → its cost-centre/city filters are set by
|
|
|
|
|
// initFilters; here we locate it on the map and open its trips.
|
|
|
|
|
(meta) => { tripApi.openVehicle(meta.vehicle_id, meta); },
|
|
|
|
|
);
|
2026-05-27 11:14:06 +00:00
|
|
|
|
2026-05-22 21:53:42 +00:00
|
|
|
refresh();
|
|
|
|
|
setInterval(refresh, 15000);
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|