fix: update radiosonde stop UI immediately on click

The stop button appeared unresponsive because UI updates waited for the
server response. If the fetch hung or errored, the user saw nothing.
Now the UI updates immediately (matching the pager stop pattern) and
the server request happens in the background.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-02-27 12:18:54 +00:00
parent 824514d922
commit 7683a925df

View File

@@ -166,19 +166,23 @@
}
function stopRadiosondeTracking() {
// Update UI immediately so the user sees feedback
document.getElementById('startRadiosondeBtn').style.display = 'block';
document.getElementById('stopRadiosondeBtn').style.display = 'none';
document.getElementById('radiosondeStatusText').textContent = 'Stopping...';
document.getElementById('radiosondeStatusText').style.color = 'var(--accent-yellow)';
if (radiosondeEventSource) {
radiosondeEventSource.close();
radiosondeEventSource = null;
}
fetch('/radiosonde/stop', { method: 'POST' })
.then(r => r.json())
.then(() => {
document.getElementById('startRadiosondeBtn').style.display = 'block';
document.getElementById('stopRadiosondeBtn').style.display = 'none';
document.getElementById('radiosondeStatusText').textContent = 'Standby';
document.getElementById('radiosondeStatusText').style.color = 'var(--accent-yellow)';
document.getElementById('radiosondeBalloonCount').textContent = '0';
document.getElementById('radiosondeLastUpdate').textContent = '\u2014';
if (radiosondeEventSource) {
radiosondeEventSource.close();
radiosondeEventSource = null;
}
radiosondeBalloons = {};
// Clear map markers
if (typeof radiosondeMap !== 'undefined' && radiosondeMap) {
@@ -187,6 +191,9 @@
radiosondeTracks.forEach(t => radiosondeMap.removeLayer(t));
radiosondeTracks.clear();
}
})
.catch(() => {
document.getElementById('radiosondeStatusText').textContent = 'Standby';
});
}