fix: ensure HTML response for downloads polling
CI / Test (Python 3.11) (push) Has been cancelled
CI / Test (Python 3.12) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Type Check (push) Has been cancelled
CI / Summary (push) Has been cancelled

- Added html=1 parameter to downloads HTMX polling
- Fixed data structure mismatch between backend and Jinja2 template
- Guaranteed TemplateResponse for downloads list when requested
This commit is contained in:
root
2026-03-24 14:18:04 +00:00
parent eb0c67348f
commit f426b2c025
2 changed files with 31 additions and 14 deletions
+8 -8
View File
@@ -1,9 +1,9 @@
<div class="downloads-grid"
hx-get="/api/downloads?html=true"
hx-get="/api/downloads?html=1"
hx-trigger="every 2s"
hx-swap="innerHTML">
{% if tasks %}
{% for task_id, task in tasks.items() %}
{% for task in tasks %}
<div class="download-item task-{{ task.status }}">
<div class="download-info">
<span class="download-name" title="{{ task.filename }}">{{ task.filename }}</span>
@@ -16,29 +16,29 @@
<div class="download-meta">
<span>{{ task.progress | round(1) }}%</span>
<span>{{ task.download_speed }}</span>
<span>{{ task.eta }}</span>
<span>{{ task.speed or '0' }} KB/s</span>
<span>{{ task.eta or '' }}</span>
</div>
<div class="download-actions">
{% if task.status == 'downloading' or task.status == 'pending' %}
<button class="btn-icon" hx-post="/api/downloads/{{ task_id }}/pause" hx-swap="none">
<button class="btn-icon" hx-post="/api/downloads/{{ task.id }}/pause" hx-swap="none">
<i class="fas fa-pause"></i>
</button>
{% elif task.status == 'paused' %}
<button class="btn-icon" hx-post="/api/downloads/{{ task_id }}/resume" hx-swap="none">
<button class="btn-icon" hx-post="/api/downloads/{{ task.id }}/resume" hx-swap="none">
<i class="fas fa-play"></i>
</button>
{% endif %}
{% if task.status == 'completed' %}
<a href="/video/{{ task_id }}" class="btn-icon success">
<a href="/video/{{ task.id }}" class="btn-icon success">
<i class="fas fa-external-link-alt"></i>
</a>
{% endif %}
<button class="btn-icon danger"
hx-delete="/api/downloads/{{ task_id }}"
hx-delete="/api/downloads/{{ task.id }}"
hx-confirm="Supprimer ce téléchargement ?"
hx-swap="none">
<i class="fas fa-trash"></i>