fix(diarization-ui): redirect after fallback job cancel/delete forms instead of showing JSON
This commit is contained in:
23
app.py
23
app.py
@@ -10,7 +10,7 @@ from typing import Optional
|
||||
import markdown as md
|
||||
import requests
|
||||
from fastapi import FastAPI, File, Form, HTTPException, UploadFile
|
||||
from fastapi.responses import HTMLResponse, PlainTextResponse, Response, JSONResponse
|
||||
from fastapi.responses import HTMLResponse, PlainTextResponse, Response, JSONResponse, RedirectResponse
|
||||
|
||||
API_BASE = os.getenv("API_BASE", "http://gx10.aquantico.lan:8093").rstrip("/")
|
||||
OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://gx10.aquantico.lan:11434").rstrip("/")
|
||||
@@ -754,12 +754,17 @@ def jobs_cancel(job_id: int):
|
||||
j = _job_get(job_id)
|
||||
if not j:
|
||||
raise HTTPException(404, "job not found")
|
||||
if j["status"] in ("done", "error", "cancelled"):
|
||||
return {"ok": True, "status": j["status"]}
|
||||
_job_set(job_id, status="cancelled", finished_at=now_iso(), error="Cancelled by user")
|
||||
if j["status"] not in ("done", "error", "cancelled"):
|
||||
_job_set(job_id, status="cancelled", finished_at=now_iso(), error="Cancelled by user")
|
||||
return {"ok": True, "status": "cancelled"}
|
||||
|
||||
|
||||
@app.post("/jobs/{job_id}/cancel-form")
|
||||
def jobs_cancel_form(job_id: int):
|
||||
jobs_cancel(job_id)
|
||||
return RedirectResponse(url="/jobs", status_code=303)
|
||||
|
||||
|
||||
@app.post("/jobs/{job_id}/delete")
|
||||
def jobs_delete(job_id: int):
|
||||
with db() as c:
|
||||
@@ -767,6 +772,12 @@ def jobs_delete(job_id: int):
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@app.post("/jobs/{job_id}/delete-form")
|
||||
def jobs_delete_form(job_id: int):
|
||||
jobs_delete(job_id)
|
||||
return RedirectResponse(url="/jobs", status_code=303)
|
||||
|
||||
|
||||
@app.get("/jobs", response_class=HTMLResponse)
|
||||
def jobs_page(queued: Optional[int] = None):
|
||||
items = _jobs_payload(200)
|
||||
@@ -779,12 +790,12 @@ def jobs_page(queued: Optional[int] = None):
|
||||
""
|
||||
if it["status"] in ("done", "error", "cancelled")
|
||||
else (
|
||||
f"<form method='post' action='/jobs/{it['id']}/cancel' style='display:inline'>"
|
||||
f"<form method='post' action='/jobs/{it['id']}/cancel-form' style='display:inline'>"
|
||||
f"<button class='iconbtn' title='Abbrechen'>⛔</button></form> "
|
||||
)
|
||||
)
|
||||
+ (
|
||||
f"<form method='post' action='/jobs/{it['id']}/delete' style='display:inline'>"
|
||||
f"<form method='post' action='/jobs/{it['id']}/delete-form' style='display:inline'>"
|
||||
f"<button class='iconbtn' title='Löschen'>🗑️</button></form> "
|
||||
)
|
||||
+ (
|
||||
|
||||
Reference in New Issue
Block a user