feat(diarization-ui): document actions as icons with JS modal prompts (rename/move/delete)
This commit is contained in:
37
app.py
37
app.py
@@ -353,11 +353,44 @@ def view_document(doc_id: int):
|
||||
raise HTTPException(404, "not found")
|
||||
|
||||
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"""
|
||||
<h2>Dokument #{d['id']} – {d['title']}</h2>
|
||||
<p><small>Projekt: {d['project']} · Typ: {d['kind']} · {d['created_at']}</small></p>
|
||||
<p><a href='/document/{doc_id}/download.md'>Download .md</a></p>
|
||||
<p>
|
||||
<small>Projekt: {d['project']} · Typ: {d['kind']} · {d['created_at']}</small>
|
||||
|
||||
<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>
|
||||
|
||||
<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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user