Add counties CRUD page, dynamic county config, crosshair cursor for multi-select
This commit is contained in:
@@ -0,0 +1,348 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Counties — OSM Import Tools</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: #eef0f3;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.page { display: flex; flex-direction: column; height: 100%; }
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 16px;
|
||||
background: #1a1a2e;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.topbar h1 { font-size: 16px; font-weight: 700; color: #fff; }
|
||||
.topbar-sep { width: 1px; height: 20px; background: #ffffff30; }
|
||||
|
||||
.btn-topbar {
|
||||
padding: 5px 12px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
background: #ffffff18;
|
||||
color: #ddd;
|
||||
text-decoration: none;
|
||||
}
|
||||
.btn-topbar:hover { background: #ffffff30; }
|
||||
.btn-topbar.active { background: #ffffff30; color: #fff; }
|
||||
.btn-topbar.purple { background: #6f42c1; color: white; }
|
||||
.btn-topbar.purple:hover { background: #5a32a3; }
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
/* ── Status bar ── */
|
||||
#status {
|
||||
width: 100%;
|
||||
max-width: 680px;
|
||||
padding: 9px 14px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
display: none;
|
||||
}
|
||||
#status.success { background: #d4edda; color: #155724; display: block; }
|
||||
#status.error { background: #f8d7da; color: #721c24; display: block; }
|
||||
|
||||
/* ── County card ── */
|
||||
.county-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
|
||||
width: 100%;
|
||||
max-width: 680px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 16px;
|
||||
background: #f8f9fa;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.color-swatch {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-header-name {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.btn-delete {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: #ccc;
|
||||
font-size: 16px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
line-height: 1;
|
||||
}
|
||||
.btn-delete:hover { color: #dc3545; background: #fdecea; }
|
||||
|
||||
.card-fields {
|
||||
padding: 14px 16px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px 16px;
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.field.full { grid-column: 1 / -1; }
|
||||
|
||||
.field label {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.field input[type="text"],
|
||||
.field input[type="color"] {
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 4px;
|
||||
padding: 5px 8px;
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.field input[type="text"]:focus { border-color: #17a2b8; }
|
||||
|
||||
.field input[type="color"] {
|
||||
padding: 2px 4px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.field .hint {
|
||||
font-size: 10px;
|
||||
color: #bbb;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
/* ── Footer ── */
|
||||
.footer {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
max-width: 680px;
|
||||
width: 100%;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 7px 16px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.btn-add { background: #e8f5e9; color: #2e7d32; }
|
||||
.btn-add:hover { background: #c8e6c9; }
|
||||
.btn-save { background: #17a2b8; color: white; }
|
||||
.btn-save:hover { filter: brightness(0.9); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
|
||||
<div class="topbar">
|
||||
<h1>OSM Import Tools</h1>
|
||||
<div class="topbar-sep"></div>
|
||||
<a href="/" class="btn-topbar">← Back</a>
|
||||
<div style="flex:1"></div>
|
||||
<a href="/counties" class="btn-topbar active">Counties</a>
|
||||
<a href="/exceptions" class="btn-topbar">Street Exceptions</a>
|
||||
<a href="/map" class="btn-topbar purple">Open Map Viewer</a>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
|
||||
<div id="status"></div>
|
||||
|
||||
<div id="countyList"></div>
|
||||
|
||||
<div class="footer">
|
||||
<button class="btn btn-add" onclick="addCounty()">+ Add county</button>
|
||||
<button class="btn btn-save" onclick="save()">Save</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let counties = [];
|
||||
|
||||
const PALETTE = ['#28a745','#17a2b8','#fd7e14','#6f42c1','#dc3545','#6610f2','#20c997','#e83e8c'];
|
||||
|
||||
function showStatus(msg, type) {
|
||||
const el = document.getElementById('status');
|
||||
el.textContent = msg;
|
||||
el.className = type;
|
||||
if (type === 'success') setTimeout(() => el.className = '', 3000);
|
||||
}
|
||||
|
||||
function render() {
|
||||
const container = document.getElementById('countyList');
|
||||
if (!counties.length) {
|
||||
container.innerHTML = '<p style="color:#aaa;font-size:13px">No counties configured. Add one to get started.</p>';
|
||||
return;
|
||||
}
|
||||
container.innerHTML = counties.map((c, i) => `
|
||||
<div class="county-card" data-index="${i}">
|
||||
<div class="card-header">
|
||||
<div class="color-swatch" style="background:${esc(c.color || '#888')}"></div>
|
||||
<div class="card-header-name">${esc(c.name || '(unnamed)')}</div>
|
||||
<button class="btn-delete" onclick="deleteCounty(${i})" title="Delete">✕</button>
|
||||
</div>
|
||||
<div class="card-fields">
|
||||
<div class="field">
|
||||
<label>ID (slug)</label>
|
||||
<input type="text" value="${esc(c.id)}" placeholder="lake"
|
||||
oninput="update(${i},'id',this.value)">
|
||||
<span class="hint">Used in file paths — changing breaks existing data</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Display name</label>
|
||||
<input type="text" value="${esc(c.name)}" placeholder="Lake County"
|
||||
oninput="update(${i},'name',this.value); refreshHeader(${i})">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>State</label>
|
||||
<input type="text" value="${esc(c.state)}" placeholder="Florida"
|
||||
oninput="update(${i},'state',this.value)">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Tab color</label>
|
||||
<input type="color" value="${esc(c.color || '#28a745')}"
|
||||
oninput="update(${i},'color',this.value); refreshHeader(${i})">
|
||||
</div>
|
||||
<div class="field full">
|
||||
<label>Roads download URL</label>
|
||||
<input type="text" value="${esc(c.roads_url)}" placeholder="https://…"
|
||||
oninput="update(${i},'roads_url',this.value)">
|
||||
</div>
|
||||
<div class="field full">
|
||||
<label>Addresses download URL</label>
|
||||
<input type="text" value="${esc(c.addresses_url)}" placeholder="https://…"
|
||||
oninput="update(${i},'addresses_url',this.value)">
|
||||
</div>
|
||||
<div class="field full">
|
||||
<label>Paths URL</label>
|
||||
<input type="text" value="${esc(c.paths_url)}" placeholder="https://… or "upload" or leave empty"
|
||||
oninput="update(${i},'paths_url',this.value)">
|
||||
<span class="hint">Empty = not available | "upload" = manual upload | URL = download</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function esc(s) {
|
||||
return (s || '').replace(/&/g,'&').replace(/"/g,'"').replace(/</g,'<');
|
||||
}
|
||||
|
||||
function update(i, key, value) {
|
||||
counties[i][key] = value;
|
||||
}
|
||||
|
||||
function refreshHeader(i) {
|
||||
const card = document.querySelector(`.county-card[data-index="${i}"]`);
|
||||
if (!card) return;
|
||||
card.querySelector('.color-swatch').style.background = counties[i].color || '#888';
|
||||
card.querySelector('.card-header-name').textContent = counties[i].name || '(unnamed)';
|
||||
}
|
||||
|
||||
function addCounty() {
|
||||
const color = PALETTE[counties.length % PALETTE.length];
|
||||
counties.push({ id: '', name: '', state: 'Florida', color, roads_url: '', addresses_url: '', paths_url: '' });
|
||||
render();
|
||||
// Focus the ID field of the new card
|
||||
const cards = document.querySelectorAll('.county-card');
|
||||
const last = cards[cards.length - 1];
|
||||
if (last) last.querySelector('input').focus();
|
||||
}
|
||||
|
||||
function deleteCounty(i) {
|
||||
counties.splice(i, 1);
|
||||
render();
|
||||
}
|
||||
|
||||
function collectFromDOM() {
|
||||
document.querySelectorAll('.county-card[data-index]').forEach(card => {
|
||||
const i = parseInt(card.dataset.index);
|
||||
const inputs = card.querySelectorAll('input[type="text"], input[type="color"]');
|
||||
// order matches render: id, name, state, color, roads_url, addresses_url, paths_url
|
||||
['id','name','state','color','roads_url','addresses_url','paths_url'].forEach((key, j) => {
|
||||
counties[i][key] = inputs[j].value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function save() {
|
||||
collectFromDOM();
|
||||
for (const c of counties) {
|
||||
if (!c.id.trim()) { showStatus('Each county must have an ID.', 'error'); return; }
|
||||
if (!c.name.trim()) { showStatus('Each county must have a display name.', 'error'); return; }
|
||||
}
|
||||
fetch('/api/counties', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ counties })
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.error) showStatus(`Error: ${data.error}`, 'error');
|
||||
else showStatus('Saved. Restart the server to apply changes to the workflow.', 'success');
|
||||
})
|
||||
.catch(err => showStatus(`Error: ${err.message}`, 'error'));
|
||||
}
|
||||
|
||||
// Load on open
|
||||
fetch('/api/counties')
|
||||
.then(r => r.json())
|
||||
.then(data => { counties = data.counties || []; render(); })
|
||||
.catch(err => showStatus(`Failed to load: ${err.message}`, 'error'));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -190,6 +190,7 @@
|
||||
<div class="topbar-sep"></div>
|
||||
<a href="/" class="btn-topbar">← Back</a>
|
||||
<div style="flex:1"></div>
|
||||
<a href="/counties" class="btn-topbar">Counties</a>
|
||||
<a href="/exceptions" class="btn-topbar active">Street Exceptions</a>
|
||||
<a href="/map" class="btn-topbar purple">Open Map Viewer</a>
|
||||
</div>
|
||||
|
||||
+51
-39
@@ -104,8 +104,7 @@
|
||||
|
||||
.county-tab:hover { color: #444; }
|
||||
|
||||
.county-tab.active.lake { color: #1a7a33; border-bottom-color: #28a745; background: white; }
|
||||
.county-tab.active.sumter { color: #0d7a8f; border-bottom-color: #17a2b8; background: white; }
|
||||
.county-tab.active { background: white; border-bottom-color: var(--county-color, #28a745); color: var(--county-color, #28a745); }
|
||||
|
||||
/* Scrollable workflow area */
|
||||
.workflows {
|
||||
@@ -189,8 +188,7 @@
|
||||
.btn-run:hover { filter: brightness(0.88); }
|
||||
.btn-run:disabled { filter: brightness(0.5); cursor: not-allowed; }
|
||||
|
||||
.lake-active .btn-run { background: #28a745; }
|
||||
.sumter-active .btn-run { background: #17a2b8; }
|
||||
.left .btn-run { background: var(--active-color, #28a745); }
|
||||
|
||||
/* Force redownload */
|
||||
.force-label {
|
||||
@@ -249,8 +247,7 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.file-link.lake { background: #28a745; }
|
||||
.file-link.sumter { background: #17a2b8; }
|
||||
.file-link { background: var(--link-color, #888); }
|
||||
|
||||
/* ── Right panel (console) ── */
|
||||
.right {
|
||||
@@ -330,6 +327,7 @@
|
||||
<button class="btn-topbar" onclick="runScript('make-new-latest', '')">New Latest</button>
|
||||
<button class="btn-topbar" onclick="runScript('ls', '')">List Files</button>
|
||||
<div style="flex:1"></div>
|
||||
<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>
|
||||
@@ -340,8 +338,11 @@
|
||||
<div class="left" id="leftPanel">
|
||||
|
||||
<div class="county-tabs">
|
||||
<button class="county-tab lake active" onclick="selectCounty('lake')">Lake County</button>
|
||||
<button class="county-tab sumter" onclick="selectCounty('sumter')">Sumter County</button>
|
||||
{% for county in counties %}
|
||||
<button class="county-tab" data-county="{{ county.id }}"
|
||||
style="--county-color: {{ county.color }}"
|
||||
onclick="selectCounty('{{ county.id }}')">{{ county.name }}</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="workflows">
|
||||
@@ -455,12 +456,15 @@
|
||||
<div class="files-strip">
|
||||
<div class="files-strip-title">Downloaded files</div>
|
||||
<div class="file-links">
|
||||
{% for county, file_names in data_files.items() %}
|
||||
{% for file_name in file_names %}
|
||||
<a class="file-link {% if 'lake' in county %}lake{% else %}sumter{% endif %}"
|
||||
href="/data/latest/{{ county }}/{{ file_name }}"
|
||||
title="{{ county }}/{{ file_name }}">{{ file_name }}</a>
|
||||
{% for county in counties %}
|
||||
{% if county.id in data_files %}
|
||||
{% for file_name in data_files[county.id] %}
|
||||
<a class="file-link"
|
||||
style="--link-color: {{ county.color }}"
|
||||
href="/data/latest/{{ county.id }}/{{ file_name }}"
|
||||
title="{{ county.id }}/{{ file_name }}">{{ file_name }}</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -482,51 +486,59 @@
|
||||
</div><!-- /page -->
|
||||
|
||||
<script>
|
||||
let activeCounty = 'lake';
|
||||
const COUNTY_CONFIG = {{ counties_json | safe }};
|
||||
let activeCounty = COUNTY_CONFIG.length ? COUNTY_CONFIG[0].id : '';
|
||||
let currentJobId = null;
|
||||
let logCheckInterval = null;
|
||||
|
||||
function selectCounty(county) {
|
||||
activeCounty = county;
|
||||
const config = COUNTY_CONFIG.find(c => c.id === county);
|
||||
|
||||
// Update tab styles
|
||||
document.querySelectorAll('.county-tab').forEach(t => t.classList.remove('active'));
|
||||
document.querySelector(`.county-tab.${county}`).classList.add('active');
|
||||
const tab = document.querySelector(`.county-tab[data-county="${county}"]`);
|
||||
if (tab) tab.classList.add('active');
|
||||
|
||||
// Update left panel class for button color theming
|
||||
// Update button color via CSS custom property
|
||||
const panel = document.getElementById('leftPanel');
|
||||
panel.classList.toggle('lake-active', county === 'lake');
|
||||
panel.classList.toggle('sumter-active', county === 'sumter');
|
||||
panel.style.setProperty('--active-color', config ? config.color : '#28a745');
|
||||
|
||||
// Update paths section availability
|
||||
renderPathsActions(county);
|
||||
renderPathsActions(county, config);
|
||||
}
|
||||
|
||||
function renderPathsActions(county) {
|
||||
if (county === 'lake') {
|
||||
function renderPathsActions(county, config) {
|
||||
const pathsUrl = config ? (config.paths_url || '') : '';
|
||||
const na = '<span class="na">Not available</span>';
|
||||
|
||||
if (!pathsUrl) {
|
||||
['1','2','3','4'].forEach(n => {
|
||||
document.getElementById(`paths-step-${n}-actions`).innerHTML =
|
||||
'<span class="na">Not available for Lake</span>';
|
||||
});
|
||||
} else {
|
||||
// Step 1: upload
|
||||
document.getElementById('paths-step-1-actions').innerHTML =
|
||||
'<input type="file" id="upload-sumter-paths" class="upload-input" accept=".zip">' +
|
||||
'<button class="btn-run" onclick="uploadFile(\'upload-sumter-paths\', \'/data/latest/sumter/paths.shp.zip\')">Upload</button>';
|
||||
// Steps 2-4: run buttons
|
||||
[
|
||||
['2', 'download-osm-paths'],
|
||||
['3', 'convert-paths'],
|
||||
['4', 'diff-paths'],
|
||||
].forEach(([n, script]) => {
|
||||
document.getElementById(`paths-step-${n}-actions`).innerHTML =
|
||||
`<button class="btn-run" onclick="runScript('${script}')">Run</button>`;
|
||||
document.getElementById(`paths-step-${n}-actions`).innerHTML = na;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 1: upload or download
|
||||
const inputId = `upload-${county}-paths`;
|
||||
const dest = `/data/latest/${county}/paths.shp.zip`;
|
||||
if (pathsUrl === 'upload') {
|
||||
document.getElementById('paths-step-1-actions').innerHTML =
|
||||
`<input type="file" id="${inputId}" class="upload-input" accept=".zip">` +
|
||||
`<button class="btn-run" onclick="uploadFile('${inputId}', '${dest}')">Upload</button>`;
|
||||
} else {
|
||||
document.getElementById('paths-step-1-actions').innerHTML =
|
||||
`<button class="btn-run" onclick="runScript('download-county-paths')">Run</button>`;
|
||||
}
|
||||
|
||||
// Steps 2–4
|
||||
[['2','download-osm-paths'],['3','convert-paths'],['4','diff-paths']].forEach(([n, script]) => {
|
||||
document.getElementById(`paths-step-${n}-actions`).innerHTML =
|
||||
`<button class="btn-run" onclick="runScript('${script}')">Run</button>`;
|
||||
});
|
||||
}
|
||||
|
||||
// Init
|
||||
selectCounty('lake');
|
||||
if (activeCounty) selectCounty(activeCounty);
|
||||
|
||||
/* ── Script runner ── */
|
||||
function runScript(scriptName) {
|
||||
|
||||
@@ -269,6 +269,12 @@
|
||||
.overlay.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Crosshair cursor in multi-select mode */
|
||||
.leaflet-container.multi-select-active,
|
||||
.leaflet-container.multi-select-active.leaflet-grab {
|
||||
cursor: crosshair !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user