/** Diagnose – passt exakt zur Backend-Antwort von /api/diagnostics */ import { api } from "../api.js"; import { escapeHtml } from "../app.js"; export async function renderDiagnose(content) { let diags; try { diags = await api.diagnostics(); } catch (err) { content.innerHTML = `
⚠️
Diagnose nicht verfügbar
${escapeHtml(err.message)}
`; return; } const report = buildReport(diags); const noIndex = diags.models_without_index_names || []; content.innerHTML = `
Anwendung
Version${escapeHtml(diags.version)}
Verarbeitung🚀 Echt
Runner${escapeHtml(diags.runner)} ${diags.runner_available ? "✓" : "✗"}
Applio-Commit${escapeHtml(diags.applio_commit)}
Python${escapeHtml(diags.python_version.split(" ")[0])}
FFmpeg${diags.ffmpeg_available ? "✓ verfügbar" : "✗ fehlt"}
Modelle & Indizes
Modelle gefunden${diags.models_found}
Modelle ohne Index${noIndex.length ? noIndex.length : "keine"}
${noIndex.length ? `
${noIndex.map(escapeHtml).join(", ")}
` : ""}
Speicher
Frei${(diags.disk?.free_gb ?? 0).toFixed(1)} GB
Belegt${(diags.disk?.used_gb ?? 0).toFixed(1)} GB
Gesamt${(diags.disk?.total_gb ?? 0).toFixed(1)} GB
Aufträge
Laufend${diags.running_jobs}
Letzter Fehler${diags.last_error ? escapeHtml(diags.last_error.error || diags.last_error.type) : "–"}
Letzter Erfolg${diags.last_success ? escapeHtml(diags.last_success.type) : "–"}
Konfigurierte Verzeichnisse
${Object.entries(diags.configured_dirs || {}).map(([k, v]) => ` `).join("")}
${escapeHtml(k)}${escapeHtml(v)}
Diagnosebericht
${escapeHtml(report)}
`; const copy = async () => { try { await navigator.clipboard.writeText(report); const btn = document.getElementById("copy-report"); if (btn) { btn.textContent = "✓ Kopiert"; setTimeout(() => { btn.textContent = "📋 Bericht kopieren"; }, 2000); } } catch { /* clipboard not available */ } }; document.getElementById("copy-report")?.addEventListener("click", copy); document.getElementById("copy-report-2")?.addEventListener("click", copy); } function buildReport(d) { const noIndex = d.models_without_index_names || []; const lines = [ "Mikes-Applio-UI Diagnosebericht", "================================", `Version: ${d.version}`, "Verarbeitung: ausschließlich echtes Applio", `Runner: ${d.runner} (verfügbar: ${d.runner_available ? "ja" : "nein"})`, `Applio-Commit: ${d.applio_commit}`, `Python: ${d.python_version}`, `Plattform: ${d.platform}`, `FFmpeg: ${d.ffmpeg_available ? "verfügbar" : "fehlt"}`, "", "Modelle:", ` Gefunden: ${d.models_found}`, ` Ohne Index: ${noIndex.length ? noIndex.join(", ") : "keine"}`, "", "Speicher:", ` Frei: ${d.disk?.free_gb?.toFixed(1)} GB`, ` Belegt: ${d.disk?.used_gb?.toFixed(1)} GB`, "", "Aufträge:", ` Laufend: ${d.running_jobs}`, ` Letzter Fehler: ${d.last_error ? d.last_error.error : "–"}`, ` Letzter Erfolg: ${d.last_success ? d.last_success.type : "–"}`, "", "Verzeichnisse:", ...Object.entries(d.configured_dirs || {}).map(([k, v]) => ` ${k}: ${v}`), ]; return lines.join("\n"); }