mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 20:50:07 +00:00
implement notification page (#8)
This commit is contained in:
281
src/components/alert-rule.tsx
Normal file
281
src/components/alert-rule.tsx
Normal file
@@ -0,0 +1,281 @@
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form"
|
||||
import { ScrollArea } from "@/components/ui/scroll-area"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { z } from "zod"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { ModelAlertRule } from "@/types"
|
||||
import { createAlertRule, updateAlertRule } from "@/api/alert-rule"
|
||||
import { Checkbox } from "@/components/ui/checkbox"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { conv } from "@/lib/utils"
|
||||
import { useState } from "react"
|
||||
import { KeyedMutator } from "swr"
|
||||
import { asOptionalField } from "@/lib/utils"
|
||||
import { IconButton } from "@/components/xui/icon-button"
|
||||
import { triggerModes } from "@/types"
|
||||
import { Textarea } from "./ui/textarea"
|
||||
|
||||
interface AlertRuleCardProps {
|
||||
data?: ModelAlertRule;
|
||||
mutate: KeyedMutator<ModelAlertRule[]>;
|
||||
}
|
||||
|
||||
const ruleSchema = z.object({
|
||||
type: z.string(),
|
||||
min: asOptionalField(z.number()),
|
||||
max: asOptionalField(z.number()),
|
||||
cycle_start: asOptionalField(z.string()),
|
||||
cycle_interval: asOptionalField(z.number()),
|
||||
cycle_unit: asOptionalField(z.enum(['hour', 'day', 'week', 'month', 'year'])),
|
||||
duration: asOptionalField(z.number()),
|
||||
cover: z.number().int().min(0),
|
||||
ignore: asOptionalField(z.record(z.boolean())),
|
||||
next_transfer_at: asOptionalField(z.record(z.string())),
|
||||
last_cycle_status: asOptionalField((z.boolean())),
|
||||
});
|
||||
|
||||
const alertRuleFormSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
rules_raw: z.string().refine((val) => {
|
||||
try {
|
||||
JSON.parse(val);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
message: 'Invalid JSON string',
|
||||
}),
|
||||
rules: z.array(ruleSchema),
|
||||
fail_trigger_tasks: z.array(z.string()).transform((v => {
|
||||
return v.filter(Boolean).map(Number);
|
||||
})),
|
||||
recover_trigger_tasks: z.array(z.string()).transform((v => {
|
||||
return v.filter(Boolean).map(Number);
|
||||
})),
|
||||
notification_group_id: z.coerce.number().int(),
|
||||
trigger_mode: z.coerce.number().int().min(0),
|
||||
enable: asOptionalField(z.boolean()),
|
||||
});
|
||||
|
||||
export const AlertRuleCard: React.FC<AlertRuleCardProps> = ({ data, mutate }) => {
|
||||
const form = useForm<z.infer<typeof alertRuleFormSchema>>({
|
||||
resolver: zodResolver(alertRuleFormSchema),
|
||||
defaultValues: data ? {
|
||||
...data,
|
||||
rules_raw: JSON.stringify(data.rules),
|
||||
} : {
|
||||
name: "",
|
||||
rules_raw: "",
|
||||
rules: [],
|
||||
fail_trigger_tasks: [],
|
||||
recover_trigger_tasks: [],
|
||||
notification_group_id: 0,
|
||||
trigger_mode: 0,
|
||||
},
|
||||
resetOptions: {
|
||||
keepDefaultValues: false,
|
||||
}
|
||||
})
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const onSubmit = async (values: z.infer<typeof alertRuleFormSchema>) => {
|
||||
values.rules = JSON.parse(values.rules_raw);
|
||||
data?.id ? await updateAlertRule(data.id, values) : await createAlertRule(values);
|
||||
setOpen(false);
|
||||
await mutate();
|
||||
form.reset();
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
{data
|
||||
?
|
||||
<IconButton variant="outline" icon="edit" />
|
||||
:
|
||||
<IconButton icon="plus" />
|
||||
}
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-xl">
|
||||
<ScrollArea className="max-h-[calc(100dvh-5rem)] p-3">
|
||||
<div className="items-center mx-1">
|
||||
<DialogHeader>
|
||||
<DialogTitle>New Alert Rule</DialogTitle>
|
||||
<DialogDescription />
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-2 my-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Name</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="rules_raw"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Rules</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
className="resize-y"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="notification_group_id"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Notifier Group ID</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="0"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="trigger_mode"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Trigger Mode</FormLabel>
|
||||
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{Object.entries(triggerModes).map(([k, v]) => (
|
||||
<SelectItem key={k} value={k}>{v}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="fail_trigger_tasks"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Tasks to trigger on an alarm (Separate with comma)</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="1,2,3"
|
||||
{...field}
|
||||
value={conv.arrToStr(field.value ?? [])}
|
||||
onChange={e => {
|
||||
const arr = conv.strToArr(e.target.value);
|
||||
field.onChange(arr);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="recover_trigger_tasks"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Tasks to trigger after recovery (Separate with comma)</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="1,2,3"
|
||||
{...field}
|
||||
value={conv.arrToStr(field.value ?? [])}
|
||||
onChange={e => {
|
||||
const arr = conv.strToArr(e.target.value);
|
||||
field.onChange(arr);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="enable"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center space-x-2">
|
||||
<FormControl>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
<Label className="text-sm">Enable</Label>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<DialogFooter className="justify-end">
|
||||
<DialogClose asChild>
|
||||
<Button type="button" className="my-2" variant="secondary">
|
||||
Close
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="my-2">Submit</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ const ddnsFormSchema = z.object({
|
||||
access_secret: asOptionalField(z.string()),
|
||||
webhook_url: asOptionalField(z.string().url()),
|
||||
webhook_method: asOptionalField(z.coerce.number().int().min(1).max(255)),
|
||||
webhook_request_type: asOptionalField(z.coerce.number().int().min(1).max(255).default(1)),
|
||||
webhook_request_type: asOptionalField(z.coerce.number().int().min(1).max(255)),
|
||||
webhook_request_body: asOptionalField(z.string()),
|
||||
webhook_headers: asOptionalField(z.string()),
|
||||
});
|
||||
|
||||
@@ -5,11 +5,11 @@ import {
|
||||
} from "@/components/ui/tabs"
|
||||
import { Link, useLocation } from "react-router-dom"
|
||||
|
||||
export const GroupTab = () => {
|
||||
export const GroupTab = ({ className }: { className?: string }) => {
|
||||
const location = useLocation();
|
||||
|
||||
return (
|
||||
<Tabs defaultValue={location.pathname}>
|
||||
<Tabs defaultValue={location.pathname} className={className}>
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="/dashboard/server-group" asChild>
|
||||
<Link to="/dashboard/server-group">Server</Link>
|
||||
|
||||
@@ -47,6 +47,11 @@ export default function Header() {
|
||||
<Link to="/dashboard/cron">Task</Link>
|
||||
</NzNavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NzNavigationMenuLink asChild active={location.pathname === "/dashboard/notification" || location.pathname === "/dashboard/alert-rule"} className={navigationMenuTriggerStyle()}>
|
||||
<Link to="/dashboard/notification">Notification</Link>
|
||||
</NzNavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NzNavigationMenuLink asChild active={location.pathname === "/dashboard/ddns"} className={navigationMenuTriggerStyle()}>
|
||||
<Link to="/dashboard/ddns">Dynamic DNS</Link>
|
||||
|
||||
@@ -27,7 +27,8 @@ import { useState } from "react"
|
||||
import { KeyedMutator } from "swr"
|
||||
import { IconButton } from "@/components/xui/icon-button"
|
||||
import { createNotificationGroup, updateNotificationGroup } from "@/api/notification-group"
|
||||
import { conv } from "@/lib/utils"
|
||||
import { MultiSelect } from "@/components/xui/multi-select"
|
||||
import { useNotification } from "@/hooks/useNotfication"
|
||||
|
||||
interface NotificationGroupCardProps {
|
||||
data?: ModelNotificationGroupResponseItem;
|
||||
@@ -44,7 +45,10 @@ const notificationGroupFormSchema = z.object({
|
||||
export const NotificationGroupCard: React.FC<NotificationGroupCardProps> = ({ data, mutate }) => {
|
||||
const form = useForm<z.infer<typeof notificationGroupFormSchema>>({
|
||||
resolver: zodResolver(notificationGroupFormSchema),
|
||||
defaultValues: data ? data : {
|
||||
defaultValues: data ? {
|
||||
name: data.group.name,
|
||||
notifications: data.notifications,
|
||||
} : {
|
||||
name: "",
|
||||
notifications: [],
|
||||
},
|
||||
@@ -62,6 +66,12 @@ export const NotificationGroupCard: React.FC<NotificationGroupCardProps> = ({ da
|
||||
form.reset();
|
||||
}
|
||||
|
||||
const { notifiers } = useNotification();
|
||||
const notifierList = notifiers?.map(n => ({
|
||||
value: `${n.id}`,
|
||||
label: n.name,
|
||||
})) || [{ value: "", label: "" }];
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
@@ -103,17 +113,11 @@ export const NotificationGroupCard: React.FC<NotificationGroupCardProps> = ({ da
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Notifiers</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="1,2,3"
|
||||
{...field}
|
||||
value={conv.arrToStr(field.value ?? [])}
|
||||
onChange={e => {
|
||||
const arr = conv.strToArr(e.target.value);
|
||||
field.onChange(arr);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<MultiSelect
|
||||
options={notifierList}
|
||||
onValueChange={field.onChange}
|
||||
defaultValue={field.value?.map(String)}
|
||||
/>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
||||
23
src/components/notification-tab.tsx
Normal file
23
src/components/notification-tab.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
Tabs,
|
||||
TabsList,
|
||||
TabsTrigger,
|
||||
} from "@/components/ui/tabs"
|
||||
import { Link, useLocation } from "react-router-dom"
|
||||
|
||||
export const NotificationTab = ({ className }: { className?: string }) => {
|
||||
const location = useLocation();
|
||||
|
||||
return (
|
||||
<Tabs defaultValue={location.pathname} className={className}>
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="/dashboard/notification" asChild>
|
||||
<Link to="/dashboard/notification">Notifier</Link>
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="/dashboard/alert-rule" asChild>
|
||||
<Link to="/dashboard/alert-rule">Alert Rule</Link>
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
)
|
||||
}
|
||||
263
src/components/notifier.tsx
Normal file
263
src/components/notifier.tsx
Normal file
@@ -0,0 +1,263 @@
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form"
|
||||
import { ScrollArea } from "@/components/ui/scroll-area"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { z } from "zod"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { ModelNotification } from "@/types"
|
||||
import { Checkbox } from "@/components/ui/checkbox"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { useState } from "react"
|
||||
import { KeyedMutator } from "swr"
|
||||
import { asOptionalField } from "@/lib/utils"
|
||||
import { IconButton } from "@/components/xui/icon-button"
|
||||
import { nrequestTypes, nrequestMethods } from "@/types"
|
||||
import { createNotification, updateNotification } from "@/api/notification"
|
||||
import { Textarea } from "./ui/textarea"
|
||||
|
||||
interface NotifierCardProps {
|
||||
data?: ModelNotification;
|
||||
mutate: KeyedMutator<ModelNotification[]>;
|
||||
}
|
||||
|
||||
const notificationFormSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
url: z.string().url(),
|
||||
request_method: z.coerce.number().int().min(1).max(255),
|
||||
request_type: z.coerce.number().int().min(1).max(255),
|
||||
request_header: z.string(),
|
||||
request_body: z.string(),
|
||||
verify_tls: asOptionalField(z.boolean()),
|
||||
skip_check: asOptionalField(z.boolean()),
|
||||
});
|
||||
|
||||
export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
|
||||
const form = useForm<z.infer<typeof notificationFormSchema>>({
|
||||
resolver: zodResolver(notificationFormSchema),
|
||||
defaultValues: data ? data : {
|
||||
name: "",
|
||||
url: "",
|
||||
request_method: 1,
|
||||
request_type: 1,
|
||||
request_header: "",
|
||||
request_body: "",
|
||||
},
|
||||
resetOptions: {
|
||||
keepDefaultValues: false,
|
||||
}
|
||||
})
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const onSubmit = async (values: z.infer<typeof notificationFormSchema>) => {
|
||||
data?.id ? await updateNotification(data.id, values) : await createNotification(values);
|
||||
setOpen(false);
|
||||
await mutate();
|
||||
form.reset();
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
{data
|
||||
?
|
||||
<IconButton variant="outline" icon="edit" />
|
||||
:
|
||||
<IconButton icon="plus" />
|
||||
}
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-xl">
|
||||
<ScrollArea className="max-h-[calc(100dvh-5rem)] p-3">
|
||||
<div className="items-center mx-1">
|
||||
<DialogHeader>
|
||||
<DialogTitle>New Notifier</DialogTitle>
|
||||
<DialogDescription />
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-2 my-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Name</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="My Notifier"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="url"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>URL</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="request_method"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Request Method</FormLabel>
|
||||
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Request Method" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{Object.entries(nrequestMethods).map(([k, v]) => (
|
||||
<SelectItem key={k} value={k}>{v}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="request_type"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Request Type</FormLabel>
|
||||
<Select onValueChange={field.onChange} defaultValue={`${field.value}`}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Request Type" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{Object.entries(nrequestTypes).map(([k, v]) => (
|
||||
<SelectItem key={k} value={k}>{v}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="request_header"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Header</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
className="resize-y"
|
||||
placeholder='{"User-Agent":"Nezha-Agent"}'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="request_body"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Body</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
className="resize-y h-[240px]"
|
||||
placeholder='{ "content":"#NEZHA#", "ServerName":"#SERVER.NAME#", "ServerIP":"#SERVER.IP#", "ServerIPV4":"#SERVER.IPV4#", "ServerIPV6":"#SERVER.IPV6#", "CPU":"#SERVER.CPU#", "MEM":"#SERVER.MEM#", "SWAP":"#SERVER.SWAP#", "DISK":"#SERVER.DISK#", "NetInSpeed":"#SERVER.NETINSPEED#", "NetOutSpeed":"#SERVER.NETOUTSPEED#", "TransferIn":"#SERVER.TRANSFERIN#", "TranferOut":"#SERVER.TRANSFEROUT#", "Load1":"#SERVER.LOAD1#", "Load5":"#SERVER.LOAD5#", "Load15":"#SERVER.LOAD15#", "TCP_CONN_COUNT":"#SERVER.TCPCONNCOUNT", "UDP_CONN_COUNT":"#SERVER.UDPCONNCOUNT" }'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="verify_tls"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center space-x-2">
|
||||
<FormControl>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
<Label className="text-sm">Verify TLS</Label>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="skip_check"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center space-x-2">
|
||||
<FormControl>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
<Label className="text-sm">Do Not Send Test Message</Label>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<DialogFooter className="justify-end">
|
||||
<DialogClose asChild>
|
||||
<Button type="button" className="my-2" variant="secondary">
|
||||
Close
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="my-2">Submit</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import { useState } from "react"
|
||||
import { KeyedMutator } from "swr"
|
||||
import { IconButton } from "@/components/xui/icon-button"
|
||||
import { createServerGroup, updateServerGroup } from "@/api/server-group"
|
||||
import { MultiSelect } from "@/components/xui/multi-select";
|
||||
import { MultiSelect } from "@/components/xui/multi-select"
|
||||
import { useServer } from "@/hooks/useServer"
|
||||
|
||||
interface ServerGroupCardProps {
|
||||
|
||||
Reference in New Issue
Block a user