- Replace 8-point scatter chart with proper 60-point line chart
- Blue gradient fill (rgba 35%→2%), tension 0.4 smooth curve
- No legend (obvious), no X axis grid, soft Y axis gridlines
- Y axis auto-scales: max(60, sessionMax*1.2) rounded to 10s
- Ticks: '0 km/h' labels on Y, time strings on X (max 6)
- chart.update('none') for live updates (no animation stutter)
- Speed history card header now shows current speed + session max
even when the graph is collapsed
- Footer bar inside expanded graph: session avg, point count, last reading time
- makeGradient() refreshed on every update in case canvas was resized
- obd_rpm now appends ' rpm' to the displayed value
Co-authored-by: Copilot <[email protected]>
168 lines
8.5 KiB
HTML
168 lines
8.5 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Dashboard - Yaris OBD{% endblock %}
|
|
|
|
{% block styles %}
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='vendor/leaflet/leaflet.css') }}">
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<h3 class="text-dark mb-3 fw-bold">Dashboard</h3>
|
|
|
|
{# ── OBD stat cards ──────────────────────────────────────────────────── #}
|
|
<div class="row g-2 mb-3">
|
|
<div class="col-6 col-sm-4 col-xl-2">
|
|
<div class="card shadow-sm border-start-primary h-100">
|
|
<div class="card-body py-2 px-3">
|
|
<div class="text-uppercase text-primary fw-bold text-xs mb-1">OBD</div>
|
|
<div id="obd-status" class="fw-bold mb-0 text-dark obd-val">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 col-sm-4 col-xl-2">
|
|
<div class="card shadow-sm border-start-success h-100">
|
|
<div class="card-body py-2 px-3">
|
|
<div class="text-uppercase text-success fw-bold text-xs mb-1">Speed</div>
|
|
<div id="obd-speed" class="fw-bold h5 mb-0 text-dark">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 col-sm-4 col-xl-2">
|
|
<div class="card shadow-sm border-start-info h-100">
|
|
<div class="card-body py-2 px-3">
|
|
<div class="text-uppercase text-info fw-bold text-xs mb-1">RPM</div>
|
|
<div id="obd-rpm" class="fw-bold h5 mb-0 text-dark">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 col-sm-4 col-xl-2">
|
|
<div class="card shadow-sm border-start-warning h-100">
|
|
<div class="card-body py-2 px-3">
|
|
<div class="text-uppercase text-warning fw-bold text-xs mb-1">Coolant</div>
|
|
<div id="obd-coolant" class="fw-bold h5 mb-0 text-dark">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 col-sm-4 col-xl-2">
|
|
<div class="card shadow-sm border-start-danger h-100">
|
|
<div class="card-body py-2 px-3">
|
|
<div class="text-uppercase text-danger fw-bold text-xs mb-1">Throttle</div>
|
|
<div id="obd-throttle" class="fw-bold h5 mb-0 text-dark">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 col-sm-4 col-xl-2">
|
|
<div class="card shadow-sm border-start-primary h-100">
|
|
<div class="card-body py-2 px-3">
|
|
<div class="text-uppercase text-primary fw-bold text-xs mb-1">Fuel</div>
|
|
<div id="obd-fuel" class="fw-bold h5 mb-0 text-dark">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# ── Pi health ───────────────────────────────────────────────────────── #}
|
|
<div class="card shadow-sm mb-3" id="pi-health-card">
|
|
<div class="card-header d-flex flex-wrap justify-content-between align-items-center gap-2 py-2">
|
|
<h6 class="text-primary fw-bold m-0">Pi health</h6>
|
|
<span id="pi-health-updated" class="small text-muted">Loading…</span>
|
|
</div>
|
|
<div class="card-body py-2">
|
|
<div id="pi-health-warning" class="alert alert-warning py-2 mb-2" role="alert" hidden></div>
|
|
<div id="pi-health-error" class="alert alert-danger py-2 mb-2" role="alert" hidden></div>
|
|
<div class="row g-2">
|
|
<div class="col-6 col-lg-3">
|
|
<div class="text-uppercase text-muted fw-bold text-xs mb-1">CPU temp</div>
|
|
<div id="pi-temperature" class="h6 text-dark fw-bold mb-0">--</div>
|
|
</div>
|
|
<div class="col-6 col-lg-3">
|
|
<div class="text-uppercase text-muted fw-bold text-xs mb-1">Memory</div>
|
|
<div id="pi-memory" class="h6 text-dark fw-bold mb-0">--</div>
|
|
</div>
|
|
<div class="col-6 col-lg-3">
|
|
<div class="text-uppercase text-muted fw-bold text-xs mb-1">Disk</div>
|
|
<div id="pi-disk" class="h6 text-dark fw-bold mb-0">--</div>
|
|
</div>
|
|
<div class="col-6 col-lg-3">
|
|
<div class="text-uppercase text-muted fw-bold text-xs mb-1">Uptime</div>
|
|
<div id="pi-uptime" class="h6 text-dark fw-bold mb-0">--</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# ── GPS map (with inline coords footer) ─────────────────────────────── #}
|
|
<div class="row g-3 mb-3">
|
|
<div class="col-lg-5 col-xl-4">
|
|
<div class="card shadow-sm h-100">
|
|
<div class="card-header py-2">
|
|
<h6 class="text-primary fw-bold m-0">Live GPS</h6>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div id="map"></div>
|
|
</div>
|
|
<div class="card-footer py-2 d-flex gap-4 bg-white border-top">
|
|
<div>
|
|
<div class="text-xs text-muted fw-bold text-uppercase">Lat</div>
|
|
<div id="gpsLocationX" class="fw-semibold small">—</div>
|
|
</div>
|
|
<div>
|
|
<div class="text-xs text-muted fw-bold text-uppercase">Lon</div>
|
|
<div id="gpsLocationY" class="fw-semibold small">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-7 col-xl-8">
|
|
<div class="card shadow-sm h-100">
|
|
<div class="card-header py-2 d-flex align-items-center gap-3">
|
|
<h6 class="text-primary fw-bold m-0 me-auto">Speed history</h6>
|
|
{# Live speed badge — visible even when graph is collapsed #}
|
|
<span class="text-xs text-muted fw-bold text-uppercase">Now</span>
|
|
<span id="speed-now-badge" class="fw-bold text-dark" style="min-width:3.5rem;text-align:right;">—</span>
|
|
<span class="text-xs text-muted fw-bold text-uppercase ms-2">Max</span>
|
|
<span id="speed-max-badge" class="fw-bold text-danger" style="min-width:3.5rem;text-align:right;">—</span>
|
|
<button class="btn btn-link btn-sm p-0 text-muted ms-2" id="speed-graph-toggle" type="button"
|
|
aria-expanded="false" aria-controls="speed-graph-body">
|
|
<i class="fas fa-chevron-down"></i>
|
|
</button>
|
|
</div>
|
|
<div class="collapse" id="speed-graph-body">
|
|
<div class="card-body pb-2 pt-3 px-3">
|
|
<canvas id="speedGraph" style="height:13rem;"></canvas>
|
|
</div>
|
|
<div class="card-footer py-2 d-flex gap-4 bg-white border-top small text-muted">
|
|
<div><span class="fw-bold text-uppercase" style="font-size:.65rem;">Avg (session)</span> <span id="speed-avg-badge" class="text-dark fw-semibold">—</span></div>
|
|
<div><span class="fw-bold text-uppercase" style="font-size:.65rem;">Points</span> <span id="speed-points-badge" class="text-dark fw-semibold">0</span></div>
|
|
<div class="ms-auto"><span id="speed-last-time" class="text-muted" style="font-size:.7rem;"></span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script src="{{ url_for('static', filename='js/chart.min.js') }}"></script>
|
|
<script src="{{ url_for('static', filename='vendor/socketio/socket.io.min.js') }}"></script>
|
|
<script src="{{ url_for('static', filename='vendor/leaflet/leaflet.js') }}"></script>
|
|
<script src="{{ url_for('static', filename='js/yaris.js') }}"></script>
|
|
<script>
|
|
// Speed graph toggle
|
|
(function () {
|
|
const btn = document.getElementById('speed-graph-toggle');
|
|
const body = document.getElementById('speed-graph-body');
|
|
if (!btn || !body) return;
|
|
const bsCollapse = new bootstrap.Collapse(body, {toggle: false});
|
|
body.addEventListener('show.bs.collapse', function () {
|
|
btn.setAttribute('aria-expanded', 'true');
|
|
btn.querySelector('i').className = 'fas fa-chevron-up';
|
|
});
|
|
body.addEventListener('hide.bs.collapse', function () {
|
|
btn.setAttribute('aria-expanded', 'false');
|
|
btn.querySelector('i').className = 'fas fa-chevron-down';
|
|
});
|
|
btn.addEventListener('click', function () { bsCollapse.toggle(); });
|
|
})();
|
|
</script>
|
|
{% endblock %} |