feat: add per-monitor Globalping toggle
Add a globalpingEnabled boolean to the Monitor model so users can opt-in to global location checks per monitor during creation/edit. ## Changes - Add globalpingEnabled field to server types, Mongoose model, Joi validation, and repository mappers - Add globalpingEnabled to client Monitor type, Zod schemas for HTTP and ping monitors, and form defaults - Add "Global monitoring" ConfigBox with Switch toggle to the monitor creation/edit form, visible for HTTP and ping types - Queue helper and monitorService now check globalpingEnabled before running Globalping checks or fetching location data - Add translation keys for the new form section ## Benefits - Users can selectively enable Globalping on monitors that need it rather than running location checks on every HTTP/ping monitor - Reduces unnecessary API usage and keeps the UI clean for monitors that only need local checks
This commit is contained in:
1 parent
7f9d2f275e
commit
4ca24c794e
11 files changed
+47
-3
No files matched your search
@@ -37,6 +37,7 @@ export const useMonitorForm = ({
|
||||
matchMethod: data?.matchMethod || "",
|
||||
expectedValue: data?.expectedValue || "",
|
||||
jsonPath: data?.jsonPath || "",
|
||||
globalpingEnabled: data?.globalpingEnabled || false,
|
||||
};
|
||||
break;
|
||||
case "ping":
|
||||
@@ -44,6 +45,7 @@ export const useMonitorForm = ({
|
||||
...base,
|
||||
type: "ping",
|
||||
url: data?.url || "",
|
||||
globalpingEnabled: data?.globalpingEnabled || false,
|
||||
};
|
||||
break;
|
||||
case "port":
|
||||
|
||||
@@ -488,6 +488,27 @@ const CreateMonitorPage = () => {
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Global monitoring - only for http and ping types */}
|
||||
{(watchedType === "http" || watchedType === "ping") && (
|
||||
<ConfigBox
|
||||
title={t("pages.createMonitor.form.globalping.title")}
|
||||
subtitle={t("pages.createMonitor.form.globalping.description")}
|
||||
rightContent={
|
||||
<Controller
|
||||
name="globalpingEnabled"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Switch
|
||||
id="globalpingEnabled"
|
||||
isChecked={field.value ?? false}
|
||||
onChange={(e) => field.onChange(e.target.checked)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Alert Thresholds - only for hardware type */}
|
||||
{generalSettingsConfig.showSecret && (
|
||||
<ConfigBox
|
||||
|
||||
@@ -59,6 +59,7 @@ export interface Monitor {
|
||||
gameId?: string;
|
||||
group: string | null;
|
||||
locations: string[];
|
||||
globalpingEnabled: boolean;
|
||||
recentChecks: CheckSnapshot[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
@@ -31,12 +31,14 @@ const httpSchema = baseSchema.extend({
|
||||
matchMethod: z.enum(["equal", "include", "regex", ""]).optional(),
|
||||
expectedValue: z.string().optional(),
|
||||
jsonPath: z.string().optional(),
|
||||
globalpingEnabled: z.boolean(),
|
||||
});
|
||||
|
||||
// Ping monitor schema
|
||||
const pingSchema = baseSchema.extend({
|
||||
type: z.literal("ping"),
|
||||
url: z.string().min(1, "Host is required"),
|
||||
globalpingEnabled: z.boolean(),
|
||||
});
|
||||
|
||||
// Port monitor schema
|
||||
|
||||
@@ -445,6 +445,15 @@
|
||||
},
|
||||
"title": "Check frequency"
|
||||
},
|
||||
"globalping": {
|
||||
"title": "Global monitoring",
|
||||
"description": "Run checks from multiple locations around the world using the Globalping network. Configure the API key and location count in settings.",
|
||||
"option": {
|
||||
"enabled": {
|
||||
"label": "Enable Globalping"
|
||||
}
|
||||
}
|
||||
},
|
||||
"general": {
|
||||
"option": {
|
||||
"container": {
|
||||
|
||||
Reference in new issue
Block a user