Logo-Upload: Bild hochladen/loeschen via Settings, Einbindung in PDF mit Fallback auf Text

This commit is contained in:
Erik Thiele
2026-07-02 15:13:41 +02:00
parent 2bd4d19034
commit 69a108e5b3
3 changed files with 96 additions and 13 deletions

View File

@@ -139,6 +139,41 @@ function showNotification(msg) {
setTimeout(() => { container.style.display = 'none'; }, 2500);
}
/** Logo hochladen via AJAX. */
async function uploadLogo() {
const input = document.getElementById('logo-upload');
if (!input.files || !input.files[0]) {
showNotification('Bitte eine Datei auswaehlen');
return;
}
const formData = new FormData();
formData.append('logo', input.files[0]);
try {
const res = await fetch('/upload_logo', { method: 'POST', body: formData });
const data = await res.json();
if (data.status === 'ok') {
showNotification('Logo gespeichert!');
setTimeout(() => location.reload(), 800);
}
} catch (e) {
showNotification('Fehler beim Hochladen');
}
}
/** Logo loeschen. */
async function deleteLogo() {
try {
const res = await fetch('/delete_logo', { method: 'POST' });
const data = await res.json();
if (data.status === 'ok') {
showNotification('Logo entfernt');
setTimeout(() => location.reload(), 800);
}
} catch (e) {
showNotification('Fehler beim Loeschen');
}
}
/** Initiale Berechnung beim Seitenladen. */
document.addEventListener('DOMContentLoaded', () => {
recalculate();