From bdf648c2fe462f06949e79d48719510d8015a76f Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Wed, 18 Jun 2025 23:15:08 +0700 Subject: [PATCH] Add custom check interval option --- .../add-service/ServiceConfigFields.tsx | 142 +++++++++++++----- 1 file changed, 106 insertions(+), 36 deletions(-) diff --git a/application/src/components/services/add-service/ServiceConfigFields.tsx b/application/src/components/services/add-service/ServiceConfigFields.tsx index d172f5e..7145df3 100644 --- a/application/src/components/services/add-service/ServiceConfigFields.tsx +++ b/application/src/components/services/add-service/ServiceConfigFields.tsx @@ -1,49 +1,119 @@ -import { FormControl, FormField, FormItem, FormLabel } from "@/components/ui/form"; +import { FormControl, FormField, FormItem, FormLabel, FormMessage, FormDescription } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { UseFormReturn } from "react-hook-form"; import { ServiceFormData } from "./types"; +import { ServiceUrlField } from "./ServiceUrlField"; +import { useState } from "react"; interface ServiceConfigFieldsProps { form: UseFormReturn; } export function ServiceConfigFields({ form }: ServiceConfigFieldsProps) { + const [isCustomInterval, setIsCustomInterval] = useState(false); + const intervalValue = form.watch("interval"); + + const handleIntervalChange = (value: string) => { + if (value === "custom") { + setIsCustomInterval(true); + form.setValue("interval", ""); + } else { + setIsCustomInterval(false); + form.setValue("interval", value); + } + }; + return ( - <> - ( - - Heartbeat Interval - - - - - )} - /> - - ( - - Maximum Retries - - - - - )} - /> - +
+ + +
+ ( + + Check Interval + {!isCustomInterval ? ( + + + + ) : ( +
+ + + + +
+ )} + + {isCustomInterval + ? "Enter custom interval in seconds (minimum 10 seconds)" + : "How often to check the service status" + } + + +
+ )} + /> + + ( + + Retry Attempts + + + + + Number of retry attempts before marking as down + + + + )} + /> +
+
); } \ No newline at end of file