Add counties CRUD page, dynamic county config, crosshair cursor for multi-select
This commit is contained in:
+138
-73
@@ -22,31 +22,24 @@ latest_path = "/data/latest"
|
||||
@app.route('/')
|
||||
def index():
|
||||
"""Main index page with script execution buttons"""
|
||||
# Get available scripts and organize them
|
||||
script_map = get_script_map()
|
||||
|
||||
# Organize scripts by category
|
||||
scripts_by_category = {
|
||||
'Download County Data': ['download-county-addresses', 'download-county-roads', 'download-county-paths'],
|
||||
'Download OSM Data': ['download-osm-roads', 'download-osm-addresses', 'download-osm-paths'],
|
||||
'Convert Data': ['convert-roads', 'convert-addresses', 'convert-paths'],
|
||||
'Diff Data': ['diff-roads', 'diff-paths', 'diff-addresses'],
|
||||
'Utilities': ['ls', 'make-new-latest']
|
||||
}
|
||||
counties = get_counties()
|
||||
|
||||
# Get list of files
|
||||
data_files = {}
|
||||
if os.path.exists(latest_path):
|
||||
try:
|
||||
for countyFolder in os.listdir(latest_path):
|
||||
files = os.listdir('/data/latest/'+countyFolder)
|
||||
data_files[countyFolder] = files
|
||||
# data_files.append(countyFolder)
|
||||
folder_path = '/data/latest/' + countyFolder
|
||||
if os.path.isdir(folder_path):
|
||||
data_files[countyFolder] = os.listdir(folder_path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
import json as _json
|
||||
return render_template('index.html',
|
||||
script_map=script_map,
|
||||
scripts_by_category=scripts_by_category,
|
||||
data_files=data_files
|
||||
)
|
||||
counties=counties,
|
||||
counties_json=_json.dumps(counties),
|
||||
data_files=data_files)
|
||||
|
||||
@app.route('/map')
|
||||
def map_viewer():
|
||||
@@ -54,64 +47,66 @@ def map_viewer():
|
||||
return render_template('map.html')
|
||||
|
||||
def get_script_map():
|
||||
"""Get the map of available scripts and their commands"""
|
||||
return {
|
||||
"""Build script map dynamically from county configuration."""
|
||||
counties = get_counties()
|
||||
|
||||
county_dirs = ' '.join(f'$NEWDIR/{c["id"]}' for c in counties)
|
||||
sm = {
|
||||
'ls': 'ls -al /data',
|
||||
'make-new-latest': 'cd /data && NEWDIR=$(date +%y%m%d) && mkdir -p $NEWDIR/lake $NEWDIR/sumter && ln -sfn $NEWDIR latest',
|
||||
# todo: make a clean-old-data script
|
||||
'download-county-paths': {
|
||||
'sumter': {'type': 'upload', 'dest': '/data/latest/sumter/paths.shp.zip'},
|
||||
# lake: not available
|
||||
},
|
||||
'download-county-addresses': {
|
||||
# deliver files with standardized names
|
||||
'sumter': 'mkdir -p /data/latest/sumter && wget https://www.arcgis.com/sharing/rest/content/items/c75c5aac13a648968c5596b0665be28b/data -O /data/latest/sumter/addresses.shp.zip',
|
||||
'lake': 'mkdir -p /data/latest/lake && wget https://c.lakecountyfl.gov/ftp/GIS/GisDownloads/Shapefiles/Addresspoints.zip -O /data/latest/lake/addresses.shp.zip'
|
||||
},
|
||||
'download-county-roads': {
|
||||
# deliver files with standardized names
|
||||
'sumter': 'mkdir -p /data/latest/sumter && wget https://www.arcgis.com/sharing/rest/content/items/9177e17c72d3433aa79630c7eda84add/data -O /data/latest/sumter/roads.shp.zip',
|
||||
'lake': 'mkdir -p /data/latest/lake && wget https://c.lakecountyfl.gov/ftp/GIS/GisDownloads/Shapefiles/Streets.zip -O /data/latest/lake/roads.shp.zip'
|
||||
},
|
||||
# todo: integrate osm downloading and shapefile converting into diff-roads like addresses
|
||||
'download-osm-roads': {
|
||||
'lake': ['python', 'download-overpass.py', '--type', 'highways', 'Lake County', 'Florida', '/data/latest/lake/osm-roads.geojson'],
|
||||
'sumter': ['python', 'download-overpass.py', '--type', 'highways', 'Sumter County', 'Florida', '/data/latest/sumter/osm-roads.geojson']
|
||||
},
|
||||
'download-osm-addresses': {
|
||||
'lake': ['python', 'download-overpass.py', '--type', 'addresses', 'Lake County', 'Florida', '/data/latest/lake/osm-addresses.geojson'],
|
||||
'sumter': ['python', 'download-overpass.py', '--type', 'addresses', 'Sumter County', 'Florida', '/data/latest/sumter/osm-addresses.geojson']
|
||||
},
|
||||
'download-osm-paths': {
|
||||
# todo: no lake county paths
|
||||
#'lake': ['python', 'download-overpass.py', '--type', 'highways', 'Lake County', 'Florida', '/data/latest/lake/osm-roads.geojson'],
|
||||
'sumter': ['python', 'download-overpass.py', '--type', 'paths', 'Sumter County', 'Florida', '/data/latest/sumter/osm-paths.geojson']
|
||||
},
|
||||
# todo
|
||||
'convert-roads': {
|
||||
'sumter': ['python', 'shp-to-geojson.py', '/data/latest/sumter/roads.shp.zip', '/data/latest/sumter/county-roads.geojson'],
|
||||
'lake': ['python', 'shp-to-geojson.py', '/data/latest/lake/roads.shp.zip', '/data/latest/lake/county-roads.geojson']
|
||||
},
|
||||
'convert-addresses': {
|
||||
'sumter': ['python', 'convert-addresses.py', '/data/latest/sumter/addresses.shp.zip', '/data/latest/sumter/county-addresses.geojson'],
|
||||
'lake': ['python', 'convert-addresses.py', '/data/latest/lake/addresses.shp.zip', '/data/latest/lake/county-addresses.geojson'],
|
||||
},
|
||||
'convert-paths': {
|
||||
'sumter': ['python', 'shp-to-geojson.py', '/data/latest/sumter/paths.shp.zip', '/data/latest/sumter/county-paths.geojson'],
|
||||
},
|
||||
'diff-roads': {
|
||||
'lake': ['python', 'diff-highways.py', '/data/latest/lake/osm-roads.geojson', '/data/latest/lake/county-roads.geojson', '--output', '/data/latest/lake/diff-roads.geojson'],
|
||||
'sumter': ['python', 'diff-highways.py', '/data/latest/sumter/osm-roads.geojson', '/data/latest/sumter/county-roads.geojson', '--output', '/data/latest/sumter/diff-roads.geojson'],
|
||||
},
|
||||
'diff-paths': {
|
||||
'sumter': ['python', 'diff-highways.py', '/data/latest/sumter/osm-paths.geojson', '/data/latest/sumter/county-paths.geojson', '--output', '/data/latest/sumter/diff-paths.geojson'],
|
||||
},
|
||||
'diff-addresses': {
|
||||
'lake': ['python', 'compare-addresses.py', '--local-file', '/data/latest/lake/county-addresses.geojson', '--osm-file', '/data/latest/lake/osm-addresses.geojson', '--output-dir', '/data/latest/lake'],
|
||||
'sumter': ['python', 'compare-addresses.py', '--local-file', '/data/latest/sumter/county-addresses.geojson', '--osm-file', '/data/latest/sumter/osm-addresses.geojson', '--output-dir', '/data/latest/sumter'],
|
||||
},
|
||||
'make-new-latest': f'cd /data && NEWDIR=$(date +%y%m%d) && mkdir -p {county_dirs} && ln -sfn $NEWDIR latest',
|
||||
}
|
||||
|
||||
dl_roads = {}; dl_addrs = {}; dl_paths = {}
|
||||
osm_roads = {}; osm_addrs = {}; osm_paths = {}
|
||||
conv_roads = {}; conv_addrs = {}; conv_paths = {}
|
||||
diff_roads = {}; diff_addrs = {}; diff_paths = {}
|
||||
|
||||
for c in counties:
|
||||
cid = c['id']
|
||||
name = c['name']
|
||||
state = c['state']
|
||||
base = f'/data/latest/{cid}'
|
||||
|
||||
if c.get('roads_url'):
|
||||
dl_roads[cid] = f'mkdir -p {base} && wget {c["roads_url"]} -O {base}/roads.shp.zip'
|
||||
if c.get('addresses_url'):
|
||||
dl_addrs[cid] = f'mkdir -p {base} && wget {c["addresses_url"]} -O {base}/addresses.shp.zip'
|
||||
pu = c.get('paths_url', '')
|
||||
if pu == 'upload':
|
||||
dl_paths[cid] = {'type': 'upload', 'dest': f'{base}/paths.shp.zip'}
|
||||
elif pu:
|
||||
dl_paths[cid] = f'mkdir -p {base} && wget {pu} -O {base}/paths.shp.zip'
|
||||
|
||||
osm_roads[cid] = ['python', 'download-overpass.py', '--type', 'highways', name, state, f'{base}/osm-roads.geojson']
|
||||
osm_addrs[cid] = ['python', 'download-overpass.py', '--type', 'addresses', name, state, f'{base}/osm-addresses.geojson']
|
||||
if pu:
|
||||
osm_paths[cid] = ['python', 'download-overpass.py', '--type', 'paths', name, state, f'{base}/osm-paths.geojson']
|
||||
|
||||
conv_roads[cid] = ['python', 'shp-to-geojson.py', f'{base}/roads.shp.zip', f'{base}/county-roads.geojson']
|
||||
conv_addrs[cid] = ['python', 'convert-addresses.py', f'{base}/addresses.shp.zip', f'{base}/county-addresses.geojson']
|
||||
if pu:
|
||||
conv_paths[cid] = ['python', 'shp-to-geojson.py', f'{base}/paths.shp.zip', f'{base}/county-paths.geojson']
|
||||
|
||||
diff_roads[cid] = ['python', 'diff-highways.py', f'{base}/osm-roads.geojson', f'{base}/county-roads.geojson', '--output', f'{base}/diff-roads.geojson']
|
||||
diff_addrs[cid] = ['python', 'compare-addresses.py', '--local-file', f'{base}/county-addresses.geojson', '--osm-file', f'{base}/osm-addresses.geojson', '--output-dir', base]
|
||||
if pu:
|
||||
diff_paths[cid] = ['python', 'diff-highways.py', f'{base}/osm-paths.geojson', f'{base}/county-paths.geojson', '--output', f'{base}/diff-paths.geojson']
|
||||
|
||||
if dl_roads: sm['download-county-roads'] = dl_roads
|
||||
if dl_addrs: sm['download-county-addresses'] = dl_addrs
|
||||
if dl_paths: sm['download-county-paths'] = dl_paths
|
||||
sm['download-osm-roads'] = osm_roads
|
||||
sm['download-osm-addresses'] = osm_addrs
|
||||
if osm_paths: sm['download-osm-paths'] = osm_paths
|
||||
sm['convert-roads'] = conv_roads
|
||||
sm['convert-addresses'] = conv_addrs
|
||||
if conv_paths: sm['convert-paths'] = conv_paths
|
||||
sm['diff-roads'] = diff_roads
|
||||
sm['diff-addresses'] = diff_addrs
|
||||
if diff_paths: sm['diff-paths'] = diff_paths
|
||||
|
||||
return sm
|
||||
|
||||
@app.route('/api/run-script', methods=['POST'])
|
||||
def run_script():
|
||||
"""Execute a script in the background"""
|
||||
@@ -288,6 +283,76 @@ def serve_data(filename):
|
||||
"""Serve GeoJSON files"""
|
||||
return send_from_directory('/data', filename)
|
||||
|
||||
# ── Counties config ────────────────────────────────────────────────────────────
|
||||
|
||||
COUNTIES_FILE = '/data/counties.yml'
|
||||
|
||||
DEFAULT_COUNTIES = [
|
||||
{
|
||||
'id': 'lake',
|
||||
'name': 'Lake County',
|
||||
'state': 'Florida',
|
||||
'color': '#28a745',
|
||||
'roads_url': 'https://c.lakecountyfl.gov/ftp/GIS/GisDownloads/Shapefiles/Streets.zip',
|
||||
'addresses_url': 'https://c.lakecountyfl.gov/ftp/GIS/GisDownloads/Shapefiles/Addresspoints.zip',
|
||||
'paths_url': '',
|
||||
},
|
||||
{
|
||||
'id': 'sumter',
|
||||
'name': 'Sumter County',
|
||||
'state': 'Florida',
|
||||
'color': '#17a2b8',
|
||||
'roads_url': 'https://www.arcgis.com/sharing/rest/content/items/9177e17c72d3433aa79630c7eda84add/data',
|
||||
'addresses_url': 'https://www.arcgis.com/sharing/rest/content/items/c75c5aac13a648968c5596b0665be28b/data',
|
||||
'paths_url': 'upload',
|
||||
},
|
||||
]
|
||||
|
||||
def _ensure_counties_file():
|
||||
if not os.path.exists(COUNTIES_FILE):
|
||||
os.makedirs(os.path.dirname(COUNTIES_FILE), exist_ok=True)
|
||||
with open(COUNTIES_FILE, 'w') as f:
|
||||
yaml.dump({'counties': DEFAULT_COUNTIES}, f,
|
||||
default_flow_style=False, allow_unicode=True)
|
||||
|
||||
_ensure_counties_file()
|
||||
|
||||
def get_counties():
|
||||
try:
|
||||
with open(COUNTIES_FILE) as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
return data.get('counties', DEFAULT_COUNTIES)
|
||||
except Exception:
|
||||
return DEFAULT_COUNTIES
|
||||
|
||||
@app.route('/counties')
|
||||
def counties_page():
|
||||
return render_template('counties.html')
|
||||
|
||||
@app.route('/api/counties', methods=['GET'])
|
||||
def get_counties_api():
|
||||
try:
|
||||
return jsonify({'counties': get_counties()})
|
||||
except Exception as e:
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/counties', methods=['POST'])
|
||||
def save_counties():
|
||||
data = request.json
|
||||
counties = data.get('counties', [])
|
||||
for c in counties:
|
||||
if not c.get('id', '').strip():
|
||||
return jsonify({'error': 'Each county must have a non-empty id'}), 400
|
||||
if not c.get('name', '').strip():
|
||||
return jsonify({'error': 'Each county must have a non-empty name'}), 400
|
||||
tmp = COUNTIES_FILE + '.tmp'
|
||||
with open(tmp, 'w') as f:
|
||||
yaml.dump({'counties': counties}, f, default_flow_style=False, allow_unicode=True)
|
||||
os.replace(tmp, COUNTIES_FILE)
|
||||
return jsonify({'success': True})
|
||||
|
||||
# ── Exceptions config ──────────────────────────────────────────────────────────
|
||||
|
||||
EXCEPTIONS_FILE = '/data/exceptions.yml'
|
||||
|
||||
DEFAULT_EXCEPTIONS = [
|
||||
|
||||
@@ -1253,9 +1253,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (multiSelectMode) {
|
||||
button.style.background = '#007bff';
|
||||
button.textContent = 'Multi-Select: ON';
|
||||
map.getContainer().classList.add('multi-select-active');
|
||||
} else {
|
||||
button.style.background = '#6c757d';
|
||||
button.textContent = 'Multi-Select: OFF';
|
||||
map.getContainer().classList.remove('multi-select-active');
|
||||
// Clear selection when turning off multi-select mode
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
+48
-36
@@ -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>';
|
||||
document.getElementById(`paths-step-${n}-actions`).innerHTML = na;
|
||||
});
|
||||
} else {
|
||||
// Step 1: upload
|
||||
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="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]) => {
|
||||
`<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