fix: ensure HTML response for downloads polling
- 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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user