fix: move reprocess button to transcript list item, remove from modal
This commit is contained in:
+16
-16
@@ -10,7 +10,6 @@ const modalTitle = document.getElementById('modal-title');
|
||||
const modalBody = document.getElementById('modal-body');
|
||||
const modalOpenBtn = document.getElementById('modal-open-btn');
|
||||
const modalCloseBtn = document.getElementById('modal-close-btn');
|
||||
const modalReprocessBtn = document.getElementById('modal-reprocess-btn');
|
||||
let _modalPath = null;
|
||||
let _modalFilename = null;
|
||||
|
||||
@@ -69,20 +68,6 @@ modalOpenBtn.addEventListener('click', () => {
|
||||
if (_modalPath) apiFetch('/open', { method: 'POST', body: JSON.stringify({ path: _modalPath }) });
|
||||
});
|
||||
|
||||
modalReprocessBtn.addEventListener('click', async () => {
|
||||
if (!_modalFilename) return;
|
||||
modalReprocessBtn.disabled = true;
|
||||
modalBody.textContent = 'Wird neu verarbeitet\u2026';
|
||||
const instructions = instructionsEl.value;
|
||||
const r = await apiFetch(`/transcripts/${encodeURIComponent(_modalFilename)}/reprocess`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ instructions }),
|
||||
});
|
||||
const md = await r.text();
|
||||
modalBody.innerHTML = DOMPurify.sanitize(marked.parse(md));
|
||||
modalReprocessBtn.disabled = false;
|
||||
});
|
||||
|
||||
instructionsEl.addEventListener('input', async () => {
|
||||
await apiFetch('/instructions', {
|
||||
method: 'POST',
|
||||
@@ -145,6 +130,21 @@ async function loadTranscripts() {
|
||||
|
||||
div.addEventListener('click', () => openModal(t.filename, t.path));
|
||||
|
||||
const reprocessBtn = document.createElement('button');
|
||||
reprocessBtn.className = 'del-btn';
|
||||
reprocessBtn.title = 'Neu verarbeiten';
|
||||
reprocessBtn.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M17.65 6.35A7.96 7.96 0 0 0 12 4a8 8 0 1 0 8 8h-2a6 6 0 1 1-1.76-4.24l-2.24 2.24H20V4l-2.35 2.35z"/></svg>';
|
||||
reprocessBtn.addEventListener('click', async (e) => {
|
||||
e.stopPropagation();
|
||||
reprocessBtn.disabled = true;
|
||||
await apiFetch(`/transcripts/${encodeURIComponent(t.filename)}/reprocess`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ instructions: instructionsEl.value }),
|
||||
});
|
||||
reprocessBtn.disabled = false;
|
||||
loadTranscripts();
|
||||
});
|
||||
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.className = 'del-btn';
|
||||
delBtn.title = 'Löschen';
|
||||
@@ -155,7 +155,7 @@ async function loadTranscripts() {
|
||||
loadTranscripts();
|
||||
});
|
||||
|
||||
div.append(name, meta, delBtn);
|
||||
div.append(name, meta, reprocessBtn, delBtn);
|
||||
return div;
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user