Show notifications as slide-in toasts with success, warning and error states

Toasts use the success colour with a check mark, errors and warnings get their own colours and icons, and the text is larger. Error toasts stay visible longer.
This commit is contained in:
Sucukdeluxe committed 2026-09-26 10:19:15 +02:00
1 parent f8c3f00de7
commit 461712b6bc
2 files changed
+76 -33

No files matched your search

+27 -26
View File
@@ -1376,7 +1376,7 @@ async function toggleAutomationPauseResume() {
} }
} }
} catch { } catch {
showCopyToast(localizeUiText(resume ? 'Automatik konnte nicht fortgesetzt werden.' : 'Automatik konnte nicht pausiert werden.')); showCopyToast(localizeUiText(resume ? 'Automatik konnte nicht fortgesetzt werden.' : 'Automatik konnte nicht pausiert werden.'), 6000, 'error');
} finally { } finally {
automationPauseResumeBusy = false; automationPauseResumeBusy = false;
refreshAutomationControlCenter(); refreshAutomationControlCenter();
@@ -1463,7 +1463,7 @@ async function init() {
renderHosterSummary(); renderHosterSummary();
renderHosterModal(); renderHosterModal();
renderSettings(); renderSettings();
if (!_startupQueueEvidenceAvailable) showCopyToast('Automatische Wiederaufnahme wurde wegen nicht verfügbarer Abschlussnachweise blockiert.', 9000); if (!_startupQueueEvidenceAvailable) showCopyToast('Automatische Wiederaufnahme wurde wegen nicht verfügbarer Abschlussnachweise blockiert.', 9000, 'warning');
renderAccounts(); renderAccounts();
setupListeners(); setupListeners();
importEntryCoordinator.ready(); importEntryCoordinator.ready();
@@ -1512,7 +1512,7 @@ async function init() {
window.api.onShutdownCountdown(handleShutdownCountdown); window.api.onShutdownCountdown(handleShutdownCountdown);
window.api.onUploadLogFallback((data) => { window.api.onUploadLogFallback((data) => {
const path = data && data.fallbackPath ? data.fallbackPath : '(Fallback)'; const path = data && data.fallbackPath ? data.fallbackPath : '(Fallback)';
showCopyToast(`Log-Pfad nicht beschreibbar — schreibe nach: ${path}`, 8000); showCopyToast(`Log-Pfad nicht beschreibbar — schreibe nach: ${path}`, 8000, 'warning');
}); });
window.api.onLogPathAutoUpdated((data) => { window.api.onLogPathAutoUpdated((data) => {
if (!data || !data.logFilePath) return; if (!data || !data.logFilePath) return;
@@ -1804,8 +1804,8 @@ async function _handleMenuAction(action) {
const res = await window.api.createSupportBundle(); const res = await window.api.createSupportBundle();
if (res && res.ok) showCopyToast(`Diagnose-Paket gespeichert (${(res.bytes / 1024).toFixed(1)} KB)`); if (res && res.ok) showCopyToast(`Diagnose-Paket gespeichert (${(res.bytes / 1024).toFixed(1)} KB)`);
else if (res && res.canceled) showCopyToast('Abgebrochen'); else if (res && res.canceled) showCopyToast('Abgebrochen');
else showCopyToast(`Fehler: ${(res && res.error) || 'unbekannt'}`); else showCopyToast(`Fehler: ${(res && res.error) || 'unbekannt'}`, 6000, 'error');
} catch (err) { showCopyToast(`Fehler: ${err.message || err}`); } } catch (err) { showCopyToast(`Fehler: ${err.message || err}`, 6000, 'error'); }
break; break;
} }
case 'check-updates': { case 'check-updates': {
@@ -1868,14 +1868,14 @@ async function requestUpdateCheck({ forceRefresh = true } = {}) {
if (result && result.available) { if (result && result.available) {
showUpdateBanner(result); showUpdateBanner(result);
} else if (result && result.error) { } else if (result && result.error) {
showCopyToast('Updateprüfung fehlgeschlagen'); showCopyToast('Updateprüfung fehlgeschlagen', 6000, 'error');
} else { } else {
_knownUpdateInfo = null; _knownUpdateInfo = null;
showCopyToast('Kein Update verfügbar'); showCopyToast('Kein Update verfügbar');
} }
return result; return result;
} catch { } catch {
showCopyToast('Updateprüfung fehlgeschlagen'); showCopyToast('Updateprüfung fehlgeschlagen', 6000, 'error');
return null; return null;
} finally { } finally {
_updateCheckBusy = false; _updateCheckBusy = false;
@@ -2245,7 +2245,7 @@ async function applyHosterSelection() {
} }
} catch { } catch {
const failure = { ok: false, error: 'Automatische Aufnahme konnte nicht abgeschlossen werden.' }; const failure = { ok: false, error: 'Automatische Aufnahme konnte nicht abgeschlossen werden.' };
showCopyToast(failure.error, 6500); showCopyToast(failure.error, 6500, 'error');
document.getElementById('hosterModal').style.display = 'flex'; document.getElementById('hosterModal').style.display = 'flex';
renderImportPlanSummary(); renderImportPlanSummary();
return failure; return failure;
@@ -2621,7 +2621,7 @@ function coordinateImportEntries(entries, options = {}) {
inspection = await window.api.inspectImportFiles(candidates, existingImportPaths()); inspection = await window.api.inspectImportFiles(candidates, existingImportPaths());
} catch { } catch {
if (generation !== _importGeneration) return null; if (generation !== _importGeneration) return null;
showCopyToast('Vorabprüfung fehlgeschlagen.', 6500); showCopyToast('Vorabprüfung fehlgeschlagen.', 6500, 'error');
return null; return null;
} }
if (generation !== _importGeneration) return null; if (generation !== _importGeneration) return null;
@@ -3755,7 +3755,7 @@ async function persistImportedQueueState() {
} }
function showImportQueuePersistenceError(error) { function showImportQueuePersistenceError(error) {
showCopyToast(`Import übernommen. Warteschlange konnte nicht vollständig gespeichert werden: ${error.message || error}`, 8000); showCopyToast(`Import übernommen. Warteschlange konnte nicht vollständig gespeichert werden: ${error.message || error}`, 8000, 'warning');
} }
function beginOnlineBackupStatusContext() { function beginOnlineBackupStatusContext() {
@@ -4040,12 +4040,12 @@ async function copyManagedOnlineBackup(entry) {
try { try {
const result = await window.api.copyManagedOnlineBackup(id); const result = await window.api.copyManagedOnlineBackup(id);
if (!result?.ok) { if (!result?.ok) {
showCopyToast(result?.error || 'Online-Sicherung konnte nicht kopiert werden'); showCopyToast(result?.error || 'Online-Sicherung konnte nicht kopiert werden', 6000, 'error');
return; return;
} }
showCopyToast('Online-Schlüssel kopiert'); showCopyToast('Online-Schlüssel kopiert');
} catch { } catch {
showCopyToast('Online-Sicherung konnte nicht kopiert werden'); showCopyToast('Online-Sicherung konnte nicht kopiert werden', 6000, 'error');
} }
}); });
renderManagedOnlineBackups(focusTarget); renderManagedOnlineBackups(focusTarget);
@@ -4783,7 +4783,7 @@ async function startSelectedUpload(explicitJobs) {
restoreUploadJobStates(originalStates); restoreUploadJobStates(originalStates);
renderQueueTable(); renderQueueTable();
const error = sanitizeUploadControlError(err, 'Jobs konnten nicht hinzugefügt werden.'); const error = sanitizeUploadControlError(err, 'Jobs konnten nicht hinzugefügt werden.');
showCopyToast(error); showCopyToast(error, 6000, 'error');
return { ok: false, error }; return { ok: false, error };
} }
@@ -4800,7 +4800,7 @@ async function startSelectedUpload(explicitJobs) {
restoreUploadJobStates(originalStates); restoreUploadJobStates(originalStates);
renderQueueTable(); renderQueueTable();
const error = sanitizeUploadControlError(result.error, 'Jobs konnten nicht hinzugefügt werden.'); const error = sanitizeUploadControlError(result.error, 'Jobs konnten nicht hinzugefügt werden.');
showCopyToast(error); showCopyToast(error, 6000, 'error');
return { ok: false, error }; return { ok: false, error };
} }
const outcome = applyAddJobsOutcome(addable, result, { const outcome = applyAddJobsOutcome(addable, result, {
@@ -4812,7 +4812,7 @@ async function startSelectedUpload(explicitJobs) {
if (!outcome.consistent) { if (!outcome.consistent) {
persistQueueStateSoon(); persistQueueStateSoon();
const error = 'Jobs konnten nicht eindeutig bestätigt werden.'; const error = 'Jobs konnten nicht eindeutig bestätigt werden.';
showCopyToast(error); showCopyToast(error, 6000, 'error');
return { ok: false, error }; return { ok: false, error };
} }
applyAddJobsFingerprints(addRequest, result?.sourceCleanupFingerprints); applyAddJobsFingerprints(addRequest, result?.sourceCleanupFingerprints);
@@ -4828,7 +4828,7 @@ async function startSelectedUpload(explicitJobs) {
if (alreadyInBatch > 0) toastParts.push(`${alreadyInBatch} bereits im Batch`); if (alreadyInBatch > 0) toastParts.push(`${alreadyInBatch} bereits im Batch`);
if (skipped > 0) toastParts.push(`${skipped} ohne gueltigen Account`); if (skipped > 0) toastParts.push(`${skipped} ohne gueltigen Account`);
if (result && result.error) { if (result && result.error) {
showCopyToast(`Jobs konnten nicht hinzugefügt werden: ${result.error}`); showCopyToast(`Jobs konnten nicht hinzugefügt werden: ${result.error}`, 6000, 'error');
} else if (toastParts.length > 0) { } else if (toastParts.length > 0) {
showCopyToast(`Jobs: ${toastParts.join(', ')}`); showCopyToast(`Jobs: ${toastParts.join(', ')}`);
} else { } else {
@@ -8351,7 +8351,7 @@ async function deleteAccount(accountId) {
// source of perceived lag on add/delete. // source of perceived lag on add/delete.
saveConfigTracked({ hosters: config.hosters }).catch((err) => { saveConfigTracked({ hosters: config.hosters }).catch((err) => {
if (window.api && window.api.debugLog) window.api.debugLog(`deleteAccount saveConfig failed: ${err && err.message ? err.message : err}`); if (window.api && window.api.debugLog) window.api.debugLog(`deleteAccount saveConfig failed: ${err && err.message ? err.message : err}`);
showCopyToast('Account-Löschung konnte nicht persistiert werden — bitte erneut versuchen.'); showCopyToast('Account-Löschung konnte nicht persistiert werden — bitte erneut versuchen.', 6000, 'error');
}); });
} }
@@ -8686,7 +8686,7 @@ async function confirmHistoryClear() {
await loadHistory(); await loadHistory();
closeHistoryClearModal(); closeHistoryClearModal();
} catch (error) { } catch (error) {
showCopyToast(error.message || String(error)); showCopyToast(error.message || String(error), 6000, 'error');
} finally { } finally {
confirmButton.disabled = false; confirmButton.disabled = false;
cancelButton.disabled = false; cancelButton.disabled = false;
@@ -9170,12 +9170,12 @@ async function recoverWindowClose(generation, attempt, originalError) {
try { try {
restored = await waitForClosePreparationStep(window.api.finishClosePreparation({ ready: false, attempt })); restored = await waitForClosePreparationStep(window.api.finishClosePreparation({ ready: false, attempt }));
} catch (error) { } catch (error) {
if (isCurrentClosePreparation(generation, attempt)) showCopyToast(error.message || String(error), 8000); if (isCurrentClosePreparation(generation, attempt)) showCopyToast(error.message || String(error), 8000, 'error');
return; return;
} }
if (!isCurrentClosePreparation(generation, attempt)) return; if (!isCurrentClosePreparation(generation, attempt)) return;
if (restored !== true) { if (restored !== true) {
showCopyToast('Die Anwendung konnte nach dem fehlgeschlagenen Speichern nicht entsperrt werden', 8000); showCopyToast('Die Anwendung konnte nach dem fehlgeschlagenen Speichern nicht entsperrt werden', 8000, 'error');
return; return;
} }
try { try {
@@ -9187,7 +9187,7 @@ async function recoverWindowClose(generation, attempt, originalError) {
if (failedConfigWriteOperations.length !== 0) throw new Error('Nicht alle Einstellungen konnten gespeichert werden'); if (failedConfigWriteOperations.length !== 0) throw new Error('Nicht alle Einstellungen konnten gespeichert werden');
})); }));
} catch (error) { } catch (error) {
if (isCurrentClosePreparation(generation, attempt)) showCopyToast(error.message || String(error), 8000); if (isCurrentClosePreparation(generation, attempt)) showCopyToast(error.message || String(error), 8000, 'error');
return; return;
} }
if (!isCurrentClosePreparation(generation, attempt)) return; if (!isCurrentClosePreparation(generation, attempt)) return;
@@ -9195,7 +9195,7 @@ async function recoverWindowClose(generation, attempt, originalError) {
activeClosePreparationAttempt = null; activeClosePreparationAttempt = null;
closePreparationState = 'open'; closePreparationState = 'open';
setClosePreparationUi(false); setClosePreparationUi(false);
showCopyToast(originalError.message || String(originalError), 8000); showCopyToast(originalError.message || String(originalError), 8000, 'error');
} }
function prepareForWindowClose(attempt) { function prepareForWindowClose(attempt) {
@@ -9489,7 +9489,7 @@ function setupListeners() {
} catch (error) { } catch (error) {
historyRetentionSelect.value = prev; historyRetentionSelect.value = prev;
syncHistoryRetentionPicker(); syncHistoryRetentionPicker();
showCopyToast(error.message || String(error)); showCopyToast(error.message || String(error), 6000, 'error');
} }
}); });
} }
@@ -10105,7 +10105,7 @@ async function importUploadLog() {
}; };
}).filter(row => hasFiniteMetadata(row.size) && hasFiniteMetadata(row.mtimeMs)); }).filter(row => hasFiniteMetadata(row.size) && hasFiniteMetadata(row.mtimeMs));
if (completionRows.length !== matchingJobs.length) { if (completionRows.length !== matchingJobs.length) {
showCopyToast('Abschlussnachweise konnten nicht vollständig ermittelt werden.', 7000); showCopyToast('Abschlussnachweise konnten nicht vollständig ermittelt werden.', 7000, 'warning');
return; return;
} }
if (completionRows.length > 0 && typeof window.api.recordAutomationCompletions === 'function') { if (completionRows.length > 0 && typeof window.api.recordAutomationCompletions === 'function') {
@@ -10113,7 +10113,7 @@ async function importUploadLog() {
await window.api.recordAutomationCompletions(completionRows); await window.api.recordAutomationCompletions(completionRows);
invalidateAutomationEvidenceSnapshot(); invalidateAutomationEvidenceSnapshot();
} catch { } catch {
showCopyToast('Abschlussnachweise konnten nicht gespeichert werden.', 7000); showCopyToast('Abschlussnachweise konnten nicht gespeichert werden.', 7000, 'error');
return; return;
} }
} }
@@ -10352,9 +10352,10 @@ function escapeAttr(str) {
return String(str).replace(_ATTR_ESC_RE, (c) => _ATTR_ESC_MAP[c]); return String(str).replace(_ATTR_ESC_RE, (c) => _ATTR_ESC_MAP[c]);
} }
function showCopyToast(msg, durationMs) { function showCopyToast(msg, durationMs, state = 'success') {
const toast = document.getElementById('copyToast'); const toast = document.getElementById('copyToast');
toast.textContent = localizeUiText(msg); toast.textContent = localizeUiText(msg);
toast.dataset.state = state === 'error' || state === 'warning' ? state : 'success';
toast.classList.add('show'); toast.classList.add('show');
clearTimeout(toast._timer); clearTimeout(toast._timer);
toast._timer = setTimeout(() => toast.classList.remove('show'), durationMs || 1500); toast._timer = setTimeout(() => toast.classList.remove('show'), durationMs || 1500);
+49 -7
View File
@@ -4434,22 +4434,64 @@ input[type="checkbox"] {
.copy-toast { .copy-toast {
top: 60px; top: 60px;
right: 12px; right: 16px;
bottom: auto; bottom: auto;
left: auto; left: auto;
display: flex;
align-items: center;
gap: 9px;
width: max-content; width: max-content;
max-width: min(420px, calc(100vw - 24px)); max-width: min(440px, calc(100vw - 32px));
padding: 9px 14px;
overflow-wrap: anywhere; overflow-wrap: anywhere;
white-space: normal; white-space: normal;
transform: translateY(-8px); transform: translateX(28px);
border-radius: 6px; border-radius: 7px;
background: rgba(35, 35, 35, .96); background: var(--success);
color: var(--success); color: #082616;
box-shadow: 0 12px 30px rgba(0, 0, 0, .38); box-shadow: 0 12px 30px rgba(0, 0, 0, .38);
font-size: 14px;
font-weight: 600;
line-height: 1.35;
transition: opacity .22s ease, transform .32s cubic-bezier(.22, 1, .36, 1);
}
.copy-toast::before {
content: "";
flex: 0 0 auto;
width: 5px;
height: 10px;
margin: 0 3px 3px 2px;
border-right: 2px solid currentColor;
border-bottom: 2px solid currentColor;
transform: rotate(45deg);
}
.copy-toast[data-state="error"] {
background: var(--danger);
color: #2b070a;
}
.copy-toast[data-state="warning"] {
background: #fbbf24;
color: #2a1b00;
}
.copy-toast[data-state="error"]::before,
.copy-toast[data-state="warning"]::before {
content: "!";
width: auto;
height: auto;
margin: 0 2px 0 0;
border: 0;
transform: none;
font-size: 16px;
font-weight: 800;
line-height: 1;
} }
.copy-toast.show { .copy-toast.show {
transform: translateY(0); transform: translateX(0);
} }
.status-badge { .status-badge {