Add auth system, fix map defaults, controls overflow, fix latest-date ref
This commit is contained in:
@@ -378,6 +378,7 @@
|
||||
<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>
|
||||
{% if current_user %}
|
||||
<div class="config-group">
|
||||
<a href="/api/config/counties.yml" class="btn-topbar-icon" title="Download counties.yml">↓ counties.yml</a>
|
||||
<label class="btn-topbar-icon" title="Upload counties.yml" style="cursor:pointer">↑<input type="file" style="display:none" accept=".yml,.yaml" onchange="uploadConfig('counties.yml', this)"></label>
|
||||
@@ -387,9 +388,19 @@
|
||||
<label class="btn-topbar-icon" title="Upload exceptions.yml" style="cursor:pointer">↑<input type="file" style="display:none" accept=".yml,.yaml" onchange="uploadConfig('exceptions.yml', this)"></label>
|
||||
</div>
|
||||
<div class="topbar-sep"></div>
|
||||
{% endif %}
|
||||
<a href="/counties" class="btn-topbar">Counties</a>
|
||||
<a href="/exceptions" class="btn-topbar">Street Exceptions</a>
|
||||
<a href="/map" class="btn-topbar purple">Open Map Viewer</a>
|
||||
<div class="topbar-sep"></div>
|
||||
{% if current_user %}
|
||||
<span style="font-size:11px;color:#888;">{{ current_user }}</span>
|
||||
<form method="POST" action="/logout" style="display:inline;margin:0">
|
||||
<button type="submit" class="btn-topbar">Logout</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<a href="/login" class="btn-topbar" style="color:#f0a830;">Login</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
@@ -564,10 +575,17 @@
|
||||
|
||||
<script>
|
||||
const COUNTY_CONFIG = {{ counties_json | safe }};
|
||||
const IS_AUTHENTICATED = {{ 'true' if current_user else 'false' }};
|
||||
let activeCounty = COUNTY_CONFIG.length ? COUNTY_CONFIG[0].id : '';
|
||||
let currentJobId = null;
|
||||
let logCheckInterval = null;
|
||||
|
||||
function requireLogin() {
|
||||
showStatus('Not authenticated – please log in.', 'error');
|
||||
setTimeout(() => { window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname); }, 1200);
|
||||
return false;
|
||||
}
|
||||
|
||||
function selectCounty(county) {
|
||||
activeCounty = county;
|
||||
const config = COUNTY_CONFIG.find(c => c.id === county);
|
||||
@@ -619,6 +637,7 @@
|
||||
|
||||
/* ── Script runner ── */
|
||||
function runScript(scriptName) {
|
||||
if (!IS_AUTHENTICATED) return requireLogin();
|
||||
const logsEl = document.getElementById('logs');
|
||||
logsEl.textContent = '';
|
||||
showStatus(`Running: ${scriptName} (${activeCounty})`, 'info');
|
||||
@@ -699,6 +718,7 @@
|
||||
}
|
||||
|
||||
function uploadFile(inputId, dest) {
|
||||
if (!IS_AUTHENTICATED) return requireLogin();
|
||||
const input = document.getElementById(inputId);
|
||||
if (!input || !input.files.length) {
|
||||
showStatus('Please select a file first.', 'error');
|
||||
@@ -727,6 +747,7 @@
|
||||
}
|
||||
|
||||
function clearData() {
|
||||
if (!IS_AUTHENTICATED) return requireLogin();
|
||||
if (!confirm('Delete all downloaded and processed files from all county folders?')) return;
|
||||
fetch('/api/clear-data', { method: 'POST' })
|
||||
.then(r => r.json())
|
||||
|
||||
Reference in New Issue
Block a user