Feat: Ignore TLS/SSL Error Option

This commit is contained in:
Br0wnHammer committed 2025-05-08 15:28:44 +05:30
1 parent 142b6a909f
commit 926f96c2c1
4 files changed
+56 -17

No files matched your search

+28 -16
View File
@@ -13,6 +13,8 @@ import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMon
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
// MUI // MUI
import { Box, Stack, Typography, Button, ButtonGroup } from "@mui/material"; import { Box, Stack, Typography, Button, ButtonGroup } from "@mui/material";
import Switch from "@mui/material/Switch";
import FormControlLabel from "@mui/material/FormControlLabel";
//Components //Components
import Breadcrumbs from "../../../Components/Breadcrumbs"; import Breadcrumbs from "../../../Components/Breadcrumbs";
@@ -92,6 +94,7 @@ const CreateMonitor = () => {
url: "", url: "",
name: "", name: "",
type: "http", type: "http",
ignoreTlsErrors: false,
notifications: [], notifications: [],
interval: 1, interval: 1,
}); });
@@ -107,6 +110,7 @@ const CreateMonitor = () => {
port: monitor.type === "port" ? monitor.port : undefined, port: monitor.type === "port" ? monitor.port : undefined,
name: monitor.name || monitor.url.substring(0, 50), name: monitor.name || monitor.url.substring(0, 50),
type: monitor.type, type: monitor.type,
ignoreTlsErrors: monitor.ignoreTlsErrors,
interval: monitor.interval * MS_PER_MINUTE, interval: monitor.interval * MS_PER_MINUTE,
}; };
@@ -130,19 +134,6 @@ const CreateMonitor = () => {
return; 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 = {
...form, ...form,
description: monitor.name || monitor.url, description: monitor.name || monitor.url,
@@ -160,11 +151,13 @@ const CreateMonitor = () => {
}; };
const handleChange = (event, formName) => { const handleChange = (event, formName) => {
const { value } = event.target; const { type, checked, value } = event.target;
const newVal = type === "checkbox" ? checked : value;
const newMonitor = { const newMonitor = {
...monitor, ...monitor,
[formName]: value, [formName]: newVal,
}; };
if (formName === "type") { if (formName === "type") {
newMonitor.url = ""; newMonitor.url = "";
@@ -172,7 +165,7 @@ const CreateMonitor = () => {
setMonitor(newMonitor); setMonitor(newMonitor);
const { error } = monitorValidation.validate( const { error } = monitorValidation.validate(
{ type: monitor.type, [formName]: value }, { type: monitor.type, [formName]: newVal },
{ abortEarly: false } { abortEarly: false }
); );
setErrors((prev) => ({ setErrors((prev) => ({
@@ -422,6 +415,25 @@ const CreateMonitor = () => {
</Box> </Box>
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<ConfigBox>
<Box>
<Typography component="h2">{t("ignoreTSLError")}</Typography>
<Typography component="p">{t("ignoreTSLErrorDescription")}</Typography>
</Box>
<Stack>
<FormControlLabel
control={
<Switch
name="ignore-error"
checked={monitor.ignoreTlsErrors}
onChange={(event) => handleChange(event, "ignoreTlsErrors")}
sx={{ mr: theme.spacing(2) }}
/>
}
label={"TSL/SSL errors ignored"}
/>
</Stack>
</ConfigBox>
<ConfigBox> <ConfigBox>
<Box> <Box>
<Typography component="h2"> <Typography component="h2">
+25 -1
View File
@@ -453,8 +453,32 @@ const baseTheme = (palette) => ({
MuiSwitch: { MuiSwitch: {
styleOverrides: { styleOverrides: {
root: ({ theme }) => ({ 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": { "& .MuiSwitch-track": {
backgroundColor: theme.palette.primary.contrastText, borderRadius: 13,
backgroundColor: theme.palette.secondary.light,
opacity: 1,
}, },
}), }),
}, },
+1
View File
@@ -170,6 +170,7 @@ const monitorValidation = joi.object({
"string.max": "This field should not exceed the 50 characters limit.", "string.max": "This field should not exceed the 50 characters limit.",
}), }),
type: joi.string().trim().messages({ "string.empty": "This field is required." }), type: joi.string().trim().messages({ "string.empty": "This field is required." }),
ignoreTlsErrors: joi.boolean(),
interval: joi.number().messages({ interval: joi.number().messages({
"number.base": "Frequency must be a number.", "number.base": "Frequency must be a number.",
"any.required": "Frequency is required.", "any.required": "Frequency is required.",
+2
View File
@@ -390,6 +390,8 @@
"FirstName": "First name", "FirstName": "First name",
"LastName": "Last name", "LastName": "Last name",
"EmailDescriptionText": "This is your current email address — it cannot be changed.", "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", "YourPhoto": "Your photo",
"PhotoDescriptionText": "This photo will be displayed in your profile page.", "PhotoDescriptionText": "This photo will be displayed in your profile page.",
"save": "Save", "save": "Save",