Merge pull request #11 from DasPoschi/codex/add-proxy-list-import-function-3g187r

Refresh jobs table via `/jobs` endpoint instead of full page reload
This commit is contained in:
2026-01-01 22:23:09 +01:00
committed by GitHub

View File

@@ -821,7 +821,11 @@ def worker(jobid: str):
def favicon(): def favicon():
return HTMLResponse(status_code=204) return HTMLResponse(status_code=204)
def render_page(error: str = "") -> str: @app.get("/jobs", response_class=HTMLResponse)
def jobs_get():
return HTMLResponse(render_job_rows())
def render_job_rows() -> str:
rows = "" rows = ""
with lock: with lock:
job_list = list(jobs.values())[::-1] job_list = list(jobs.values())[::-1]
@@ -851,6 +855,13 @@ def render_page(error: str = "") -> str:
f"</tr>" f"</tr>"
) )
if not rows:
rows = "<tr><td colspan='5'><em>No jobs yet.</em></td></tr>"
return rows
def render_page(error: str = "") -> str:
rows = render_job_rows()
err_html = f"<p class='error'>{error}</p>" if error else "" err_html = f"<p class='error'>{error}</p>" if error else ""
auth_note = "aktiv" if _auth_enabled() else "aus" auth_note = "aktiv" if _auth_enabled() else "aus"
return f""" return f"""
@@ -860,10 +871,18 @@ def render_page(error: str = "") -> str:
<meta charset="utf-8"> <meta charset="utf-8">
<title>JD → Jellyfin</title> <title>JD → Jellyfin</title>
<script> <script>
setInterval(() => {{ async function refreshJobs() {{
if (document.hidden) return; if (document.hidden) return;
window.location.reload(); try {{
}}, 5000); const resp = await fetch('/jobs');
if (!resp.ok) return;
const html = await resp.text();
const tbody = document.getElementById('jobs-body');
if (tbody) tbody.innerHTML = html;
}} catch (e) {{
}}
}}
setInterval(refreshJobs, 5000);
</script> </script>
</head> </head>
<body> <body>
@@ -901,8 +920,8 @@ def render_page(error: str = "") -> str:
<thead> <thead>
<tr><th>JobID</th><th>URL</th><th>Paket</th><th>Ziel</th><th>Status</th></tr> <tr><th>JobID</th><th>URL</th><th>Paket</th><th>Ziel</th><th>Status</th></tr>
</thead> </thead>
<tbody> <tbody id="jobs-body">
{rows if rows else "<tr><td colspan='5'><em>No jobs yet.</em></td></tr>"} {rows}
</tbody> </tbody>
</table> </table>
</body> </body>