diff --git a/app/routers/router_downloads.py b/app/routers/router_downloads.py index e5c1779..c4ecfcb 100644 --- a/app/routers/router_downloads.py +++ b/app/routers/router_downloads.py @@ -27,14 +27,15 @@ async def get_downloads( """Get list of all download tasks. Returns HTML for HTMX.""" tasks = download_manager.get_all_tasks() - # Check for HTMX or explicit HTML request + # Force HTML if requested or via HTMX if html or request.headers.get("HX-Request"): - print(f"[DOWNLOADS] Returning HTML list for {len(tasks)} tasks") + print(f"[DOWNLOADS] HTMX Request detected. Returning HTML for {len(tasks)} tasks.") return templates.TemplateResponse( "components/downloads_list.html", {"request": request, "tasks": tasks} ) + print(f"[DOWNLOADS] API Request detected. Returning JSON.") return {"downloads": tasks} diff --git a/templates/components/downloads_list.html b/templates/components/downloads_list.html index c6bdce3..181a44b 100644 --- a/templates/components/downloads_list.html +++ b/templates/components/downloads_list.html @@ -1,8 +1,5 @@ -
- {% if tasks %} +{% if tasks %} +
{% for task in tasks %}
@@ -46,9 +43,54 @@
{% endfor %} - {% else %} -
-

Aucun téléchargement en cours

-
- {% endif %} -
+
+{% else %} +
+

Aucun téléchargement en cours

+
+{% endif %} + + diff --git a/templates/components/downloads_section.html b/templates/components/downloads_section.html index 3a232e1..c241076 100644 --- a/templates/components/downloads_section.html +++ b/templates/components/downloads_section.html @@ -5,77 +5,24 @@ -
- {% include "components/downloads_list.html" %} + +
+
+
Chargement des téléchargements... +