feat(diarization-ui): document actions as icons with JS modal prompts (rename/move/delete)

This commit is contained in:
2026-03-21 14:35:26 +01:00
parent 1c9953251f
commit 3100aa22b3

37
app.py
View File

@@ -353,11 +353,44 @@ def view_document(doc_id: int):
raise HTTPException(404, "not found") raise HTTPException(404, "not found")
rendered = md.markdown(d["content_md"] or "", extensions=["fenced_code", "tables", "nl2br"]) rendered = md.markdown(d["content_md"] or "", extensions=["fenced_code", "tables", "nl2br"])
projects = get_projects()
project_list = "\\n".join([f"{p['id']}: {p['name']}" for p in projects])
body = f""" body = f"""
<h2>Dokument #{d['id']} {d['title']}</h2> <h2>Dokument #{d['id']} {d['title']}</h2>
<p><small>Projekt: {d['project']} · Typ: {d['kind']} · {d['created_at']}</small></p> <p>
<p><a href='/document/{doc_id}/download.md'>Download .md</a></p> <small>Projekt: {d['project']} · Typ: {d['kind']} · {d['created_at']}</small>
&nbsp;&nbsp;
<a title='Download .md' href='/document/{doc_id}/download.md' style='text-decoration:none'>⬇️</a>
<a title='Umbenennen' href='#' onclick='renameDoc();return false;' style='text-decoration:none'>✏️</a>
<a title='Verschieben' href='#' onclick='moveDoc();return false;' style='text-decoration:none'>📁</a>
<a title='Löschen' href='#' onclick='deleteDoc();return false;' style='text-decoration:none'>🗑️</a>
</p>
<div class='card mdview'>{rendered}</div> <div class='card mdview'>{rendered}</div>
<script>
async function postForm(url, data) {{
const body = new URLSearchParams(data);
const r = await fetch(url, {{method:'POST', headers:{{'Content-Type':'application/x-www-form-urlencoded'}}, body}});
if (!r.ok) {{ alert('Fehler: '+r.status); return; }}
location.href = '/library';
}}
function renameDoc() {{
const v = prompt('Neuer Dokumentname:', {json.dumps(d['title'])});
if (v===null) return;
postForm('/document/{doc_id}/rename', {{title:v}});
}}
function moveDoc() {{
const info = {json.dumps(project_list)};
const v = prompt('Ziel-Projekt-ID eingeben:\n'+info, '');
if (v===null) return;
postForm('/document/{doc_id}/move', {{project_id:v}});
}}
function deleteDoc() {{
if (!confirm('Dokument wirklich löschen?')) return;
postForm('/document/{doc_id}/delete', {{}});
}}
</script>
""" """
return layout("Dokument", body) return layout("Dokument", body)