fix user permissions + improve notification system

This commit is contained in:
KingKDot
2026-04-13 14:11:49 -05:00
parent c56a9f16f4
commit f28c0d33a9
12 changed files with 257 additions and 24 deletions
@@ -52,6 +52,11 @@ const eventNotifOfflineInput = document.getElementById("event-notif-offline");
const eventNotifPurgatoryInput = document.getElementById("event-notif-purgatory");
const saveEventNotifsBtn = document.getElementById("save-event-notifs");
const clientEventWebhookInput = document.getElementById("client-event-webhook");
const clientEventTelegramInput = document.getElementById("client-event-telegram");
const clientEventPushInput = document.getElementById("client-event-push");
const saveEventChannelsBtn = document.getElementById("save-event-channels");
// Browser permission status bar
const desktopNotifStatusBar = document.getElementById("desktop-notif-status-bar");
const desktopNotifStatusIcon = document.getElementById("desktop-notif-status-icon");
@@ -354,6 +359,9 @@ function applyMySettings(settings) {
if (telegramBotTokenInput) telegramBotTokenInput.value = settings.telegram_bot_token || "";
if (telegramChatIdInput) telegramChatIdInput.value = settings.telegram_chat_id || "";
if (telegramTemplateInput) telegramTemplateInput.value = settings.telegram_template || "";
if (clientEventWebhookInput) clientEventWebhookInput.checked = settings.client_event_webhook !== 0;
if (clientEventTelegramInput) clientEventTelegramInput.checked = settings.client_event_telegram !== 0;
if (clientEventPushInput) clientEventPushInput.checked = settings.client_event_push !== 0;
}
async function loadMySettings() {
@@ -676,6 +684,22 @@ function wireEventNotifSave() {
});
}
function wireEventChannelsSave() {
if (!saveEventChannelsBtn) return;
saveEventChannelsBtn.addEventListener("click", async () => {
try {
await saveMySettings({
client_event_webhook: clientEventWebhookInput?.checked ?? true,
client_event_telegram: clientEventTelegramInput?.checked ?? true,
client_event_push: clientEventPushInput?.checked ?? true,
});
window.showToast?.("Event delivery channel settings saved", "success", 3000);
} catch (err) {
window.showToast?.(err?.message || "Failed to save event channel settings", "error", 4000);
}
});
}
// ── Bootstrap ─────────────────────────────────────────────────────────────────
initWebhookTemplateEditor();
wireKeywordSave();
@@ -684,6 +708,7 @@ wireTelegramSave();
loadMySettings();
loadEventNotifPrefs();
wireEventNotifSave();
wireEventChannelsSave();
updateDesktopPermissionUi();
wireDesktopPermissionBtn();
initRoleUi();
+43
View File
@@ -313,6 +313,49 @@
</div>
</div>
<!-- Client Event Delivery Channels -->
<div class="bg-slate-900/60 border border-slate-800 rounded-xl p-4">
<div class="flex items-center justify-between flex-wrap gap-3 mb-4">
<div>
<h2 class="text-lg font-semibold">Client Event Delivery Channels</h2>
<p class="text-sm text-slate-400">
Choose which channels receive client lifecycle events (online, offline, purgatory).
</p>
</div>
<button
id="save-event-channels"
class="inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white"
>
<i class="fa-solid fa-save"></i>
<span>Save</span>
</button>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3 text-sm">
<label class="flex items-center gap-3 rounded-lg bg-slate-950 border border-slate-800 px-4 py-3 cursor-pointer hover:border-slate-600 transition-colors">
<input id="client-event-webhook" type="checkbox" class="h-4 w-4 accent-indigo-500 shrink-0" />
<span class="flex flex-col gap-0.5">
<span class="text-slate-200 font-medium"><i class="fa-brands fa-discord mr-1"></i> Discord Webhook</span>
<span class="text-slate-500 text-xs">Send client events to your webhook</span>
</span>
</label>
<label class="flex items-center gap-3 rounded-lg bg-slate-950 border border-slate-800 px-4 py-3 cursor-pointer hover:border-slate-600 transition-colors">
<input id="client-event-telegram" type="checkbox" class="h-4 w-4 accent-sky-500 shrink-0" />
<span class="flex flex-col gap-0.5">
<span class="text-slate-200 font-medium"><i class="fa-brands fa-telegram mr-1"></i> Telegram Bot</span>
<span class="text-slate-500 text-xs">Send client events to your Telegram</span>
</span>
</label>
<label class="flex items-center gap-3 rounded-lg bg-slate-950 border border-slate-800 px-4 py-3 cursor-pointer hover:border-slate-600 transition-colors">
<input id="client-event-push" type="checkbox" class="h-4 w-4 accent-emerald-500 shrink-0" />
<span class="flex flex-col gap-0.5">
<span class="text-slate-200 font-medium"><i class="fa-solid fa-bell mr-1"></i> Push Notifications</span>
<span class="text-slate-500 text-xs">Send client events via browser push</span>
</span>
</label>
</div>
</div>
<!-- Notification feed -->
<div
id="notification-panel"