mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-06-20 10:00:41 +00:00
feat: improve notification settings and interactive TG bot
This commit is contained in:
@@ -0,0 +1,227 @@
|
|||||||
|
import { updateServer } from "@/api/server"
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog"
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/components/ui/form"
|
||||||
|
import { Textarea } from "@/components/ui/textarea"
|
||||||
|
import { IconButton } from "@/components/xui/icon-button"
|
||||||
|
import { ModelServer as Server } from "@/types"
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
|
import { useEffect, useState } from "react"
|
||||||
|
import { useForm } from "react-hook-form"
|
||||||
|
import { useTranslation } from "react-i18next"
|
||||||
|
import { toast } from "sonner"
|
||||||
|
import { KeyedMutator } from "swr"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
interface BatchEditNoteIconProps {
|
||||||
|
servers: Server[]
|
||||||
|
selectedIds: number[]
|
||||||
|
mutate: KeyedMutator<Server[]>
|
||||||
|
}
|
||||||
|
|
||||||
|
const batchNoteFormSchema = z.object({
|
||||||
|
note: z.string().optional(),
|
||||||
|
public_note: z.string().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const BatchEditNoteIcon: React.FC<BatchEditNoteIconProps> = ({
|
||||||
|
servers,
|
||||||
|
selectedIds,
|
||||||
|
mutate,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
|
const form = useForm<z.infer<typeof batchNoteFormSchema>>({
|
||||||
|
resolver: zodResolver(batchNoteFormSchema),
|
||||||
|
defaultValues: {
|
||||||
|
note: "",
|
||||||
|
public_note: "",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleMessage = (e: MessageEvent) => {
|
||||||
|
if (e.data?.type === "NZCFG_JSON") {
|
||||||
|
const target = e.data.target === "traffic" ? "public_note" : e.data.target
|
||||||
|
if (target === "public_note" || target === "note") {
|
||||||
|
form.setValue(target, e.data.payload)
|
||||||
|
toast(t("Success"), {
|
||||||
|
description: `批量配置已自动填入${
|
||||||
|
target === "public_note" ? t("PublicNote.Label") : t("Private") + t("Note")
|
||||||
|
}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.addEventListener("message", handleMessage)
|
||||||
|
return () => window.removeEventListener("message", handleMessage)
|
||||||
|
}, [form, t])
|
||||||
|
|
||||||
|
const onSubmit = async (values: z.infer<typeof batchNoteFormSchema>) => {
|
||||||
|
if (selectedIds.length === 0) {
|
||||||
|
toast(t("Error"), { description: t("Results.SelectAtLeastOneServer") })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const promises = selectedIds.map((id) => {
|
||||||
|
const server = servers.find((s) => s.id === id)
|
||||||
|
if (!server) return Promise.resolve()
|
||||||
|
|
||||||
|
// Only update note/public_note if the batch form field is not empty!
|
||||||
|
// Wait, what if they WANT to clear the note?
|
||||||
|
// For batch, usually we only override if they typed something.
|
||||||
|
// We can provide a checkbox or just update if not empty.
|
||||||
|
// Let's just update if not empty for safety.
|
||||||
|
let updatePayload = { ...server }
|
||||||
|
if (values.note && values.note.trim() !== "") {
|
||||||
|
updatePayload.note = values.note
|
||||||
|
}
|
||||||
|
if (values.public_note && values.public_note.trim() !== "") {
|
||||||
|
updatePayload.public_note = values.public_note
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up non-API fields
|
||||||
|
return updateServer(id, {
|
||||||
|
name: updatePayload.name,
|
||||||
|
display_index: updatePayload.display_index,
|
||||||
|
note: updatePayload.note,
|
||||||
|
public_note: updatePayload.public_note,
|
||||||
|
hide_for_guest: updatePayload.hide_for_guest,
|
||||||
|
enable_ddns: updatePayload.enable_ddns,
|
||||||
|
ddns_profiles: updatePayload.ddns_profiles,
|
||||||
|
override_ddns_domains: updatePayload.override_ddns_domains,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
toast.promise(Promise.all(promises), {
|
||||||
|
loading: t("Saving..."),
|
||||||
|
success: () => {
|
||||||
|
setOpen(false)
|
||||||
|
mutate()
|
||||||
|
form.reset()
|
||||||
|
return t("Success")
|
||||||
|
},
|
||||||
|
error: t("Results.UnExpectedError"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<IconButton
|
||||||
|
icon="edit"
|
||||||
|
onClick={() => {
|
||||||
|
if (selectedIds.length === 0) {
|
||||||
|
toast(t("Error"), { description: t("Results.SelectAtLeastOneServer") })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setOpen(true)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
<DialogContent className="sm:max-w-xl">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>批量修改配置/备注 (已选 {selectedIds.length} 台)</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="note"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel className="flex justify-between items-center w-full">
|
||||||
|
<span>{t("Private") + t("Note")} (留空则不修改)</span>
|
||||||
|
<Button
|
||||||
|
variant="link"
|
||||||
|
type="button"
|
||||||
|
className="text-blue-500 hover:text-blue-700 text-xs flex items-center gap-1 h-auto p-0"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
window.open(
|
||||||
|
"/dashboard/nzcfg.html?target=note",
|
||||||
|
"nzcfg",
|
||||||
|
"width=1000,height=800",
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
可视化管理配置 <i className="fa-solid fa-up-right-from-square"></i>
|
||||||
|
</Button>
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Textarea
|
||||||
|
className="resize-none"
|
||||||
|
placeholder="在此粘贴或使用右上角可视化工具生成配置..."
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="public_note"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel className="flex justify-between items-center w-full">
|
||||||
|
<span>{t("Public") + t("Note")} (留空则不修改)</span>
|
||||||
|
<Button
|
||||||
|
variant="link"
|
||||||
|
type="button"
|
||||||
|
className="text-blue-500 hover:text-blue-700 text-xs flex items-center gap-1 h-auto p-0"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
window.open(
|
||||||
|
"/dashboard/nzcfg.html?target=public_note",
|
||||||
|
"nzcfg",
|
||||||
|
"width=1000,height=800",
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
可视化管理配置 <i className="fa-solid fa-up-right-from-square"></i>
|
||||||
|
</Button>
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Textarea
|
||||||
|
className="resize-y"
|
||||||
|
placeholder="在此粘贴或使用右上角可视化工具生成配置..."
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<DialogFooter>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="button" variant="secondary">
|
||||||
|
{t("Close")}
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
<Button type="submit">{t("Submit")}</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
+19
-52
@@ -49,9 +49,9 @@ interface NotifierCardProps {
|
|||||||
|
|
||||||
const notificationFormSchema = z.object({
|
const notificationFormSchema = z.object({
|
||||||
name: z.string().min(1),
|
name: z.string().min(1),
|
||||||
url: z.string().min(1),
|
url: z.string().default(""),
|
||||||
request_method: z.coerce.number().int().min(1).max(255),
|
request_method: z.coerce.number().int().default(1),
|
||||||
request_type: z.coerce.number().int().min(1).max(255),
|
request_type: z.coerce.number().int().default(1),
|
||||||
request_header: z.string(),
|
request_header: z.string(),
|
||||||
request_body: z.string(),
|
request_body: z.string(),
|
||||||
verify_tls: z.boolean().default(false),
|
verify_tls: z.boolean().default(false),
|
||||||
@@ -162,42 +162,33 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="1">Webhook</SelectItem>
|
<SelectItem value="1">Webhook</SelectItem>
|
||||||
<SelectItem value="2">SMTP (Email)</SelectItem>
|
<SelectItem value="2">Email (Global)</SelectItem>
|
||||||
<SelectItem value="3">Telegram</SelectItem>
|
<SelectItem value="3">Telegram (Global)</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{form.watch("type") == 1 && (
|
||||||
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="url"
|
name="url"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>URL</FormLabel>
|
||||||
{form.watch("type") == 2
|
|
||||||
? "SMTP Server (host:port)"
|
|
||||||
: form.watch("type") == 3
|
|
||||||
? "Bot Token"
|
|
||||||
: "URL"}
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
placeholder={
|
placeholder="https://..."
|
||||||
form.watch("type") == 3
|
|
||||||
? "123456:ABC-DEF"
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{form.watch("type") != 2 && form.watch("type") != 3 && (
|
|
||||||
<>
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="request_method"
|
name="request_method"
|
||||||
@@ -256,30 +247,16 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="request_header"
|
name="request_header"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t("RequestHeader")}</FormLabel>
|
||||||
{form.watch("type") == 2
|
|
||||||
? "SMTP User:Pass"
|
|
||||||
: form.watch("type") == 3
|
|
||||||
? "Chat ID"
|
|
||||||
: t("RequestHeader")}
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
className="resize-y"
|
className="resize-y"
|
||||||
placeholder={
|
placeholder={'{"User-Agent":"Nezha-Agent"}'}
|
||||||
form.watch("type") == 2
|
|
||||||
? "user:pass"
|
|
||||||
: form.watch("type") == 3
|
|
||||||
? "123456789"
|
|
||||||
: '{"User-Agent":"Nezha-Agent"}'
|
|
||||||
}
|
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@@ -287,29 +264,18 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{form.watch("type") != 3 && (
|
</>
|
||||||
|
)}
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="request_body"
|
name="request_body"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t("RequestBody")}</FormLabel>
|
||||||
{form.watch("type") == 2
|
|
||||||
? "Recipient Email"
|
|
||||||
: t("RequestBody")}
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
className={
|
className="resize-y h-[240px]"
|
||||||
form.watch("type") == 2
|
placeholder="..."
|
||||||
? "resize-y"
|
|
||||||
: "resize-y h-[240px]"
|
|
||||||
}
|
|
||||||
placeholder={
|
|
||||||
form.watch("type") == 2
|
|
||||||
? "target@example.com"
|
|
||||||
: "..."
|
|
||||||
}
|
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@@ -317,12 +283,12 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
<div className="pt-4 border-t space-y-3">
|
<div className="pt-4 border-t space-y-3">
|
||||||
<Label className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
|
<Label className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
|
||||||
{t("AdvancedSettings")}
|
{t("AdvancedSettings")}
|
||||||
</Label>
|
</Label>
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2">
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2">
|
||||||
|
{form.watch("type") == 1 && (
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="verify_tls"
|
name="verify_tls"
|
||||||
@@ -340,6 +306,7 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="skip_check"
|
name="skip_check"
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
|
||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
|
|||||||
@@ -153,6 +153,9 @@
|
|||||||
"IPChangeNotification": "IP Change Notification",
|
"IPChangeNotification": "IP Change Notification",
|
||||||
"IPChangeNotificationGroupID": "IP Change Notification Group ID",
|
"IPChangeNotificationGroupID": "IP Change Notification Group ID",
|
||||||
"ExpiryNotificationGroupID": "Expiry Notification Group ID",
|
"ExpiryNotificationGroupID": "Expiry Notification Group ID",
|
||||||
|
"ExpiryNotification": "Expiry Notification",
|
||||||
|
"DomainNotificationDays": "Domain Notification Days",
|
||||||
|
"ServerNotificationDays": "Server Notification Days",
|
||||||
"FullIPNotification": "Show Full IP Address in Notification Messages",
|
"FullIPNotification": "Show Full IP Address in Notification Messages",
|
||||||
"EditService": "Edit Service",
|
"EditService": "Edit Service",
|
||||||
"CreateService": "Create Service",
|
"CreateService": "Create Service",
|
||||||
|
|||||||
@@ -160,6 +160,9 @@
|
|||||||
"IPChangeNotification": "IP 变更通知",
|
"IPChangeNotification": "IP 变更通知",
|
||||||
"IPChangeNotificationGroupID": "IP 变更通知组 ID",
|
"IPChangeNotificationGroupID": "IP 变更通知组 ID",
|
||||||
"ExpiryNotificationGroupID": "到期通知组 ID",
|
"ExpiryNotificationGroupID": "到期通知组 ID",
|
||||||
|
"ExpiryNotification": "到期提醒设置",
|
||||||
|
"DomainNotificationDays": "域名到期提醒天数",
|
||||||
|
"ServerNotificationDays": "VPS到期提醒天数",
|
||||||
"FullIPNotification": "在通知消息中显示完整的 IP 地址",
|
"FullIPNotification": "在通知消息中显示完整的 IP 地址",
|
||||||
"LoginFailed": "登录失败",
|
"LoginFailed": "登录失败",
|
||||||
"BruteForceAttackingToken": "暴力攻击令牌",
|
"BruteForceAttackingToken": "暴力攻击令牌",
|
||||||
|
|||||||
+5
-1
@@ -121,7 +121,11 @@ const router = createBrowserRouter([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/dashboard/settings",
|
path: "/dashboard/settings",
|
||||||
element: <SettingsPage />,
|
element: (
|
||||||
|
<NotificationProvider withNotifierGroup>
|
||||||
|
<SettingsPage />
|
||||||
|
</NotificationProvider>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/dashboard/settings/user",
|
path: "/dashboard/settings/user",
|
||||||
|
|||||||
+126
-30
@@ -59,6 +59,13 @@ const settingFormSchema = z.object({
|
|||||||
background_image_night: asOptionalField(z.string()),
|
background_image_night: asOptionalField(z.string()),
|
||||||
telegram_bot_token: asOptionalField(z.string()),
|
telegram_bot_token: asOptionalField(z.string()),
|
||||||
telegram_admin_chat_id: asOptionalField(z.string()),
|
telegram_admin_chat_id: asOptionalField(z.string()),
|
||||||
|
smtp_server: asOptionalField(z.string()),
|
||||||
|
smtp_user: asOptionalField(z.string()),
|
||||||
|
smtp_password: asOptionalField(z.string()),
|
||||||
|
admin_email: asOptionalField(z.string()),
|
||||||
|
domain_expiry_notification_days: asOptionalField(z.string()),
|
||||||
|
server_expiry_notification_days: asOptionalField(z.string()),
|
||||||
|
expiry_notification_group_id: z.coerce.number().int().min(0),
|
||||||
})
|
})
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
@@ -95,6 +102,9 @@ export default function SettingsPage() {
|
|||||||
site_name: "",
|
site_name: "",
|
||||||
language: "",
|
language: "",
|
||||||
user_template: "user-dist",
|
user_template: "user-dist",
|
||||||
|
expiry_notification_group_id: 0,
|
||||||
|
domain_expiry_notification_days: "",
|
||||||
|
server_expiry_notification_days: "",
|
||||||
},
|
},
|
||||||
resetOptions: {
|
resetOptions: {
|
||||||
keepDefaultValues: false,
|
keepDefaultValues: false,
|
||||||
@@ -133,36 +143,6 @@ export default function SettingsPage() {
|
|||||||
<div>
|
<div>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-2 my-2">
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-2 my-2">
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="ip_change_notification_group_id"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>{t("IPChangeNotificationGroupID")}</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="number" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="expiry_notification_group_id"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Expiry Notification Group ID</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
type="number"
|
|
||||||
placeholder="Enter Group ID"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="site_name"
|
name="site_name"
|
||||||
@@ -279,6 +259,58 @@ export default function SettingsPage() {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="smtp_server"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>SMTP Server (host:port)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="smtp.example.com:465" {...field} value={field.value as string || ""} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="smtp_user"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>SMTP User</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="user@example.com" {...field} value={field.value as string || ""} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="smtp_password"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>SMTP Password</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input type="password" placeholder="••••••••" {...field} value={field.value as string || ""} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="admin_email"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Admin Email (Recipient)</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input type="email" placeholder="admin@example.com" {...field} value={field.value as string || ""} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="language"
|
name="language"
|
||||||
@@ -540,6 +572,70 @@ export default function SettingsPage() {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>{t("ExpiryNotification")}</FormLabel>
|
||||||
|
<Card className="w-full">
|
||||||
|
<CardContent>
|
||||||
|
<div className="flex flex-col space-y-4 mt-4">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="expiry_notification_group_id"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>{t("NotificationGroup")}</FormLabel>
|
||||||
|
<Combobox
|
||||||
|
options={ngroupList}
|
||||||
|
defaultValue={`${field.value}`}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
/>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="domain_expiry_notification_days"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>
|
||||||
|
{t("DomainNotificationDays") +
|
||||||
|
" " +
|
||||||
|
t("SeparateWithComma")}
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="60,30,15,7,3,1,0"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="server_expiry_notification_days"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>
|
||||||
|
{t("ServerNotificationDays") +
|
||||||
|
" " +
|
||||||
|
t("SeparateWithComma")}
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="30,15,7,3,1,0"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</FormItem>
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>{t("IPChangeNotification")}</FormLabel>
|
<FormLabel>{t("IPChangeNotification")}</FormLabel>
|
||||||
<Card className="w-full">
|
<Card className="w-full">
|
||||||
|
|||||||
@@ -696,6 +696,10 @@ export interface ModelSetting {
|
|||||||
background_image_night?: string
|
background_image_night?: string
|
||||||
telegram_bot_token?: string
|
telegram_bot_token?: string
|
||||||
telegram_admin_chat_id?: string
|
telegram_admin_chat_id?: string
|
||||||
|
smtp_server?: string
|
||||||
|
smtp_user?: string
|
||||||
|
smtp_password?: string
|
||||||
|
admin_email?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelSettingForm {
|
export interface ModelSettingForm {
|
||||||
@@ -731,6 +735,10 @@ export interface ModelSettingForm {
|
|||||||
background_image_night?: string
|
background_image_night?: string
|
||||||
telegram_bot_token?: string
|
telegram_bot_token?: string
|
||||||
telegram_admin_chat_id?: string
|
telegram_admin_chat_id?: string
|
||||||
|
smtp_server?: string
|
||||||
|
smtp_user?: string
|
||||||
|
smtp_password?: string
|
||||||
|
admin_email?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelSettingResponse {
|
export interface ModelSettingResponse {
|
||||||
|
|||||||
Reference in New Issue
Block a user