feat: add explicit toast type parameters to all showToast calls for consistent error and success notifications
This commit is contained in:
parent
6108cfd486
commit
8c30b0d238
@ -1223,7 +1223,7 @@
|
|||||||
res = await fetch(path, mergedOpts);
|
res = await fetch(path, mergedOpts);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.name === "AbortError") throw err; // let callers handle abort
|
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;
|
throw err;
|
||||||
}
|
}
|
||||||
if (res.status === 401 && AuthManager._authEnabled) {
|
if (res.status === 401 && AuthManager._authEnabled) {
|
||||||
@ -1245,7 +1245,7 @@
|
|||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
var detail = "";
|
var detail = "";
|
||||||
try { var body = await res.json(); detail = body.detail || ""; } catch (_) { /* no json body */ }
|
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);
|
throw new Error(detail || "API error: " + res.status);
|
||||||
}
|
}
|
||||||
return res.json();
|
return res.json();
|
||||||
@ -1679,7 +1679,7 @@
|
|||||||
this._loadUsers();
|
this._loadUsers();
|
||||||
showToast(isEdit ? 'Utilisateur modifié' : 'Utilisateur créé', 'success');
|
showToast(isEdit ? 'Utilisateur modifié' : 'Utilisateur créé', 'success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showToast(err.message);
|
showToast(err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1687,7 +1687,7 @@
|
|||||||
async _deleteUser(username) {
|
async _deleteUser(username) {
|
||||||
const currentUser = AuthManager.getUser();
|
const currentUser = AuthManager.getUser();
|
||||||
if (currentUser && currentUser.username === username) {
|
if (currentUser && currentUser.username === username) {
|
||||||
showToast('Impossible de supprimer son propre compte');
|
showToast('Impossible de supprimer son propre compte', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!confirm('Supprimer l\'utilisateur "' + username + '" ?')) return;
|
if (!confirm('Supprimer l\'utilisateur "' + username + '" ?')) return;
|
||||||
@ -1696,7 +1696,7 @@
|
|||||||
this._loadUsers();
|
this._loadUsers();
|
||||||
showToast('Utilisateur supprimé', 'success');
|
showToast('Utilisateur supprimé', 'success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showToast(err.message);
|
showToast(err.message, 'error');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -2575,7 +2575,7 @@
|
|||||||
setTimeout(() => (copyBtn.lastChild.textContent = "Copier"), 1500);
|
setTimeout(() => (copyBtn.lastChild.textContent = "Copier"), 1500);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Copy error:", 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),
|
search_timeout_ms: _getFieldNum("cfg-timeout", 30000),
|
||||||
};
|
};
|
||||||
localStorage.setItem(_FRONTEND_CONFIG_KEY, JSON.stringify(cfg));
|
localStorage.setItem(_FRONTEND_CONFIG_KEY, JSON.stringify(cfg));
|
||||||
showToast("Paramètres client sauvegardés");
|
showToast("Paramètres client sauvegardés", "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveBackendConfig() {
|
async function saveBackendConfig() {
|
||||||
@ -3141,12 +3141,12 @@
|
|||||||
if (btn) { btn.disabled = true; btn.textContent = "Réindexation..."; }
|
if (btn) { btn.disabled = true; btn.textContent = "Réindexation..."; }
|
||||||
try {
|
try {
|
||||||
await api("/api/index/reload");
|
await api("/api/index/reload");
|
||||||
showToast("Réindexation terminée");
|
showToast("Réindexation terminée", "success");
|
||||||
loadDiagnostics();
|
loadDiagnostics();
|
||||||
await Promise.all([loadVaults(), loadTags()]);
|
await Promise.all([loadVaults(), loadTags()]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Reindex error:", err);
|
console.error("Reindex error:", err);
|
||||||
showToast("Erreur de réindexation");
|
showToast("Erreur de réindexation", "error");
|
||||||
} finally {
|
} finally {
|
||||||
if (btn) { btn.disabled = false; btn.textContent = "Forcer réindexation"; }
|
if (btn) { btn.disabled = false; btn.textContent = "Forcer réindexation"; }
|
||||||
}
|
}
|
||||||
@ -3169,7 +3169,7 @@
|
|||||||
});
|
});
|
||||||
} catch (err) { console.error("Reset config error:", err); }
|
} catch (err) { console.error("Reset config error:", err); }
|
||||||
loadConfigFields();
|
loadConfigFields();
|
||||||
showToast("Configuration réinitialisée");
|
showToast("Configuration réinitialisée", "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDiagnostics() {
|
async function loadDiagnostics() {
|
||||||
@ -5270,7 +5270,7 @@
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to initialize ObsiGate:", 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
|
// Log when app is installed
|
||||||
window.addEventListener('appinstalled', () => {
|
window.addEventListener('appinstalled', () => {
|
||||||
console.log('[PWA] ObsiGate has been installed');
|
console.log('[PWA] ObsiGate has been installed');
|
||||||
showToast('ObsiGate installé avec succès !');
|
showToast('ObsiGate installé avec succès !', 'success');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user