From 926f96c2c11b01a0353d41f5a05b06e261dce88d Mon Sep 17 00:00:00 2001 From: Br0wnHammer Date: Thu, 8 May 2025 15:28:44 +0530 Subject: [PATCH] Feat: Ignore TLS/SSL Error Option --- client/src/Pages/Uptime/Create/index.jsx | 44 +++++++++++++++--------- client/src/Utils/Theme/globalTheme.js | 26 +++++++++++++- client/src/Validation/validation.js | 1 + client/src/locales/gb.json | 2 ++ 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/client/src/Pages/Uptime/Create/index.jsx b/client/src/Pages/Uptime/Create/index.jsx index 74facf2ef..a4da24ea5 100644 --- a/client/src/Pages/Uptime/Create/index.jsx +++ b/client/src/Pages/Uptime/Create/index.jsx @@ -13,6 +13,8 @@ import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMon import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; // MUI import { Box, Stack, Typography, Button, ButtonGroup } from "@mui/material"; +import Switch from "@mui/material/Switch"; +import FormControlLabel from "@mui/material/FormControlLabel"; //Components import Breadcrumbs from "../../../Components/Breadcrumbs"; @@ -92,6 +94,7 @@ const CreateMonitor = () => { url: "", name: "", type: "http", + ignoreTlsErrors: false, notifications: [], interval: 1, }); @@ -107,6 +110,7 @@ const CreateMonitor = () => { port: monitor.type === "port" ? monitor.port : undefined, name: monitor.name || monitor.url.substring(0, 50), type: monitor.type, + ignoreTlsErrors: monitor.ignoreTlsErrors, interval: monitor.interval * MS_PER_MINUTE, }; @@ -130,19 +134,6 @@ const CreateMonitor = () => { return; } - if (monitor.type === "http") { - // const checkEndpointAction = await dispatch( - // checkEndpointResolution({ monitorURL: form.url }) - // ); - // if (checkEndpointAction.meta.requestStatus === "rejected") { - // createToast({ - // body: "The endpoint you entered doesn't resolve. Check the URL again.", - // }); - // setErrors({ url: "The entered URL is not reachable." }); - // return; - // } - } - form = { ...form, description: monitor.name || monitor.url, @@ -160,11 +151,13 @@ const CreateMonitor = () => { }; const handleChange = (event, formName) => { - const { value } = event.target; + const { type, checked, value } = event.target; + + const newVal = type === "checkbox" ? checked : value; const newMonitor = { ...monitor, - [formName]: value, + [formName]: newVal, }; if (formName === "type") { newMonitor.url = ""; @@ -172,7 +165,7 @@ const CreateMonitor = () => { setMonitor(newMonitor); const { error } = monitorValidation.validate( - { type: monitor.type, [formName]: value }, + { type: monitor.type, [formName]: newVal }, { abortEarly: false } ); setErrors((prev) => ({ @@ -422,6 +415,25 @@ const CreateMonitor = () => { + + + {t("ignoreTSLError")} + {t("ignoreTSLErrorDescription")} + + + handleChange(event, "ignoreTlsErrors")} + sx={{ mr: theme.spacing(2) }} + /> + } + label={"TSL/SSL errors ignored"} + /> + + diff --git a/client/src/Utils/Theme/globalTheme.js b/client/src/Utils/Theme/globalTheme.js index cd8173f83..08a1edca1 100644 --- a/client/src/Utils/Theme/globalTheme.js +++ b/client/src/Utils/Theme/globalTheme.js @@ -453,8 +453,32 @@ const baseTheme = (palette) => ({ MuiSwitch: { styleOverrides: { root: ({ theme }) => ({ + width: 42, + height: 26, + padding: 0, + "& .MuiSwitch-switchBase": { + padding: 0, + margin: 2, + transitionDuration: "300ms", + "&.Mui-checked": { + transform: "translateX(16px)", + color: "#fff", + "& + .MuiSwitch-track": { + backgroundColor: theme.palette.accent.main, + opacity: 1, + border: 0, + }, + }, + }, + "& .MuiSwitch-thumb": { + boxSizing: "border-box", + width: 22, + height: 22, + }, "& .MuiSwitch-track": { - backgroundColor: theme.palette.primary.contrastText, + borderRadius: 13, + backgroundColor: theme.palette.secondary.light, + opacity: 1, }, }), }, diff --git a/client/src/Validation/validation.js b/client/src/Validation/validation.js index 38092c9e6..94c820ef6 100644 --- a/client/src/Validation/validation.js +++ b/client/src/Validation/validation.js @@ -170,6 +170,7 @@ const monitorValidation = joi.object({ "string.max": "This field should not exceed the 50 characters limit.", }), type: joi.string().trim().messages({ "string.empty": "This field is required." }), + ignoreTlsErrors: joi.boolean(), interval: joi.number().messages({ "number.base": "Frequency must be a number.", "any.required": "Frequency is required.", diff --git a/client/src/locales/gb.json b/client/src/locales/gb.json index 3ce6cb3dc..55b358043 100644 --- a/client/src/locales/gb.json +++ b/client/src/locales/gb.json @@ -390,6 +390,8 @@ "FirstName": "First name", "LastName": "Last name", "EmailDescriptionText": "This is your current email address — it cannot be changed.", + "ignoreTSLError": "Ignore TSL/SSL error", + "ignoreTSLErrorDescription": "Ignore TSL/SSL errors and continue checking the website's availability", "YourPhoto": "Your photo", "PhotoDescriptionText": "This photo will be displayed in your profile page.", "save": "Save",