From a75017603788421c51536313bbaf395b0540432f Mon Sep 17 00:00:00 2001 From: Vishnu Sreekumaran Nair <200557136@student.georgianc.on.ca> Date: Thu, 1 May 2025 13:22:55 -0400 Subject: [PATCH 1/4] add port input field when editing port monitors --- client/src/Pages/Uptime/Configure/index.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/src/Pages/Uptime/Configure/index.jsx b/client/src/Pages/Uptime/Configure/index.jsx index 37d8511c7..118a9448d 100644 --- a/client/src/Pages/Uptime/Configure/index.jsx +++ b/client/src/Pages/Uptime/Configure/index.jsx @@ -371,6 +371,17 @@ const Configure = () => { value={parsedUrl?.host || monitor?.url || ""} disabled={true} /> + handleChange(event, "port")} + error={errors["port"] ? true : false} + helperText={errors["port"]} + hidden={monitor.type !== "port"} + /> Date: Thu, 1 May 2025 13:46:10 -0400 Subject: [PATCH 2/4] include port in update payload for port monitors --- client/src/Utils/NetworkService.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/Utils/NetworkService.js b/client/src/Utils/NetworkService.js index 7c4ffba9f..d7d9d58a6 100644 --- a/client/src/Utils/NetworkService.js +++ b/client/src/Utils/NetworkService.js @@ -266,6 +266,7 @@ class NetworkService { matchMethod: monitor.matchMethod, expectedValue: monitor.expectedValue, jsonPath: monitor.jsonPath, + ...(monitor.type === "port" && { port: monitor.port }), }; return this.axiosInstance.put(`/monitors/${monitorId}`, payload, { headers: { From 2fb20bfff913ac9d02090f6956bd5abec3abfdc5 Mon Sep 17 00:00:00 2001 From: Vishnu Sreekumaran Nair <200557136@student.georgianc.on.ca> Date: Thu, 1 May 2025 13:47:10 -0400 Subject: [PATCH 3/4] allow 'port' field in edit monitor schema --- server/validation/joi.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/validation/joi.js b/server/validation/joi.js index 8f17df0d1..d4f2ceade 100755 --- a/server/validation/joi.js +++ b/server/validation/joi.js @@ -210,6 +210,7 @@ const editMonitorBodyValidation = joi.object({ jsonPath: joi.string().allow(""), expectedValue: joi.string().allow(""), matchMethod: joi.string(), + port: joi.number().min(1).max(65535), thresholds: joi.object().keys({ usage_cpu: joi.number(), usage_memory: joi.number(), From c2ccf344a893bdb4d2994d906c786c756b99e5a2 Mon Sep 17 00:00:00 2001 From: Vishnu Sreekumaran Nair <200557136@student.georgianc.on.ca> Date: Thu, 1 May 2025 20:20:21 -0400 Subject: [PATCH 4/4] Add frontend validation for port field values --- client/src/Validation/validation.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/src/Validation/validation.js b/client/src/Validation/validation.js index 6e8ff76cb..a875da153 100644 --- a/client/src/Validation/validation.js +++ b/client/src/Validation/validation.js @@ -159,7 +159,20 @@ const monitorValidation = joi.object({ "string.invalidUrl": "Please enter a valid URL with optional port", "string.pattern.base": "Please enter a valid container ID.", }), - port: joi.number(), + port: joi.number() + .integer() + .min(1) + .max(65535) + .when("type", { + is: "port", + then: joi.required().messages({ + "number.base": "Port must be a number.", + "number.min": "Port must be at least 1.", + "number.max": "Port must be at most 65535.", + "any.required": "Port is required for port monitors.", + }), + otherwise: joi.optional(), + }), name: joi.string().trim().max(50).allow("").messages({ "string.max": "This field should not exceed the 50 characters limit.", }),