From 19fc85ae2d9dda7570ee239064fca6f5255777ec Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Sun, 22 Feb 2026 23:25:04 +0000 Subject: [PATCH] front end --- client/src/Hooks/useMonitorForm.ts | 3 + client/src/Pages/CreateMonitor/index.tsx | 87 +++++++++++++++++++++++- client/src/Types/Monitor.ts | 6 ++ client/src/Validation/monitor.ts | 3 + client/src/locales/en.json | 25 +++++++ 5 files changed, 123 insertions(+), 1 deletion(-) diff --git a/client/src/Hooks/useMonitorForm.ts b/client/src/Hooks/useMonitorForm.ts index 633fcb5c9..392b5064c 100644 --- a/client/src/Hooks/useMonitorForm.ts +++ b/client/src/Hooks/useMonitorForm.ts @@ -14,6 +14,9 @@ const getBaseDefaults = (data?: Monitor | null) => ({ notifications: data?.notifications || [], statusWindowSize: data?.statusWindowSize || 5, statusWindowThreshold: data?.statusWindowThreshold || 60, + geoCheckEnabled: data?.geoCheckEnabled || false, + geoCheckLocations: data?.geoCheckLocations || [], + geoCheckInterval: data?.geoCheckInterval || 300000, }); export const useMonitorForm = ({ diff --git a/client/src/Pages/CreateMonitor/index.tsx b/client/src/Pages/CreateMonitor/index.tsx index 5012c1154..4bd29b941 100644 --- a/client/src/Pages/CreateMonitor/index.tsx +++ b/client/src/Pages/CreateMonitor/index.tsx @@ -29,7 +29,8 @@ import { } from "@/Components/inputs"; import { useGet, usePost, usePatch, useDelete } from "@/Hooks/UseApi"; import { useMonitorForm } from "@/Hooks/useMonitorForm"; -import type { Monitor, MonitorType, GamesMap } from "@/Types/Monitor"; +import type { Monitor, MonitorType, GamesMap, GeoCheckLocation } from "@/Types/Monitor"; +import { GeoCheckLocations } from "@/Types/Monitor"; import type { Notification } from "@/Types/Notification"; import type { MonitorFormData } from "@/Validation/monitor"; @@ -165,6 +166,7 @@ const CreateMonitorPage = () => { const watchedType = watch("type") as MonitorType; const watchedUseAdvancedMatching = watch("useAdvancedMatching") as boolean; + const watchGeoCheckEnabled = watch("geoCheckEnabled") as boolean; useEffect(() => { clearErrors(); @@ -823,6 +825,89 @@ const CreateMonitorPage = () => { /> )} + {/* Geo-distributed Checks Configuration */} + {watchedType === "http" && ( + + ( + + field.onChange(e.target.checked)} + /> + + {t("pages.createMonitor.form.geoChecks.option.enabled.label")} + + + )} + /> + {watchGeoCheckEnabled && ( + + { + const locationOptions = GeoCheckLocations.map((loc) => ({ + id: loc, + name: t( + `pages.createMonitor.form.geoChecks.option.locations.options.${loc}` + ), + })); + const selectedLocations = locationOptions.filter((loc) => + (field.value ?? []).includes(loc.id) + ); + return ( + option.name} + onChange={(_, newValue: typeof locationOptions) => { + field.onChange(newValue.map((loc) => loc.id)); + }} + isOptionEqualToValue={(option, value) => option.id === value.id} + fieldLabel={t( + "pages.createMonitor.form.geoChecks.option.locations.label" + )} + /> + ); + }} + /> + ( + + )} + /> + + )} + + } + /> + )} +