diff --git a/app.py b/app.py index 7034a5c..48af551 100644 --- a/app.py +++ b/app.py @@ -210,6 +210,13 @@ def data(): response.content_type = 'application/json' return response +@app.route('/api/dtc') +def api_dtc(): + return jsonify({ + "mil": app_obd.get_fresh_mil(), + "codes": app_obd.get_fresh_dtc_codes(), + }) + if __name__ == '__main__': # Debug/Development # app.run(debug=True, host="0.0.0.0", port="5000") diff --git a/static/js/theme.js b/static/js/theme.js index d06b9ce..a35d786 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -1,76 +1,30 @@ -(function() { - "use strict"; // Start of use strict +(function () { + 'use strict'; - var sidebar = document.querySelector('.sidebar'); - var sidebarToggles = document.querySelectorAll('#sidebarToggle, #sidebarToggleTop'); - - if (sidebar) { - - var collapseEl = sidebar.querySelector('.collapse'); - var collapseElementList = [].slice.call(document.querySelectorAll('.sidebar .collapse')) - var sidebarCollapseList = collapseElementList.map(function (collapseEl) { - return new bootstrap.Collapse(collapseEl, { toggle: false }); - }); + const COLLAPSED_KEY = 'sidebar-collapsed'; + const sidebar = document.getElementById('app-sidebar'); + const contentWrapper = document.getElementById('content-wrapper'); + const toggleBtn = document.getElementById('sidebarToggle'); - for (var toggle of sidebarToggles) { + if (!sidebar) return; - // Toggle the side navigation - toggle.addEventListener('click', function(e) { - document.body.classList.toggle('sidebar-toggled'); - sidebar.classList.toggle('toggled'); - - if (sidebar.classList.contains('toggled')) { - for (var bsCollapse of sidebarCollapseList) { - bsCollapse.hide(); - } - }; - }); + function applyCollapsed(collapsed) { + sidebar.classList.toggle('collapsed', collapsed); + contentWrapper.classList.toggle('sidebar-collapsed', collapsed); + const icon = toggleBtn && toggleBtn.querySelector('i'); + if (icon) { + icon.className = collapsed ? 'fas fa-chevron-right' : 'fas fa-chevron-left'; + } } - // Close any open menu accordions when window is resized below 768px - window.addEventListener('resize', function() { - var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); + // Restore saved state + applyCollapsed(localStorage.getItem(COLLAPSED_KEY) === '1'); - if (vw < 768) { - for (var bsCollapse of sidebarCollapseList) { - bsCollapse.hide(); - } - }; - }); - } - - // Prevent the content wrapper from scrolling when the fixed side navigation hovered over - - var fixedNaigation = document.querySelector('body.fixed-nav .sidebar'); - - if (fixedNaigation) { - fixedNaigation.on('mousewheel DOMMouseScroll wheel', function(e) { - var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); - - if (vw > 768) { - var e0 = e.originalEvent, - delta = e0.wheelDelta || -e0.detail; - this.scrollTop += (delta < 0 ? 1 : -1) * 30; - e.preventDefault(); - } - }); - } - - var scrollToTop = document.querySelector('.scroll-to-top'); - - if (scrollToTop) { - - // Scroll to top button appear - window.addEventListener('scroll', function() { - var scrollDistance = window.pageYOffset; - - //check if user is scrolling up - if (scrollDistance > 100) { - scrollToTop.style.display = 'block'; - } else { - scrollToTop.style.display = 'none'; - } - }); - } - -})(); // End of use strict + if (toggleBtn) { + toggleBtn.addEventListener('click', function () { + const nowCollapsed = !sidebar.classList.contains('collapsed'); + applyCollapsed(nowCollapsed); + localStorage.setItem(COLLAPSED_KEY, nowCollapsed ? '1' : '0'); + }); + } +})(); diff --git a/static/js/yaris.js b/static/js/yaris.js index d19efe1..3213cce 100644 --- a/static/js/yaris.js +++ b/static/js/yaris.js @@ -94,6 +94,21 @@ socket.on('obd_rpm', function(data) { status.innerHTML = data; }); +socket.on('obd_coolant_temp', function(data) { + const el = document.getElementById('obd-coolant'); + if (el) el.textContent = data != null ? data + ' °C' : '—'; +}); + +socket.on('obd_fuel_level', function(data) { + const el = document.getElementById('obd-fuel'); + if (el) el.textContent = data != null ? data + ' %' : '—'; +}); + +socket.on('obd_throttle', function(data) { + const el = document.getElementById('obd-throttle'); + if (el) el.textContent = data != null ? data + ' %' : '—'; +}); + socket.on('obd_error', function(data) { console.log("obd errors "+data); const status = document.getElementById('obd-error'); diff --git a/static/yaris.css b/static/yaris.css index d7ff0d5..cfa41cd 100644 --- a/static/yaris.css +++ b/static/yaris.css @@ -1,3 +1,216 @@ +/* ── Layout ──────────────────────────────────────────────────────────────── */ + +:root { + --sidebar-width: 14rem; + --sidebar-collapsed-width: 4rem; + --topbar-height: 3.5rem; + --sidebar-bg: #1a1a2e; + --sidebar-hover: rgba(255,255,255,.08); + --sidebar-active: rgba(255,255,255,.15); + --primary: #4e73df; +} + +body { + background: #f4f6fb; + min-height: 100vh; +} + +/* Desktop sidebar */ +.app-sidebar { + position: fixed; + top: 0; + left: 0; + width: var(--sidebar-width); + height: 100vh; + background: var(--sidebar-bg); + color: #fff; + display: flex; + flex-direction: column; + transition: width .2s ease; + z-index: 1040; + overflow: hidden; +} + +.app-sidebar.collapsed { + width: var(--sidebar-collapsed-width); +} + +.sidebar-brand { + display: flex; + align-items: center; + gap: .75rem; + padding: 1.25rem 1rem; + color: #fff; + text-decoration: none; + white-space: nowrap; + flex-shrink: 0; +} + +.sidebar-brand:hover { color: rgba(255,255,255,.85); } + +.sidebar-brand-icon { + font-size: 1.25rem; + flex-shrink: 0; + width: 2rem; + text-align: center; +} + +.sidebar-brand-text { + font-weight: 700; + font-size: .95rem; + letter-spacing: .02em; + transition: opacity .15s; +} + +.app-sidebar.collapsed .sidebar-brand-text, +.app-sidebar.collapsed .nav-link span { + opacity: 0; + pointer-events: none; + width: 0; + overflow: hidden; +} + +.sidebar-divider { + border-color: rgba(255,255,255,.15); + margin: 0 1rem .5rem; +} + +.app-sidebar .nav-link { + display: flex; + align-items: center; + gap: .75rem; + padding: .65rem 1rem; + color: rgba(255,255,255,.7); + white-space: nowrap; + border-radius: .375rem; + margin: .1rem .5rem; + transition: background .15s, color .15s; +} + +.app-sidebar .nav-link:hover { + color: #fff; + background: var(--sidebar-hover); +} + +.app-sidebar .nav-link.active { + color: #fff; + background: var(--sidebar-active); + font-weight: 600; +} + +.app-sidebar .nav-link .fa-fw { + flex-shrink: 0; + width: 1.25rem; + text-align: center; +} + +.sidebar-collapse-btn { + background: none; + border: none; + color: rgba(255,255,255,.5); + padding: .75rem 1rem; + text-align: right; + cursor: pointer; + transition: color .15s, transform .2s; + margin-top: auto; + flex-shrink: 0; +} + +.sidebar-collapse-btn:hover { color: #fff; } + +.app-sidebar.collapsed .sidebar-collapse-btn { + text-align: center; + transform: rotate(180deg); +} + +/* Content wrapper shifts right on desktop */ +#content-wrapper { + margin-left: var(--sidebar-width); + min-height: 100vh; + display: flex; + flex-direction: column; + transition: margin-left .2s ease; +} + +#content-wrapper.sidebar-collapsed { + margin-left: var(--sidebar-collapsed-width); +} + +/* Top bar */ +.topbar { + height: var(--topbar-height); + position: sticky; + top: 0; + z-index: 1030; + border-bottom: 1px solid rgba(0,0,0,.06); +} + +.main-content { + flex: 1; + /* on mobile, leave room for the bottom nav */ + padding-bottom: 5rem; +} + +/* ── Mobile bottom navigation ─────────────────────────────────────────────── */ + +.mobile-bottom-nav { + position: fixed; + bottom: 0; + left: 0; + right: 0; + height: 3.75rem; + background: #fff; + border-top: 1px solid rgba(0,0,0,.1); + z-index: 1040; + box-shadow: 0 -2px 8px rgba(0,0,0,.08); +} + +.mobile-nav-item { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: .2rem; + color: #6c757d; + text-decoration: none; + font-size: .6rem; + font-weight: 500; + padding: .25rem 0; + transition: color .15s; + -webkit-tap-highlight-color: transparent; +} + +.mobile-nav-item i { + font-size: 1.1rem; + line-height: 1; +} + +.mobile-nav-item.active { + color: var(--primary); +} + +.mobile-nav-item:hover { + color: var(--primary); +} + +@media (max-width: 767.98px) { + #content-wrapper { + margin-left: 0 !important; + } + .main-content { + padding-bottom: 5rem; + } +} + +@media (min-width: 768px) { + .main-content { + padding-bottom: 1.5rem; + } +} + +/* ── Maps ────────────────────────────────────────────────────────────────── */ + #map { height: 20rem; } #history-map { @@ -5,15 +218,14 @@ min-height: 24rem; } +/* ── Alert dropdown ──────────────────────────────────────────────────────── */ + #alert-menu { min-width: min(22rem, calc(100vw - 2rem)); max-width: calc(100vw - 2rem); } -.app-sidebar { - color: var(--bs-accordion-btn-focus-border-color); - background: #000; -} +/* ── Data table ──────────────────────────────────────────────────────────── */ .data-list { min-height: 10rem; @@ -49,6 +261,8 @@ justify-content: flex-end; } +/* ── Dashcam / video ─────────────────────────────────────────────────────── */ + .local-video-thumbnail { width: 8rem; aspect-ratio: 16 / 9; @@ -63,4 +277,22 @@ width: 100%; max-height: 70vh; background: #000; -} \ No newline at end of file +} + +/* ── OBD stat cards ──────────────────────────────────────────────────────── */ + +.stat-card-icon { + font-size: 1.75rem; + opacity: .2; +} + +/* ── Misc ────────────────────────────────────────────────────────────────── */ + +.border-start-primary { border-left: .25rem solid var(--primary) !important; } +.border-start-success { border-left: .25rem solid #1cc88a !important; } +.border-start-info { border-left: .25rem solid #36b9cc !important; } +.border-start-warning { border-left: .25rem solid #f6c23e !important; } +.border-start-danger { border-left: .25rem solid #e74a3b !important; } + +.text-xs { font-size: .75rem; } +.text-gray-300 { color: #dddfeb !important; } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index c1c40bd..b2627a7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -12,85 +12,111 @@
-