diff --git a/static/css/style.css b/static/css/style.css index 9ac3dd9..43426f3 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -16,7 +16,31 @@ font-size: 0.9rem; } -/* Drive cards styling */ +/* Drive selector cards */ +.drive-selector-card { + transition: all 0.2s ease; +} + +.drive-selector-card .btn-check:checked + .btn { + background-color: #e7f1ff; + border-color: #0d6efd; + box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25); +} + +.drive-selector-card .btn { + border-radius: 0.5rem; + padding: 1rem; +} + +.drive-selector-card .btn:hover { + background-color: #f8f9fa; +} + +.drive-selector-card .btn-check:checked + .btn:hover { + background-color: #e7f1ff; +} + +/* General drive cards */ .drive-card { transition: all 0.3s ease; height: 100%; diff --git a/static/js/main.js b/static/js/main.js index 00cdbab..f88e68f 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -3,6 +3,9 @@ * Handles HTMX events and dynamic content rendering */ +// Global state +let selectedDrive = null; + // Render drives after HTMX loads them function renderDrives(data) { const container = document.getElementById('drives-content'); @@ -45,16 +48,117 @@ function renderDrives(data) { }); } +// Render drive selector for benchmark tab (available drives only) +function renderDriveSelector(data) { + const container = document.getElementById('drive-cards'); + if (!container) return; + + container.innerHTML = ''; + + if (!data.drives || data.drives.length === 0) { + container.innerHTML = '
No drives found.
Drive ${drive.name} selected. Configure benchmark parameters below.
+ + `; + } +} + // Listen for HTMX events document.addEventListener('htmx:afterRequest', function(evt) { + // Render drives in home page if (evt.detail.target.id === 'drives-content') { renderDrives(JSON.parse(evt.detail.xhr.response)); } + + // Render drive selector in benchmark page + if (evt.detail.target.id === 'drive-cards') { + renderDriveSelector(JSON.parse(evt.detail.xhr.response)); + } }); -// Optional: Listen for HTMX load event as fallback +// Listen for HTMX load event as fallback document.addEventListener('htmx:load', function(evt) { - if (evt.target.id === 'drives-content') { + if (evt.target.id === 'drive-cards') { // HTMX will load the content via hx-get // The afterRequest event will handle rendering } diff --git a/templates/benchmark.html b/templates/benchmark.html index 92b1047..2f6d600 100644 --- a/templates/benchmark.html +++ b/templates/benchmark.html @@ -8,16 +8,43 @@Configure and run disk benchmarks.
- -Choose a drive to benchmark from the list below.
+Choose an available drive from the list below.
- - + +Select a drive above to configure benchmark parameters.