Add Echobell notification fields and i18n support in settings

This commit is contained in:
headlessdev 2025-04-29 22:40:07 +02:00
parent 0f2afb4157
commit 1a395783b0
3 changed files with 41 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { AlertCircle, Check, Palette, User, Bell, AtSign, Send, MessageSquare, Trash2, Play, Languages } from "lucide-react" import { AlertCircle, Check, Palette, User, Bell, AtSign, Send, MessageSquare, Trash2, Play, Languages } from "lucide-react"
import { Toaster } from "@/components/ui/sonner" import { Toaster } from "@/components/ui/sonner"
import { toast } from "sonner" import { toast } from "sonner"
import { Textarea } from "@/components/ui/textarea"
import { import {
AlertDialog, AlertDialog,
@ -35,7 +36,6 @@ import {
} from "@/components/ui/alert-dialog" } from "@/components/ui/alert-dialog"
import { Label } from "@/components/ui/label" import { Label } from "@/components/ui/label"
import { Checkbox } from "@/components/ui/checkbox" import { Checkbox } from "@/components/ui/checkbox"
import { Textarea } from "@/components/ui/textarea"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"
interface NotificationsResponse { interface NotificationsResponse {
@ -82,6 +82,8 @@ export default function Settings() {
const [pushoverUrl, setPushoverUrl] = useState<string>("") const [pushoverUrl, setPushoverUrl] = useState<string>("")
const [pushoverToken, setPushoverToken] = useState<string>("") const [pushoverToken, setPushoverToken] = useState<string>("")
const [pushoverUser, setPushoverUser] = useState<string>("") const [pushoverUser, setPushoverUser] = useState<string>("")
const [echobellURL, setEchobellURL] = useState<string>("")
const [echobellData, setEchobellData] = useState<string>("")
const [language, setLanguage] = useState<string>("english") const [language, setLanguage] = useState<string>("english")
const [notifications, setNotifications] = useState<any[]>([]) const [notifications, setNotifications] = useState<any[]>([])
@ -190,6 +192,8 @@ export default function Settings() {
pushoverUrl: pushoverUrl, pushoverUrl: pushoverUrl,
pushoverToken: pushoverToken, pushoverToken: pushoverToken,
pushoverUser: pushoverUser, pushoverUser: pushoverUser,
echobellURL: echobellURL,
echobellData: echobellData,
}) })
getNotifications() getNotifications()
} catch (error: any) { } catch (error: any) {
@ -514,6 +518,7 @@ export default function Settings() {
<SelectItem value="gotify">{t('Settings.Notifications.AddNotification.Gotify.Title')}</SelectItem> <SelectItem value="gotify">{t('Settings.Notifications.AddNotification.Gotify.Title')}</SelectItem>
<SelectItem value="ntfy">{t('Settings.Notifications.AddNotification.Ntfy.Title')}</SelectItem> <SelectItem value="ntfy">{t('Settings.Notifications.AddNotification.Ntfy.Title')}</SelectItem>
<SelectItem value="pushover">{t('Settings.Notifications.AddNotification.Pushover.Title')}</SelectItem> <SelectItem value="pushover">{t('Settings.Notifications.AddNotification.Pushover.Title')}</SelectItem>
<SelectItem value="echobell">{t('Settings.Notifications.AddNotification.Echobell.Title')}</SelectItem>
</SelectContent> </SelectContent>
{notificationType === "smtp" && ( {notificationType === "smtp" && (
@ -685,6 +690,31 @@ export default function Settings() {
</div> </div>
</div> </div>
)} )}
{notificationType === "echobell" && (
<div className="mt-4 flex flex-col gap-2">
<div className="grid w-full items-center gap-1.5">
<Label>{t('Settings.Notifications.AddNotification.Echobell.Url')}</Label>
<Input
type="text"
placeholder="e.g. https://hook.echobell.one/t/xxx"
onChange={(e) => setEchobellURL(e.target.value)}
/>
</div>
<div className="grid w-full items-center gap-1.5">
<Label>{t('Settings.Notifications.AddNotification.Echobell.Data')}</Label>
<Textarea
placeholder={`e.g.:
"title": "Server Status",
"message": "Server is online"
`}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => setEchobellData(e.target.value)}
rows={4}
/>
</div>
</div>
)}
</Select> </Select>
</div> </div>
</AlertDialogDescription> </AlertDialogDescription>

View File

@ -381,6 +381,11 @@
"Url": "Pushover-URL", "Url": "Pushover-URL",
"Token": "Pushover-Token", "Token": "Pushover-Token",
"User": "Pushover-Benutzer" "User": "Pushover-Benutzer"
},
"Echobell": {
"Title": "Echobell",
"Url": "Echobell-URL",
"Data": "Echobell-Data"
} }
}, },
"CustomizeText": { "CustomizeText": {

View File

@ -381,6 +381,11 @@
"Url": "Pushover URL", "Url": "Pushover URL",
"Token": "Pushover Token", "Token": "Pushover Token",
"User": "Pushover User" "User": "Pushover User"
},
"Echobell": {
"Title": "Echobell",
"Url": "Echobell URL",
"Data": "Echobell Data"
} }
}, },
"CustomizeText": { "CustomizeText": {