From 18c645583753b3436728fe95fd18804409d6c1fe Mon Sep 17 00:00:00 2001 From: MacRimi Date: Mon, 2 Mar 2026 18:55:02 +0100 Subject: [PATCH] Update notification service --- AppImage/components/channel-grid.tsx | 103 +++++++++++++++ AppImage/components/notification-settings.tsx | 117 +++--------------- AppImage/public/icons/discord.svg | 2 + AppImage/public/icons/gotify.svg | 2 + AppImage/public/icons/mail.svg | 2 + AppImage/public/icons/telegram.svg | 2 + 6 files changed, 131 insertions(+), 97 deletions(-) create mode 100644 AppImage/components/channel-grid.tsx create mode 100644 AppImage/public/icons/discord.svg create mode 100644 AppImage/public/icons/gotify.svg create mode 100644 AppImage/public/icons/mail.svg create mode 100644 AppImage/public/icons/telegram.svg diff --git a/AppImage/components/channel-grid.tsx b/AppImage/components/channel-grid.tsx new file mode 100644 index 00000000..59e35eef --- /dev/null +++ b/AppImage/components/channel-grid.tsx @@ -0,0 +1,103 @@ +"use client" + +import { useState } from "react" + +const CHANNELS = [ + { key: "telegram", label: "Telegram", icon: "/icons/telegram.svg", color: "blue", switchOn: "bg-blue-600" }, + { key: "gotify", label: "Gotify", icon: "/icons/gotify.svg", color: "green", switchOn: "bg-green-600" }, + { key: "discord", label: "Discord", icon: "/icons/discord.svg", color: "indigo", switchOn: "bg-indigo-600" }, + { key: "email", label: "Email", icon: "/icons/mail.svg", color: "amber", switchOn: "bg-amber-600" }, +] + +const SELECTED_BORDER = { + blue: "border-blue-500/60 bg-blue-500/10", + green: "border-green-500/60 bg-green-500/10", + indigo: "border-indigo-500/60 bg-indigo-500/10", + amber: "border-amber-500/60 bg-amber-500/10", +} + +interface ChannelGridProps { + enabledChannels: { telegram: boolean; gotify: boolean; discord: boolean; email: boolean } + onToggle: (channel: string, enabled: boolean) => void + selectedChannel: string | null + onSelect: (channel: string | null) => void +} + +export function ChannelGrid({ enabledChannels, onToggle, selectedChannel, onSelect }: ChannelGridProps) { + return ( +
+ {CHANNELS.map(ch => { + const isEnabled = enabledChannels[ch.key as keyof typeof enabledChannels] || false + const isSelected = selectedChannel === ch.key + const selStyle = SELECTED_BORDER[ch.color as keyof typeof SELECTED_BORDER] + + return ( + + ) + })} +
+ ) +} diff --git a/AppImage/components/notification-settings.tsx b/AppImage/components/notification-settings.tsx index d8c66c8f..dd60d7b9 100644 --- a/AppImage/components/notification-settings.tsx +++ b/AppImage/components/notification-settings.tsx @@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./ui/card" - +import { ChannelGrid } from "./channel-grid" import { Input } from "./ui/input" import { Label } from "./ui/label" import { Badge } from "./ui/badge" @@ -101,42 +101,6 @@ const AI_PROVIDERS = [ { value: "groq", label: "Groq" }, ] -// ── Channel visual definitions ── -const CHANNEL_COLOR_MAP: Record = { - blue: "border-blue-500/60 bg-blue-500/10", - green: "border-green-500/60 bg-green-500/10", - indigo: "border-indigo-500/60 bg-indigo-500/10", - amber: "border-amber-500/60 bg-amber-500/10", -} - -const CHANNEL_SWITCH_COLOR: Record = { - blue: "bg-blue-600", - green: "bg-green-600", - indigo: "bg-indigo-600", - amber: "bg-amber-600", -} - -const CHANNEL_DEFS: ChannelDef[] = [ - { key: "telegram", label: "Telegram", color: "blue", activeColor: "bg-blue-600 hover:bg-blue-700" }, - { key: "gotify", label: "Gotify", color: "green", activeColor: "bg-green-600 hover:bg-green-700" }, - { key: "discord", label: "Discord", color: "indigo", activeColor: "bg-indigo-600 hover:bg-indigo-700" }, - { key: "email", label: "Email", color: "amber", activeColor: "bg-amber-600 hover:bg-amber-700" }, -] - -interface ChannelDef { - key: string - label: string - color: string - activeColor: string -} - -const CHANNEL_ICONS: Record = { - telegram: "/icons/telegram.svg", - gotify: "/icons/gotify.svg", - discord: "/icons/discord.svg", - email: "/icons/mail.svg", -} - const DEFAULT_CONFIG: NotificationConfig = { enabled: false, channels: { @@ -707,64 +671,21 @@ matcher: proxmenux-pbs Channels - {/* ── Channel Cards Grid ── */} -
- {CHANNEL_DEFS.map(ch => { - /* eslint-disable @typescript-eslint/no-explicit-any */ - const chConf = (config.channels || {})[ch.key] - const isEnabled = !!(chConf && chConf.enabled) - const isSelected = selectedChannel === ch.key + updateChannel(ch, "enabled", val)} + selectedChannel={selectedChannel} + onSelect={setSelectedChannel} + /> - return ( - - ) - })} -
- - {/* ── Selected Channel Configuration Panel ── */} + {/* ── Telegram Config ── */} {selectedChannel === "telegram" && ( -
+
{config.channels.telegram?.enabled ? ( <>
@@ -819,8 +740,9 @@ matcher: proxmenux-pbs
)} + {/* ── Gotify Config ── */} {selectedChannel === "gotify" && ( -
+
{config.channels.gotify?.enabled ? ( <>
@@ -875,8 +797,9 @@ matcher: proxmenux-pbs
)} + {/* ── Discord Config ── */} {selectedChannel === "discord" && ( -
+
{config.channels.discord?.enabled ? ( <>
@@ -922,8 +845,9 @@ matcher: proxmenux-pbs
)} + {/* ── Email Config ── */} {selectedChannel === "email" && ( -
+
{config.channels.email?.enabled ? ( <>
@@ -1065,7 +989,6 @@ matcher: proxmenux-pbs {testResult.message}
)} -
{/* close bordered channel container */}
{/* ── Filters ── */} diff --git a/AppImage/public/icons/discord.svg b/AppImage/public/icons/discord.svg new file mode 100644 index 00000000..a18ffdca --- /dev/null +++ b/AppImage/public/icons/discord.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/AppImage/public/icons/gotify.svg b/AppImage/public/icons/gotify.svg new file mode 100644 index 00000000..26622e75 --- /dev/null +++ b/AppImage/public/icons/gotify.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/AppImage/public/icons/mail.svg b/AppImage/public/icons/mail.svg new file mode 100644 index 00000000..69296ebd --- /dev/null +++ b/AppImage/public/icons/mail.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/AppImage/public/icons/telegram.svg b/AppImage/public/icons/telegram.svg new file mode 100644 index 00000000..e1147398 --- /dev/null +++ b/AppImage/public/icons/telegram.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file