Add cross-dashboard header links (UPLOAD_DASHBOARD_URL, LIVE_DASHBOARD_URL)

This commit is contained in:
proitlab committed 2026-08-05 07:58:00 +07:00
1 parent 99e126de1b
commit 89673db0bf
9 files changed
+16 -2

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ PYTHONNOUSERSITE=1 venv/bin/python recounting_dashboard_upload.py
- **Reset flow**: `POST /api/reset` → deletes state JSON + touches `{SHM_DIR}/.reset`. `batch_store._check_reset_signal()` watches this marker and clears in-memory state on next crossing. - **Reset flow**: `POST /api/reset` → deletes state JSON + touches `{SHM_DIR}/.reset`. `batch_store._check_reset_signal()` watches this marker and clears in-memory state on next crossing.
- **Upload filename contract**: uploads are expected as `batch_XX_YYYYMMDD_HHmmSS.mp4` (XX = batch number, timestamp = date). `recounting_dashboard_upload.py` parses both to query the live API's `/api/day-detail/<YYYY-MM-DD>` for the recorded count. - **Upload filename contract**: uploads are expected as `batch_XX_YYYYMMDD_HHmmSS.mp4` (XX = batch number, timestamp = date). `recounting_dashboard_upload.py` parses both to query the live API's `/api/day-detail/<YYYY-MM-DD>` for the recorded count.
- **`RECOUNT_CMD`** in the upload dashboard is a template with a `{path}` placeholder, e.g. `bytetrack-counter config.env --source {path}`; the uploaded file path is `shlex.quote()`d before substitution. - **`RECOUNT_CMD`** in the upload dashboard is a template with a `{path}` placeholder, e.g. `bytetrack-counter config.env --source {path}`; the uploaded file path is `shlex.quote()`d before substitution.
- **Cross-dashboard header links**: `UPLOAD_DASHBOARD_URL` (live → upload dashboard, `counter_dashboard.py`) and `LIVE_DASHBOARD_URL` (upload → live dashboard, `recounting_dashboard_upload.py`); empty value hides the header link.
## Code conventions ## Code conventions
+3
View File
@@ -54,6 +54,7 @@ env: MIN_OBJECT_PER_BATCH → min count to persist batch (default 60)
env: MIN_DURATION_PER_BATCH → min seconds to persist batch (default 60) env: MIN_DURATION_PER_BATCH → min seconds to persist batch (default 60)
env: LIVE_STREAM_ENABLED → write annotated JPEG snapshot each N frames env: LIVE_STREAM_ENABLED → write annotated JPEG snapshot each N frames
env: EXPORT_CSV → write per-crossing CSV (default true) env: EXPORT_CSV → write per-crossing CSV (default true)
env: UPLOAD_DASHBOARD_URL → header link to upload recounting dashboard (default empty → hidden)
### Recounting dashboard config ### Recounting dashboard config
``` ```
@@ -70,6 +71,7 @@ env: RECOUNTING_UPLOAD_PORT → port for upload UI (default 5003)
env: UPLOAD_DIR → dir for uploaded MP4s (default <repo>/uploads) env: UPLOAD_DIR → dir for uploaded MP4s (default <repo>/uploads)
env: RECOUNT_CMD → replay command template with {path} placeholder (default "bytetrack-counter config.env --source {path}") env: RECOUNT_CMD → replay command template with {path} placeholder (default "bytetrack-counter config.env --source {path}")
env: RECOUNTING_UPLOAD_TEMPLATE → template (default recounting_upload.html) env: RECOUNTING_UPLOAD_TEMPLATE → template (default recounting_upload.html)
env: LIVE_DASHBOARD_URL → header link to live counter dashboard (default empty → hidden)
``` ```
``` ```
@@ -178,6 +180,7 @@ T12|x|add recounting dashboard — dual-API counter panels, MP4 browser, go2rtc
T13|x|add template system — DASHBOARD_TEMPLATE env var selects dashboard.html|lamborghini|tesla| T13|x|add template system — DASHBOARD_TEMPLATE env var selects dashboard.html|lamborghini|tesla|
T14|x|harden reset API — separate SHM marker creation from state file cleanup; return 500 on SHM failure|V20 T14|x|harden reset API — separate SHM marker creation from state file cleanup; return 500 on SHM failure|V20
T15|x|add upload recounting dashboard — MP4 upload, progress bar, RECOUNT_CMD replay|V21 T15|x|add upload recounting dashboard — MP4 upload, progress bar, RECOUNT_CMD replay|V21
T16|x|add cross-dashboard header links — UPLOAD_DASHBOARD_URL (live→upload) & LIVE_DASHBOARD_URL (upload→live)|I.config
``` ```
## §B — Bugs ## §B — Bugs
+4
View File
@@ -159,6 +159,8 @@ SECRET_KEY=change-me-in-production
DASHBOARD_HOST=0.0.0.0 DASHBOARD_HOST=0.0.0.0
# Listen port for the dashboard web UI # Listen port for the dashboard web UI
DASHBOARD_PORT=5000 DASHBOARD_PORT=5000
# URL of the upload recounting dashboard (recounting_dashboard_upload.py); empty hides the header link
UPLOAD_DASHBOARD_URL=http://localhost:5003
# Enable Flask debug mode (true/false) — auto-reloads on code changes; disable in production # Enable Flask debug mode (true/false) — auto-reloads on code changes; disable in production
FLASK_DEBUG=false FLASK_DEBUG=false
# Fallback name for the active-batch JSON state file used by the dashboard # Fallback name for the active-batch JSON state file used by the dashboard
@@ -188,3 +190,5 @@ UPLOAD_DIR=/opt/bytetrack-counter/uploads
RECOUNT_CMD=bytetrack-counter config.env --source {path} RECOUNT_CMD=bytetrack-counter config.env --source {path}
# Template file for the upload dashboard: "recounting_upload.html" (default) # Template file for the upload dashboard: "recounting_upload.html" (default)
RECOUNTING_UPLOAD_TEMPLATE=recounting_upload.html RECOUNTING_UPLOAD_TEMPLATE=recounting_upload.html
# URL of the live counter dashboard (counter_dashboard.py); empty hides the header link
LIVE_DASHBOARD_URL=http://localhost:5000
+2 -1
View File
@@ -40,6 +40,7 @@ SHM_DIR = os.getenv("SHM_DIR", "/dev/shm/bytetrack-counter")
SITE_NAME = os.getenv("SITE_NAME", "LIVE") SITE_NAME = os.getenv("SITE_NAME", "LIVE")
TEMPLATE = os.getenv("DASHBOARD_TEMPLATE", "dashboard.html") TEMPLATE = os.getenv("DASHBOARD_TEMPLATE", "dashboard.html")
UPLOAD_DASHBOARD_URL = os.getenv("UPLOAD_DASHBOARD_URL", "")
DASHBOARD_PORT = int(os.getenv("DASHBOARD_PORT", "5000")) DASHBOARD_PORT = int(os.getenv("DASHBOARD_PORT", "5000"))
DASHBOARD_HOST = os.getenv("DASHBOARD_HOST", "0.0.0.0") DASHBOARD_HOST = os.getenv("DASHBOARD_HOST", "0.0.0.0")
@@ -132,7 +133,7 @@ def get_counting_date(dt=None, cutoff_str=CUTOFF_TIME):
@app.route("/") @app.route("/")
def index(): def index():
return render_template(TEMPLATE, site_name=SITE_NAME) return render_template(TEMPLATE, site_name=SITE_NAME, upload_dashboard_url=UPLOAD_DASHBOARD_URL)
@app.route("/api/current-batch") @app.route("/api/current-batch")
+2 -1
View File
@@ -36,6 +36,7 @@ RECOUNT_API_URL = os.getenv("RECOUNT_API_URL", "http://localhost:5001")
SITE_NAME = os.getenv("SITE_NAME", "RECOUNT") SITE_NAME = os.getenv("SITE_NAME", "RECOUNT")
TEMPLATE = os.getenv("RECOUNTING_UPLOAD_TEMPLATE", "recounting_upload.html") TEMPLATE = os.getenv("RECOUNTING_UPLOAD_TEMPLATE", "recounting_upload.html")
LIVE_DASHBOARD_URL = os.getenv("LIVE_DASHBOARD_URL", "")
DASHBOARD_PORT = int(os.getenv("RECOUNTING_UPLOAD_PORT", "5003")) DASHBOARD_PORT = int(os.getenv("RECOUNTING_UPLOAD_PORT", "5003"))
DASHBOARD_HOST = os.getenv("DASHBOARD_HOST", "0.0.0.0") DASHBOARD_HOST = os.getenv("DASHBOARD_HOST", "0.0.0.0")
@@ -92,7 +93,7 @@ def _folder_date(filepath, base):
@app.route("/") @app.route("/")
def index(): def index():
return render_template(TEMPLATE, site_name=SITE_NAME, upload_dir=str(UPLOAD_DIR)) return render_template(TEMPLATE, site_name=SITE_NAME, upload_dir=str(UPLOAD_DIR), live_dashboard_url=LIVE_DASHBOARD_URL)
@app.route("/api/live-progress") @app.route("/api/live-progress")
+1
View File
@@ -575,6 +575,7 @@
<span class="date-val" id="current-date">--</span> <span class="date-val" id="current-date">--</span>
Counting Day Counting Day
</div> </div>
{% if upload_dashboard_url %}<a class="live-chip" href="{{ upload_dashboard_url }}" target="_blank" rel="noopener" style="text-decoration:none;">RECOUNT UPLOAD</a>{% endif %}
<div class="live-chip"> <div class="live-chip">
<span class="dot"></span> <span class="dot"></span>
<span>{{ site_name }}</span> <span>{{ site_name }}</span>
+1
View File
@@ -408,6 +408,7 @@
<span class="date-val" id="current-date">--</span> <span class="date-val" id="current-date">--</span>
Counting Day Counting Day
</div> </div>
{% if upload_dashboard_url %}<a class="live-chip" href="{{ upload_dashboard_url }}" target="_blank" rel="noopener" style="text-decoration:none;">RECOUNT UPLOAD</a>{% endif %}
<div class="live-chip"> <div class="live-chip">
<span class="dot"></span> <span class="dot"></span>
<span>{{ site_name }}</span> <span>{{ site_name }}</span>
+1
View File
@@ -418,6 +418,7 @@
<span class="date-val" id="current-date">--</span> <span class="date-val" id="current-date">--</span>
Counting Day Counting Day
</div> </div>
{% if upload_dashboard_url %}<a class="live-chip" href="{{ upload_dashboard_url }}" target="_blank" rel="noopener" style="text-decoration:none;">RECOUNT UPLOAD</a>{% endif %}
<div class="live-chip"> <div class="live-chip">
<span class="dot"></span> <span class="dot"></span>
<span>{{ site_name }}</span> <span>{{ site_name }}</span>
+1
View File
@@ -432,6 +432,7 @@
</div> </div>
</div> </div>
<div class="header-right"> <div class="header-right">
{% if live_dashboard_url %}<a class="live-chip live-chip-green" href="{{ live_dashboard_url }}" target="_blank" rel="noopener" style="text-decoration:none;">LIVE DASHBOARD</a>{% endif %}
<div class="live-chip live-chip-green"> <div class="live-chip live-chip-green">
<span class="dot"></span> <span class="dot"></span>
<span>LIVE</span> <span>LIVE</span>