better toast success notifications

This commit is contained in:
KingKDot
2026-07-11 19:35:56 -05:00
parent fb6c856ad1
commit 9ea63fa6bc
2 changed files with 20 additions and 14 deletions
+19 -14
View File
@@ -165,6 +165,11 @@ function formatDate(timestamp) {
return formatSharedDate(timestamp, "-"); return formatSharedDate(timestamp, "-");
} }
function showSettingsSuccess(text, showInline = showMessage) {
showInline(text);
window.showToast?.(text, "success");
}
function canManageClientBans(role) { function canManageClientBans(role) {
return userHas("network:manage-bans"); return userHas("network:manage-bans");
} }
@@ -634,7 +639,7 @@ async function updatePassword(event) {
} }
passwordForm.reset(); passwordForm.reset();
showMessage("Password updated successfully."); showSettingsSuccess("Password updated successfully.");
} }
function showMfaMessage(text, type = "ok") { function showMfaMessage(text, type = "ok") {
@@ -759,7 +764,7 @@ function savePrefs(event) {
if (perm === "granted") { if (perm === "granted") {
setDesktopNotificationsEnabled(true); setDesktopNotificationsEnabled(true);
if (prefDesktopNotificationsHint) prefDesktopNotificationsHint.classList.add("hidden"); if (prefDesktopNotificationsHint) prefDesktopNotificationsHint.classList.add("hidden");
showMessage("Preferences saved. Desktop notifications enabled."); showSettingsSuccess("Preferences saved. Desktop notifications enabled.");
} else { } else {
setDesktopNotificationsEnabled(false); setDesktopNotificationsEnabled(false);
if (prefDesktopNotificationsInput) prefDesktopNotificationsInput.checked = false; if (prefDesktopNotificationsInput) prefDesktopNotificationsInput.checked = false;
@@ -770,7 +775,7 @@ function savePrefs(event) {
} else { } else {
setDesktopNotificationsEnabled(false); setDesktopNotificationsEnabled(false);
if (prefDesktopNotificationsHint) prefDesktopNotificationsHint.classList.add("hidden"); if (prefDesktopNotificationsHint) prefDesktopNotificationsHint.classList.add("hidden");
showMessage("Preferences saved."); showSettingsSuccess("Preferences saved.");
} }
const navHiddenInput = document.getElementById("pref-nav-hidden"); const navHiddenInput = document.getElementById("pref-nav-hidden");
@@ -815,7 +820,7 @@ async function saveSecurityPolicy(event) {
securityConfig = data.security || payload; securityConfig = data.security || payload;
applySecurityForm(); applySecurityForm();
showMessage("Security policy updated."); showSettingsSuccess("Security policy updated.");
} }
async function saveTlsSettings(event) { async function saveTlsSettings(event) {
@@ -850,7 +855,7 @@ async function saveTlsSettings(event) {
tlsConfig = data.tls || payload; tlsConfig = data.tls || payload;
applyTlsForm(); applyTlsForm();
showMessage("TLS settings updated. Restart server to apply."); showSettingsSuccess("TLS settings updated. Restart server to apply.");
} }
async function saveOidcSettings(event) { async function saveOidcSettings(event) {
@@ -926,7 +931,7 @@ async function saveOidcSettings(event) {
oidcConfig = data.oidc || payload; oidcConfig = data.oidc || payload;
applyOidcForm(); applyOidcForm();
showMessage("OIDC settings saved. Environment variables still take priority after restart."); showSettingsSuccess("OIDC settings saved. Environment variables still take priority after restart.");
} }
async function runCertbotAutoSetup() { async function runCertbotAutoSetup() {
@@ -1011,7 +1016,7 @@ async function saveMyTelegram() {
} }
myTelegramChatIdInput.value = data.telegramChatId || ""; myTelegramChatIdInput.value = data.telegramChatId || "";
showMessage(chatId ? "Telegram chat ID saved." : "Telegram notifications disabled."); showSettingsSuccess(chatId ? "Telegram chat ID saved." : "Telegram notifications disabled.");
} catch { } catch {
showMessage("Failed to save Telegram settings.", "error"); showMessage("Failed to save Telegram settings.", "error");
} }
@@ -1558,7 +1563,7 @@ async function saveAppearanceSettings(event) {
} }
applyBrandingForm(data.loginBranding || collectBrandingForm()); applyBrandingForm(data.loginBranding || collectBrandingForm());
showMessage("Branding saved. Reload any open page to apply it everywhere."); showSettingsSuccess("Branding saved. Reload any open page to apply it everywhere.");
} }
const chatSettingsSection = document.getElementById("chat-settings-section"); const chatSettingsSection = document.getElementById("chat-settings-section");
@@ -1608,7 +1613,7 @@ async function saveInputArchivePreference(event) {
showMessage(data.error || "Failed to save input archive preference.", "error"); showMessage(data.error || "Failed to save input archive preference.", "error");
return; return;
} }
showMessage("Input archive preference saved."); showSettingsSuccess("Input archive preference saved.");
} }
async function saveInputArchiveAdminSettings(event) { async function saveInputArchiveAdminSettings(event) {
@@ -1651,7 +1656,7 @@ async function saveInputArchiveAdminSettings(event) {
showMessage(data.error || "Failed to save input archive settings.", "error"); showMessage(data.error || "Failed to save input archive settings.", "error");
return; return;
} }
showMessage("Input archive settings saved."); showSettingsSuccess("Input archive settings saved.");
} }
async function saveChatSettings(event) { async function saveChatSettings(event) {
@@ -1679,7 +1684,7 @@ async function saveChatSettings(event) {
return; return;
} }
showMessage("Chat settings saved."); showSettingsSuccess("Chat settings saved.");
} }
function showExportImportMessage(text, type = "ok") { function showExportImportMessage(text, type = "ok") {
@@ -2086,7 +2091,7 @@ async function saveRegistrationSettings(e) {
showRegMsg(data.error || "Failed to save", "error"); showRegMsg(data.error || "Failed to save", "error");
return; return;
} }
showRegMsg("Registration settings saved.", "success"); showSettingsSuccess("Registration settings saved.", (text) => showRegMsg(text, "success"));
updateRegSubsections(mode); updateRegSubsections(mode);
if (mode === "key" && userHas("users:manage")) loadRegistrationKeys(); if (mode === "key" && userHas("users:manage")) loadRegistrationKeys();
if (mode === "approval" && userHas("users:manage")) loadPendingRegistrations(); if (mode === "approval" && userHas("users:manage")) loadPendingRegistrations();
@@ -2309,7 +2314,7 @@ async function saveBuildRateLimitSettings(e) {
showBrlMsg(data.error || "Failed to save", "error"); showBrlMsg(data.error || "Failed to save", "error");
return; return;
} }
showBrlMsg("Build rate limit settings saved.", "success"); showSettingsSuccess("Build rate limit settings saved.", (text) => showBrlMsg(text, "success"));
} catch { } catch {
showBrlMsg("Network error.", "error"); showBrlMsg("Network error.", "error");
} }
@@ -2368,7 +2373,7 @@ async function saveThumbnailSettings(e) {
showThumbnailsMsg(data.error || "Failed to save", "error"); showThumbnailsMsg(data.error || "Failed to save", "error");
return; return;
} }
showThumbnailsMsg("Thumbnail settings saved.", "success"); showSettingsSuccess("Thumbnail settings saved.", (text) => showThumbnailsMsg(text, "success"));
} catch { } catch {
showThumbnailsMsg("Network error.", "error"); showThumbnailsMsg("Network error.", "error");
} }
+1
View File
@@ -13,6 +13,7 @@
<link rel="stylesheet" href="/assets/tailwind.css" /> <link rel="stylesheet" href="/assets/tailwind.css" />
<link rel="stylesheet" href="/vendor/fontawesome/css/all.min.css" /> <link rel="stylesheet" href="/vendor/fontawesome/css/all.min.css" />
<link rel="stylesheet" href="/assets/main.css" /> <link rel="stylesheet" href="/assets/main.css" />
<script defer src="/assets/toast.js"></script>
<link rel="stylesheet" href="/assets/custom.css" /> <link rel="stylesheet" href="/assets/custom.css" />
<style> <style>
.settings-nav-link { .settings-nav-link {