feat: disable nat

This commit is contained in:
naiba
2025-01-21 22:21:52 +08:00
parent 0d275084d9
commit 30ae419cbd
3 changed files with 30 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ import { useTranslation } from "react-i18next"
import { toast } from "sonner" import { toast } from "sonner"
import { KeyedMutator } from "swr" import { KeyedMutator } from "swr"
import { z } from "zod" import { z } from "zod"
import { Checkbox } from "./ui/checkbox"
import { Label } from "./ui/label"
interface NATCardProps { interface NATCardProps {
data?: ModelNAT data?: ModelNAT
@@ -37,6 +39,7 @@ interface NATCardProps {
const natFormSchema = z.object({ const natFormSchema = z.object({
name: z.string().min(1), name: z.string().min(1),
enabled: z.boolean(),
server_id: z.coerce.number().int(), server_id: z.coerce.number().int(),
host: z.string(), host: z.string(),
domain: z.string(), domain: z.string(),
@@ -50,6 +53,7 @@ export const NATCard: React.FC<NATCardProps> = ({ data, mutate }) => {
? data ? data
: { : {
name: "", name: "",
enabled: false,
server_id: 0, server_id: 0,
host: "", host: "",
domain: "", domain: "",
@@ -148,6 +152,26 @@ export const NATCard: React.FC<NATCardProps> = ({ data, mutate }) => {
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={form.control}
name="enabled"
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">
{t("Enable")}
</Label>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<DialogFooter className="justify-end"> <DialogFooter className="justify-end">
<DialogClose asChild> <DialogClose asChild>
<Button type="button" className="my-2" variant="secondary"> <Button type="button" className="my-2" variant="secondary">

View File

@@ -61,6 +61,11 @@ export default function NATPage() {
accessorKey: "id", accessorKey: "id",
accessorFn: (row) => row.id, accessorFn: (row) => row.id,
}, },
{
header: t("Enabled"),
accessorKey: "enabled",
accessorFn: (row) => row.enabled,
},
{ {
header: t("Name"), header: t("Name"),
accessorKey: "name", accessorKey: "name",

View File

@@ -401,6 +401,7 @@ export interface ModelLoginResponse {
export interface ModelNAT { export interface ModelNAT {
created_at: string created_at: string
domain: string domain: string
enabled: boolean
host: string host: string
id: number id: number
name: string name: string