Add Clear Data button to wipe county data folders

This commit is contained in:
zyphlar
2026-04-21 22:55:34 -07:00
parent 7aaff6be35
commit 6880382011
2 changed files with 38 additions and 0 deletions
+16
View File
@@ -376,6 +376,7 @@
<h1>OSM Import Tools</h1>
<div class="topbar-sep"></div>
<button class="btn-topbar" onclick="runScript('ls', '')">List Files</button>
<button class="btn-topbar" onclick="clearData()" style="color:#f88;">Clear Data</button>
<div style="flex:1"></div>
<div class="config-group">
<a href="/api/config/counties.yml" class="btn-topbar-icon" title="Download counties.yml">↓ counties.yml</a>
@@ -725,6 +726,21 @@
.finally(() => enableButtons());
}
function clearData() {
if (!confirm('Delete all downloaded and processed files from all county folders?')) return;
fetch('/api/clear-data', { method: 'POST' })
.then(r => r.json())
.then(data => {
if (data.error) {
showStatus(`Error: ${data.error}`, 'error');
} else {
showStatus(`Cleared ${data.removed.length} file(s).`, 'success');
setTimeout(() => window.location.reload(), 800);
}
})
.catch(err => showStatus(`Error: ${err.message}`, 'error'));
}
function uploadConfig(filename, input) {
if (!input.files.length) return;
const formData = new FormData();