[32788f42] Keine Zusammenfassung angegeben.

Keine Zusammenfassung angegeben.
This commit is contained in:
2026-04-07 18:10:46 +00:00
parent 229ad10e6b
commit 831ec7e71c
4 changed files with 97 additions and 59 deletions

View File

@@ -171,24 +171,18 @@ function App() {
setProcessingJobId(job.id);
setError(null);
try {
const response = await fetch(`${API_BASE_URL}/api/jobs/${job.id}/generate-pdf?account_type=${activeTab}`);
if (!response.ok) {
const errData = await response.json();
throw new Error(errData.detail || 'PDF Generierung fehlgeschlagen');
}
// Direkter Download über die URL, umgeht das Blob/Mixed-Content-Sicherheitsproblem in Chrome.
const downloadUrl = `${API_BASE_URL}/api/jobs/${job.id}/generate-pdf?account_type=${activeTab}`;
window.open(downloadUrl, '_blank');
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `Listen_${job.name.replace(/\s+/g, "_")}.pdf`;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
// Wir setzen einen künstlichen Timeout für den Lade-Indikator,
// da wir bei window.open nicht wissen, wann der Download fertig ist.
setTimeout(() => {
setProcessingJobId(null);
}, 3000);
} catch (err: any) {
setError(`PDF Fehler (${job.name}): ${err.message}`);
} finally {
setProcessingJobId(null);
}
};
@@ -228,8 +222,12 @@ function App() {
a.download = `QR_Karten_Andruck_${job.id}.pdf`;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
// Delay removal and revocation to ensure download starts in all browsers
setTimeout(() => {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 100);
} catch (err: any) {
setError(err.message);
} finally {
@@ -241,28 +239,14 @@ function App() {
setIsListGenerating(true);
setError(null);
try {
const response = await fetch(`${API_BASE_URL}/api/jobs/${job.id}/appointment-list?event_type_name=${encodeURIComponent(selectedEventType)}`);
const downloadUrl = `${API_BASE_URL}/api/jobs/${job.id}/appointment-list?event_type_name=${encodeURIComponent(selectedEventType)}`;
window.open(downloadUrl, '_blank');
if (!response.ok) {
if (response.status === 404) {
throw new Error("Keine passenden Calendly-Termine gefunden.");
}
const errData = await response.json();
throw new Error(errData.detail || 'PDF Generierung fehlgeschlagen');
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `Terminuebersicht_${job.name.replace(/\s+/g, "_")}.pdf`;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
setTimeout(() => {
setIsListGenerating(false);
}, 3000);
} catch (err: any) {
setError(`Listen-Fehler (${job.name}): ${err.message}`);
} finally {
setIsListGenerating(false);
}
};
@@ -300,9 +284,18 @@ function App() {
{/* Top Navigation Bar */}
<header className="bg-white shadow-sm sticky top-0 z-10">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between">
<div className="flex items-center gap-2">
<span className="text-2xl">📸</span>
<h1 className="text-xl font-bold text-gray-800 tracking-tight">Fotograf.de ERP</h1>
<div className="flex items-center gap-6">
<div className="flex items-center gap-2">
<span className="text-2xl">📸</span>
<h1 className="text-xl font-bold text-gray-800 tracking-tight">Fotograf.de ERP</h1>
</div>
<a
href="http://192.168.178.6:8090"
className="hidden sm:flex text-xs font-medium text-gray-500 hover:text-indigo-600 transition-colors items-center gap-1 bg-gray-50 px-2 py-1 rounded border border-gray-200"
>
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" /></svg>
Zum Dashboard
</a>
</div>
{/* Main Tabs */}