Phase 3a Frontend-Hygiene: Toast statt alert/confirm
- src/static/css/style.css: Toast-Styles (.toast-container, .toast,
Varianten info/success/warning/error, Animations)
- src/static/dashboard.html: <div id=toastContainer> vor </body>,
Cancel-Button im Confirm-Modal bekommt id=confirmCancelBtn
- src/static/js/app.js:
- showToast(msg, type) neu - links oben, autoclose 3.5s (error: 6s)
- showConfirm(title, text, callback?) jetzt Promise<boolean>-fähig
(Backwards-compat: Legacy-Callback wird bei OK weiter aufgerufen)
- Cancel/Close-Hooks am modalConfirm setzen Promise auf false
- alle 18 alert() in app.js / source-health.js / sources.js durch
showToast(msg, type) ersetzt (type je nach Kontext error/success/warning/info)
- 2 confirm() in source-health.js durch await showConfirm() ersetzt
Dieser Commit ist enthalten in:
@@ -202,18 +202,19 @@ async function handleSuggestion(id, accept) {
|
||||
const suggestion = suggestionsCache.find((s) => s.id === id);
|
||||
if (!suggestion) return;
|
||||
|
||||
if (!confirm(`Vorschlag "${suggestion.title}" ${action}?`)) return;
|
||||
const ok = await showConfirm("Vorschlag " + (action === "annehmen" ? "annehmen" : "ablehnen"), `Soll "${suggestion.title}" ${action}?`);
|
||||
if (!ok) return;
|
||||
|
||||
try {
|
||||
const result = await API.put("/api/sources/suggestions/" + id, { accept });
|
||||
if (result.action) {
|
||||
alert(`Ergebnis: ${result.action}`);
|
||||
showToast("Ergebnis: " + result.action, "success");
|
||||
}
|
||||
loadHealthData();
|
||||
// Grundquellen-Liste auch aktualisieren
|
||||
if (typeof loadGlobalSources === "function") loadGlobalSources();
|
||||
} catch (err) {
|
||||
alert("Fehler: " + err.message);
|
||||
showToast("Fehler: " + err.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +323,8 @@ function formatDateTime(dateStr) {
|
||||
async function searchFix(btn) {
|
||||
const sourceId = btn.dataset.sourceId;
|
||||
const sourceName = btn.dataset.sourceName;
|
||||
if (!confirm(`Sonnet mit WebSearch nach einer Lösung für "${sourceName}" suchen lassen?\n\nDas kann einige Minuten dauern.`)) return;
|
||||
const ok = await showConfirm("Lösung suchen", `Sonnet mit WebSearch nach einer Lösung für "${sourceName}" suchen lassen? Das kann einige Minuten dauern.`);
|
||||
if (!ok) return;
|
||||
|
||||
btn.disabled = true;
|
||||
btn.textContent = "Sucht...";
|
||||
@@ -337,10 +339,10 @@ async function searchFix(btn) {
|
||||
if (result.cost_usd) {
|
||||
msg += `\n\nKosten: $${result.cost_usd.toFixed(2)}`;
|
||||
}
|
||||
alert(msg);
|
||||
showToast(msg, "info");
|
||||
loadHealthData();
|
||||
} catch (err) {
|
||||
alert("Fehler: " + err.message);
|
||||
showToast("Fehler: " + err.message, "error");
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = "Lösung suchen";
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren