feat: add explicit toast type parameters to all showToast calls for consistent error and success notifications

This commit is contained in:
Bruno Charest 2026-03-25 08:15:27 -04:00
parent 6108cfd486
commit 8c30b0d238

View File

@ -1223,7 +1223,7 @@
res = await fetch(path, mergedOpts);
} catch (err) {
if (err.name === "AbortError") throw err; // let callers handle abort
showToast("Erreur réseau — vérifiez votre connexion");
showToast("Erreur réseau — vérifiez votre connexion", "error");
throw err;
}
if (res.status === 401 && AuthManager._authEnabled) {
@ -1245,7 +1245,7 @@
if (!res.ok) {
var detail = "";
try { var body = await res.json(); detail = body.detail || ""; } catch (_) { /* no json body */ }
showToast(detail || "Erreur API : " + res.status);
showToast(detail || "Erreur API : " + res.status, "error");
throw new Error(detail || "API error: " + res.status);
}
return res.json();
@ -1679,7 +1679,7 @@
this._loadUsers();
showToast(isEdit ? 'Utilisateur modifié' : 'Utilisateur créé', 'success');
} catch (err) {
showToast(err.message);
showToast(err.message, 'error');
}
});
},
@ -1687,7 +1687,7 @@
async _deleteUser(username) {
const currentUser = AuthManager.getUser();
if (currentUser && currentUser.username === username) {
showToast('Impossible de supprimer son propre compte');
showToast('Impossible de supprimer son propre compte', 'error');
return;
}
if (!confirm('Supprimer l\'utilisateur "' + username + '" ?')) return;
@ -1696,7 +1696,7 @@
this._loadUsers();
showToast('Utilisateur supprimé', 'success');
} catch (err) {
showToast(err.message);
showToast(err.message, 'error');
}
},
};
@ -2575,7 +2575,7 @@
setTimeout(() => (copyBtn.lastChild.textContent = "Copier"), 1500);
} catch (err) {
console.error("Copy error:", err);
showToast("Erreur lors de la copie");
showToast("Erreur lors de la copie", "error");
}
});
@ -3102,7 +3102,7 @@
search_timeout_ms: _getFieldNum("cfg-timeout", 30000),
};
localStorage.setItem(_FRONTEND_CONFIG_KEY, JSON.stringify(cfg));
showToast("Paramètres client sauvegardés");
showToast("Paramètres client sauvegardés", "success");
}
async function saveBackendConfig() {
@ -3141,12 +3141,12 @@
if (btn) { btn.disabled = true; btn.textContent = "Réindexation..."; }
try {
await api("/api/index/reload");
showToast("Réindexation terminée");
showToast("Réindexation terminée", "success");
loadDiagnostics();
await Promise.all([loadVaults(), loadTags()]);
} catch (err) {
console.error("Reindex error:", err);
showToast("Erreur de réindexation");
showToast("Erreur de réindexation", "error");
} finally {
if (btn) { btn.disabled = false; btn.textContent = "Forcer réindexation"; }
}
@ -3169,7 +3169,7 @@
});
} catch (err) { console.error("Reset config error:", err); }
loadConfigFields();
showToast("Configuration réinitialisée");
showToast("Configuration réinitialisée", "success");
}
async function loadDiagnostics() {
@ -5270,7 +5270,7 @@
}
} catch (err) {
console.error("Failed to initialize ObsiGate:", err);
showToast("Erreur lors de l'initialisation");
showToast("Erreur lors de l'initialisation", "error");
}
}
@ -5355,7 +5355,7 @@
// Log when app is installed
window.addEventListener('appinstalled', () => {
console.log('[PWA] ObsiGate has been installed');
showToast('ObsiGate installé avec succès !');
showToast('ObsiGate installé avec succès !', 'success');
});
document.addEventListener("DOMContentLoaded", () => {