fix(frontend): add clearDriveSelection() function for undoing drive selection
- Add clearDriveSelection() to reset UI state and uncheck radio buttons - Show clear selection button when drive is selected - Fixes issue #1: undo disk selection
This commit was merged in pull request #4.
This commit is contained in:
@@ -132,6 +132,12 @@ function selectDrive(drive) {
|
||||
`;
|
||||
}
|
||||
|
||||
// Show clear selection button
|
||||
const clearContainer = document.getElementById('clear-selection-container');
|
||||
if (clearContainer) {
|
||||
clearContainer.style.display = 'block';
|
||||
}
|
||||
|
||||
// Enable benchmark configuration section
|
||||
const configDiv = document.getElementById('benchmark-config');
|
||||
if (configDiv) {
|
||||
@@ -143,6 +149,44 @@ function selectDrive(drive) {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle drive deselection (clear selection)
|
||||
function clearDriveSelection() {
|
||||
selectedDrive = null;
|
||||
console.log('Cleared drive selection');
|
||||
|
||||
// Clear selected drive info
|
||||
const infoDiv = document.getElementById('selected-drive-info');
|
||||
if (infoDiv) {
|
||||
infoDiv.innerHTML = '';
|
||||
}
|
||||
|
||||
// Hide clear selection button
|
||||
const clearContainer = document.getElementById('clear-selection-container');
|
||||
if (clearContainer) {
|
||||
clearContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
// Disable benchmark configuration section
|
||||
const configDiv = document.getElementById('benchmark-config');
|
||||
if (configDiv) {
|
||||
configDiv.classList.add('opacity-50');
|
||||
configDiv.querySelector('.card-body').innerHTML = `
|
||||
<p class="text-muted">Select a drive above to configure benchmark parameters.</p>
|
||||
`;
|
||||
}
|
||||
|
||||
// Uncheck all radio buttons
|
||||
const radios = document.querySelectorAll('input[name="selected_drive"]');
|
||||
radios.forEach(radio => { radio.checked = false; });
|
||||
}
|
||||
|
||||
// Listen for clear selection button click
|
||||
document.addEventListener('click', function(evt) {
|
||||
if (evt.target.id === 'clear-selection-btn' || evt.target.closest('#clear-selection-btn')) {
|
||||
clearDriveSelection();
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for HTMX events
|
||||
document.addEventListener('htmx:afterRequest', function(evt) {
|
||||
// Render drives in home page
|
||||
|
||||
Reference in New Issue
Block a user