Move config download/upload into Counties and Exceptions pages
This commit is contained in:
@@ -180,6 +180,19 @@
|
||||
|
||||
.btn-save { background: #17a2b8; color: white; }
|
||||
.btn-save:hover { filter: brightness(0.9); }
|
||||
|
||||
.btn-dl {
|
||||
padding: 7px 12px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
background: #e9ecef;
|
||||
color: #555;
|
||||
text-decoration: none;
|
||||
}
|
||||
.btn-dl:hover { background: #dee2e6; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -222,6 +235,11 @@
|
||||
<div class="card-footer">
|
||||
<button class="btn btn-add" onclick="addRow()">+ Add row</button>
|
||||
<button class="btn btn-save" onclick="save()">Save</button>
|
||||
{% if current_user %}
|
||||
<div style="flex:1"></div>
|
||||
<a href="/api/config/exceptions.yml" class="btn-dl" title="Download exceptions.yml">↓ Download</a>
|
||||
<label class="btn-dl" style="cursor:pointer" title="Upload exceptions.yml">↑ Upload<input type="file" style="display:none" accept=".yml,.yaml" onchange="uploadConfig(this)"></label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -308,6 +326,22 @@
|
||||
.catch(err => showStatus(`Error: ${err.message}`, 'error'));
|
||||
}
|
||||
|
||||
function uploadConfig(input) {
|
||||
if (!input.files.length) return;
|
||||
const formData = new FormData();
|
||||
formData.append('file', input.files[0]);
|
||||
showStatus('Uploading…', 'info');
|
||||
fetch('/api/config/exceptions.yml', { method: 'POST', body: formData })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.error) { showStatus(`Error: ${data.error}`, 'error'); return; }
|
||||
showStatus('Uploaded — reloading…', 'success');
|
||||
setTimeout(() => window.location.reload(), 800);
|
||||
})
|
||||
.catch(err => showStatus(`Error: ${err.message}`, 'error'))
|
||||
.finally(() => { input.value = ''; });
|
||||
}
|
||||
|
||||
// Load on page open
|
||||
fetch('/api/exceptions')
|
||||
.then(r => r.json())
|
||||
|
||||
Reference in New Issue
Block a user