Merge pull request #217 from bluewave-labs/fix/create-monitor-page
Fix/create monitor page
This commit is contained in:
9 files changed
+284
-211
No files matched your search
@@ -33,5 +33,4 @@
|
|||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
color: var(--env-var-color-5);
|
color: var(--env-var-color-5);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,9 @@ const CustomizableCheckbox = (props) => {
|
|||||||
onChange={props.handleChange}
|
onChange={props.handleChange}
|
||||||
className="custom-checkbox"
|
className="custom-checkbox"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="checkbox"
|
id={props.id}
|
||||||
/>
|
/>
|
||||||
<label className="custom-checkbox-label">{props.title}</label>
|
<label className="custom-checkbox-label" htmlFor={props.id}>{props.title}</label>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
* />
|
* />
|
||||||
*
|
*
|
||||||
* @param {Object} props - The component props.
|
* @param {Object} props - The component props.
|
||||||
|
* @param {string} props.id - The id of the radio button.
|
||||||
* @param {string} props.title - The title of the radio button.
|
* @param {string} props.title - The title of the radio button.
|
||||||
* @param {string} [props.desc] - The description of the radio button.
|
* @param {string} [props.desc] - The description of the radio button.
|
||||||
* @param {string} [props.size="small"] - The size of the radio button.
|
* @param {string} [props.size="small"] - The size of the radio button.
|
||||||
@@ -28,7 +29,7 @@ function RadioButton(props) {
|
|||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
checked={props.checked}
|
checked={props.checked}
|
||||||
value={props.value}
|
value={props.value}
|
||||||
control={<Radio size={props.size} />}
|
control={<Radio id={props.id} size={props.size} />}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
label={
|
label={
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ const ProfilePanel = () => {
|
|||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="h4" component="h1">
|
<Typography variant="h4" component="h1">
|
||||||
First Name
|
First name
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -178,7 +178,7 @@ const ProfilePanel = () => {
|
|||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="h4" component="h1">
|
<Typography variant="h4" component="h1">
|
||||||
Last Name
|
Last name
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -232,18 +232,17 @@ const ProfilePanel = () => {
|
|||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="h4" component="h1">
|
<Typography variant="h4" component="h1">
|
||||||
Your Photo
|
Your photo
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="h5" component="p">
|
<Typography variant="h5" component="p">
|
||||||
This photo will be displayed in your profile page.
|
This photo will be displayed in your profile page.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack className="row-stack" direction="row" alignItems="center">
|
<Stack className="row-stack" direction="row" alignItems="center">
|
||||||
{/* TODO - Update placeholder values with redux data */}
|
|
||||||
<Avatar
|
<Avatar
|
||||||
src={picture ? picture.src : "/static/images/avatar/2.jpg"}
|
src={picture ? picture.src : "/static/images/avatar/2.jpg"}
|
||||||
firstName={localData.firstname}
|
firstName={user?.firstname}
|
||||||
lastName={localData.lastname}
|
lastName={user?.lastname}
|
||||||
sx={{
|
sx={{
|
||||||
width: "64px",
|
width: "64px",
|
||||||
height: "64px",
|
height: "64px",
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
import "./flexibileTextField.css";
|
import "./flexibileTextField.css";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const FlexibileTextField = ({ title, type, placeholder, value, onChange }) => {
|
const FlexibileTextField = ({
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
type,
|
||||||
|
placeholder,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="flexibile-textfield">
|
<div className="flexibile-textfield">
|
||||||
<div className="flexibile-textfield-title">{title}</div>
|
<div className="flexibile-textfield-title">{title}</div>
|
||||||
<input
|
<input
|
||||||
|
id={id}
|
||||||
type={type}
|
type={type}
|
||||||
className="flexibile-textfield-input"
|
className="flexibile-textfield-input"
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
|||||||
@@ -3,122 +3,108 @@ import ConfigBox from "../../Components/ConfigBox";
|
|||||||
import FlexibileTextField from "../../Components/TextFields/Flexibile/FlexibileTextField";
|
import FlexibileTextField from "../../Components/TextFields/Flexibile/FlexibileTextField";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import RadioButton from "../../Components/RadioButton";
|
import RadioButton from "../../Components/RadioButton";
|
||||||
import Dropdown from "../../Components/Dropdown";
|
|
||||||
import CustomizableCheckBox from "../../Components/Checkbox/CustomizableCheckbox";
|
import CustomizableCheckBox from "../../Components/Checkbox/CustomizableCheckbox";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
|
import { MenuItem, Select, Typography } from "@mui/material";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import { createMonitorValidation } from "../../Validation/validation";
|
||||||
|
|
||||||
const CreateNewMonitor = () => {
|
const CreateNewMonitor = () => {
|
||||||
const portOptions = [
|
const { user } = useSelector((state) => state.auth);
|
||||||
{ label: "Port 1", value: "Port1" },
|
const [errors, setErrors] = useState({});
|
||||||
{ label: "Port 2", value: "Port2" },
|
|
||||||
// Add more Ports as needed
|
|
||||||
];
|
|
||||||
|
|
||||||
const frequencyOptions = [
|
//General Settings Form
|
||||||
{ label: "1 minute", value: "1" },
|
const [generalSettings, setGeneralSettings] = useState({ url: "", name: "" });
|
||||||
{ label: "5 minutes", value: "5" },
|
//Checks Form
|
||||||
// Add more Ports as needed
|
const [checks, setChecks] = useState({
|
||||||
];
|
type: "",
|
||||||
|
// port: ""
|
||||||
|
});
|
||||||
|
//Incidents Form
|
||||||
|
// const [notifications, setNotifications] = useState({
|
||||||
|
// viaSms: false,
|
||||||
|
// viaEmail: false,
|
||||||
|
// viaOther: false,
|
||||||
|
// email: "",
|
||||||
|
// });
|
||||||
|
//Advanced Settings Form
|
||||||
|
const [advancedSettings, setAdvancedSettings] = useState({
|
||||||
|
frequency: "",
|
||||||
|
// retries: "",
|
||||||
|
// codes: "",
|
||||||
|
// redirects: "",
|
||||||
|
});
|
||||||
|
//Proxy Settings Form
|
||||||
|
// const [proxy, setProxy] = useState({
|
||||||
|
// enabled: false,
|
||||||
|
// protocol: "",
|
||||||
|
// address: "",
|
||||||
|
// proxy_port: "",
|
||||||
|
// });
|
||||||
|
|
||||||
const [incidentEmail, setIncidentEmail] = useState("");
|
const handleChange = (event, id, setState, checkbox) => {
|
||||||
|
const { value } = event.target;
|
||||||
|
setState((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[id]: checkbox ? true : value,
|
||||||
|
}));
|
||||||
|
|
||||||
const [notifyViaSMS, setNotifyViaSMS] = useState(false);
|
const validation = createMonitorValidation.validate(
|
||||||
const [notifyViaEmail, setNotifyViaEmail] = useState(false);
|
{ [id]: value },
|
||||||
const [notifyViaCurrentEmail, setNotifyViaCurrentEmail] = useState(false);
|
{ abortEarly: false }
|
||||||
|
);
|
||||||
|
|
||||||
const [maxRetries, setMaxRetries] = useState(0);
|
setErrors((prev) => {
|
||||||
const [acceptCode, setAcceptCode] = useState(0);
|
const updatedErrors = { ...prev };
|
||||||
const [maxRedirects, setMaxRedirects] = useState(0);
|
|
||||||
|
|
||||||
const [proxy, setProxy] = useState(false);
|
if (validation.error) {
|
||||||
|
updatedErrors[id] = validation.error.details[0].message;
|
||||||
|
} else {
|
||||||
|
delete updatedErrors[id];
|
||||||
|
}
|
||||||
|
return updatedErrors;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// const handleCheck = (id, setState) => {
|
||||||
|
// setState((prev) => ({
|
||||||
|
// ...prev,
|
||||||
|
// [id]: !prev[id],
|
||||||
|
// }));
|
||||||
|
// };
|
||||||
|
|
||||||
const [proxyAddress, setProxyAddress] = useState("");
|
const handleCreateNewMonitor = (event) => {
|
||||||
const [proxyPort, setProxyPort] = useState("");
|
event.preventDefault();
|
||||||
|
//obj to submit
|
||||||
|
const monitor = {
|
||||||
|
...generalSettings,
|
||||||
|
...advancedSettings,
|
||||||
|
userId: user._id,
|
||||||
|
...checks,
|
||||||
|
};
|
||||||
|
|
||||||
const [selectedMonitorType, setSelectedMonitorType] = useState("");
|
const { error } = createMonitorValidation.validate(monitor, {
|
||||||
|
abortEarly: false,
|
||||||
|
});
|
||||||
|
|
||||||
const [urlToMonitor, setUrlToMonitor] = useState("");
|
if (error) {
|
||||||
const [friendlyName, setFriendlyName] = useState("");
|
const newErrors = {};
|
||||||
|
error.details.forEach((err) => {
|
||||||
const [port, setPort] = useState("Select a port to check");
|
newErrors[err.path[0]] = err.message;
|
||||||
const [frequncy, setFrequency] = useState("1 minute");
|
});
|
||||||
|
setErrors(newErrors);
|
||||||
const handlePortOptionChange = (newValue) => {
|
} else {
|
||||||
setPort(newValue);
|
//TODO - submit logic
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFrequencyOptionChange = (newValue) => {
|
console.log(errors);
|
||||||
setPort(newValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUrlToMonitor = (event) => {
|
//select values
|
||||||
setUrlToMonitor(event.target.value);
|
// const ports = ["Port 1", "Port 2", "Port 3"];
|
||||||
console.log(urlToMonitor);
|
const frequencies = [1, 2, 3, 4, 5];
|
||||||
};
|
|
||||||
|
|
||||||
const handleFriendlyName = (event) => {
|
|
||||||
setFriendlyName(event.target.value);
|
|
||||||
console.log(friendlyName);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleIncidentEmail = (event) => {
|
|
||||||
setIncidentEmail(event.target.value);
|
|
||||||
console.log(incidentEmail);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNotifyViaSMS = (event) => {
|
|
||||||
setNotifyViaSMS(event.target.checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNotifyViaEmail = (event) => {
|
|
||||||
setNotifyViaEmail(event.target.checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNotifyViaCurrentEmail = (event) => {
|
|
||||||
setNotifyViaCurrentEmail(event.target.checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSetMaxRetries = (event) => {
|
|
||||||
setMaxRetries(event.target.value);
|
|
||||||
console.log(maxRetries);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSetAcceptCode = (event) => {
|
|
||||||
setAcceptCode(event.target.value);
|
|
||||||
console.log(acceptCode);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSetMaxRedirects = (event) => {
|
|
||||||
setMaxRedirects(event.target.value);
|
|
||||||
console.log(maxRedirects);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEnableProxy = (event) => {
|
|
||||||
setProxy(event.target.value);
|
|
||||||
console.log(proxy);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleproxyAddress = (event) => {
|
|
||||||
setProxyAddress(event.target.value);
|
|
||||||
console.log(proxyAddress);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleproxyPort = (event) => {
|
|
||||||
setProxyPort(event.target.value);
|
|
||||||
console.log(proxyPort);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMonitorTypeChange = (value) => {
|
|
||||||
setSelectedMonitorType(value);
|
|
||||||
console.log(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCreateNewMonitor = () => {
|
|
||||||
console.log("Created");
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<form onSubmit={handleCreateNewMonitor} noValidate spellCheck="false">
|
||||||
<div className="new-monitor-header">Create new monitor</div>
|
<div className="new-monitor-header">Create new monitor</div>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
@@ -134,18 +120,40 @@ const CreateNewMonitor = () => {
|
|||||||
rightLayout={
|
rightLayout={
|
||||||
<div className="config-box-inputs">
|
<div className="config-box-inputs">
|
||||||
<FlexibileTextField
|
<FlexibileTextField
|
||||||
|
id="monitor-url"
|
||||||
title="URL to monitor"
|
title="URL to monitor"
|
||||||
type="url"
|
type="url"
|
||||||
placeholder="https://google.com"
|
placeholder="https://google.com"
|
||||||
onChange={handleUrlToMonitor}
|
value={generalSettings.url}
|
||||||
|
onChange={(event) =>
|
||||||
|
handleChange(event, "url", setGeneralSettings)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
{errors["url"] ? (
|
||||||
|
<Typography variant="h5" component="p" className="input-error">
|
||||||
|
{errors["url"]}
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<FlexibileTextField
|
<FlexibileTextField
|
||||||
|
id="monitor-name"
|
||||||
title="Friendly name (optional)"
|
title="Friendly name (optional)"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Google"
|
placeholder="Google"
|
||||||
onChange={handleFriendlyName}
|
value={generalSettings.name}
|
||||||
|
onChange={(event) =>
|
||||||
|
handleChange(event, "name", setGeneralSettings)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
{errors["name"] ? (
|
||||||
|
<Typography variant="h5" component="p" className="input-error">
|
||||||
|
{errors["name"]}
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -163,42 +171,62 @@ const CreateNewMonitor = () => {
|
|||||||
rightLayout={
|
rightLayout={
|
||||||
<div className="service-check-list">
|
<div className="service-check-list">
|
||||||
<RadioButton
|
<RadioButton
|
||||||
|
id="monitor-checks-http"
|
||||||
title="HTTP/website monitoring"
|
title="HTTP/website monitoring"
|
||||||
desc="Use HTTP(s) to monitor your website or API endpoint."
|
desc="Use HTTP(s) to monitor your website or API endpoint."
|
||||||
value="http"
|
value="http"
|
||||||
checked={selectedMonitorType === "http"}
|
checked={checks.type === "http"}
|
||||||
onChange={() => handleMonitorTypeChange("http")}
|
onChange={(event) => handleChange(event, "type", setChecks)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
|
id="monitor-checks-ping"
|
||||||
title="Ping monitoring"
|
title="Ping monitoring"
|
||||||
desc="Check whether your server is available or not."
|
desc="Check whether your server is available or not."
|
||||||
value="ping"
|
value="ping"
|
||||||
checked={selectedMonitorType === "ping"}
|
checked={checks.type === "ping"}
|
||||||
onChange={() => handleMonitorTypeChange("ping")}
|
onChange={(event) => handleChange(event, "type", setChecks)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<RadioButton
|
{/* TODO */}
|
||||||
|
{/* <RadioButton
|
||||||
|
id="monitor-checks-port"
|
||||||
title="Port monitoring"
|
title="Port monitoring"
|
||||||
desc="Monitor a specific service on your server."
|
desc="Monitor a specific service on your server."
|
||||||
value="port"
|
value="port"
|
||||||
checked={selectedMonitorType === "port"}
|
checked={checks.type === "port"}
|
||||||
onChange={() => handleMonitorTypeChange("port")}
|
onChange={(event) => handleChange(event, "type", setChecks)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-small-plus"></div>
|
<div className="monitors-gaps-small-plus"></div>
|
||||||
<div className="monitors-dropdown-holder">
|
<div className="monitors-dropdown-holder">
|
||||||
<Dropdown
|
<Select
|
||||||
id="ports-dropdown"
|
id="monitor-ports"
|
||||||
label="Select a port to check"
|
value={checks.port || "placeholder"}
|
||||||
onChange={handlePortOptionChange}
|
inputProps={{ id: "monitor-ports-select" }}
|
||||||
options={portOptions}
|
onChange={(event) => handleChange(event, "port", setChecks)}
|
||||||
value={port}
|
>
|
||||||
/>
|
<MenuItem id="port-placeholder" value="placeholder">
|
||||||
</div>
|
Select a port to check
|
||||||
|
</MenuItem>
|
||||||
|
{ports.map((port, index) => (
|
||||||
|
<MenuItem key={`port-${index}`} value={port}>
|
||||||
|
{port}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</div> */}
|
||||||
|
{errors["type"] ? (
|
||||||
|
<Typography variant="h5" component="p" className="input-error">
|
||||||
|
{errors["type"]}
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
{/* TODO */}
|
||||||
|
{/* <div className="monitors-gaps-medium"></div>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
leftLayout={
|
leftLayout={
|
||||||
@@ -217,35 +245,41 @@ const CreateNewMonitor = () => {
|
|||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="incident-notif-config-checks">
|
<div className="incident-notif-config-checks">
|
||||||
<CustomizableCheckBox
|
<CustomizableCheckBox
|
||||||
isChecked={notifyViaSMS}
|
id="monitor-notify-sms"
|
||||||
handleChange={handleNotifyViaSMS}
|
|
||||||
title="Notify via SMS (to be implemented)"
|
title="Notify via SMS (to be implemented)"
|
||||||
|
isChecked={notifications.viaSms}
|
||||||
|
handleChange={() => handleCheck("viaSms", setNotifications)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<CustomizableCheckBox
|
<CustomizableCheckBox
|
||||||
isChecked={notifyViaEmail}
|
id="monitor-notify-email"
|
||||||
handleChange={handleNotifyViaEmail}
|
|
||||||
title="Notify via email (to current email address)"
|
title="Notify via email (to current email address)"
|
||||||
|
isChecked={notifications.viaEmail}
|
||||||
|
handleChange={() => handleCheck("viaEmail", setNotifications)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<CustomizableCheckBox
|
<CustomizableCheckBox
|
||||||
isChecked={notifyViaCurrentEmail}
|
id="monitor-notify-other"
|
||||||
handleChange={handleNotifyViaCurrentEmail}
|
|
||||||
title="Notify via email (to another email address below)"
|
title="Notify via email (to another email address below)"
|
||||||
|
isChecked={notifications.viaOther}
|
||||||
|
handleChange={() => handleCheck("viaOther", setNotifications)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-small-plus"></div>
|
<div className="monitors-gaps-small-plus"></div>
|
||||||
<div className="monitors-dropdown-holder">
|
<div className="monitors-dropdown-holder">
|
||||||
<FlexibileTextField
|
<FlexibileTextField
|
||||||
|
id="monitor-notify-other-email"
|
||||||
placeholder="notifications@gmail.com"
|
placeholder="notifications@gmail.com"
|
||||||
type="email"
|
type="email"
|
||||||
value={incidentEmail}
|
value={notifications.email}
|
||||||
onChange={handleIncidentEmail}
|
onChange={(event) =>
|
||||||
|
handleChange(event, "email", setNotifications)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/> */}
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
@@ -258,40 +292,56 @@ const CreateNewMonitor = () => {
|
|||||||
<div className="advanced-setting-config">
|
<div className="advanced-setting-config">
|
||||||
<div className="adv-setting-title">Check frequency</div>
|
<div className="adv-setting-title">Check frequency</div>
|
||||||
<div className="monitors-gaps-small"></div>
|
<div className="monitors-gaps-small"></div>
|
||||||
<Dropdown
|
<Select
|
||||||
id="freq-dropdown"
|
id="monitor-frequencies"
|
||||||
label="1 minutes"
|
value={advancedSettings.frequency || 1}
|
||||||
onChange={handleFrequencyOptionChange}
|
inputProps={{ id: "monitor-frequencies-select" }}
|
||||||
options={frequencyOptions}
|
onChange={(event) =>
|
||||||
value={frequencyOptions}
|
handleChange(event, "frequency", setAdvancedSettings)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{frequencies.map((freq) => (
|
||||||
|
<MenuItem key={`port-${freq}`} value={freq}>
|
||||||
|
{freq} {freq === 1 ? "minute" : "minutes"}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
<div className="monitors-gaps-medium"></div>
|
||||||
|
{/* TODO */}
|
||||||
|
{/* <FlexibileTextField
|
||||||
|
id="monitor-settings-retries"
|
||||||
|
title="Maximum retries before the service is marked as down"
|
||||||
|
type="number"
|
||||||
|
value={advancedSettings.retries}
|
||||||
|
onChange={(event) =>
|
||||||
|
handleChange(event, "retries", setAdvancedSettings)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="adv-setting-title">
|
|
||||||
Maximum retries before the service is marked as down
|
|
||||||
</div>
|
|
||||||
<FlexibileTextField
|
<FlexibileTextField
|
||||||
onChange={handleSetMaxRetries}
|
id="monitor-settings-codes"
|
||||||
|
title="Accepted status codes"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder=""
|
value={advancedSettings.codes}
|
||||||
|
onChange={(event) =>
|
||||||
|
handleChange(event, "codes", setAdvancedSettings)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="adv-setting-title">Accepted status codes</div>
|
|
||||||
<FlexibileTextField
|
<FlexibileTextField
|
||||||
onChange={handleSetAcceptCode}
|
id="monitor-settings-redirects"
|
||||||
|
title="Maximum redirects"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder=""
|
value={advancedSettings.redirects}
|
||||||
/>
|
onChange={(event) =>
|
||||||
<div className="monitors-gaps-medium"></div>
|
handleChange(event, "redirects", setAdvancedSettings)
|
||||||
<div className="adv-setting-title">Maximum redirects</div>
|
}
|
||||||
<FlexibileTextField
|
/> */}
|
||||||
onChange={handleSetMaxRedirects}
|
|
||||||
type="number"
|
|
||||||
placeholder=""
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
{/* TODO */}
|
||||||
|
{/* <div className="monitors-gaps-medium"></div>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
leftLayout={
|
leftLayout={
|
||||||
@@ -302,22 +352,35 @@ const CreateNewMonitor = () => {
|
|||||||
rightLayout={
|
rightLayout={
|
||||||
<div className="proxy-setting-config">
|
<div className="proxy-setting-config">
|
||||||
<CustomizableCheckBox
|
<CustomizableCheckBox
|
||||||
isChecked={proxy}
|
id="monitor-proxy-enable"
|
||||||
handleChange={handleEnableProxy}
|
|
||||||
title="Enable proxy"
|
title="Enable proxy"
|
||||||
|
isChecked={proxy.enabled}
|
||||||
|
handleChange={() => handleCheck("enabled", setProxy)}
|
||||||
/>
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="adv-setting-title">Proxy protocol</div>
|
<FlexibileTextField
|
||||||
<FlexibileTextField />
|
id="monitor-proxy-protocol"
|
||||||
|
title="Proxy protocol"
|
||||||
|
value={proxy.protocol}
|
||||||
|
onChange={(event) => handleChange(event, "protocol", setProxy)}
|
||||||
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="adv-setting-title">Proxy address</div>
|
<FlexibileTextField
|
||||||
<FlexibileTextField onChange={handleproxyAddress} />
|
id="monitor-proxy-address"
|
||||||
|
title="Proxy address"
|
||||||
|
value={proxy.address}
|
||||||
|
onChange={(event) => handleChange(event, "address", setProxy)}
|
||||||
|
/>
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="adv-setting-title">Proxy port</div>
|
<FlexibileTextField
|
||||||
<FlexibileTextField onChange={handleproxyPort} />
|
id="monitor-proxy-port"
|
||||||
|
title="Proxy port"
|
||||||
|
value={proxy.proxy_port}
|
||||||
|
onChange={(event) => handleChange(event, "proxy_port", setProxy)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/> */}
|
||||||
<div className="monitors-gaps-medium"></div>
|
<div className="monitors-gaps-medium"></div>
|
||||||
<div className="monitors-gaps-small"></div>
|
<div className="monitors-gaps-small"></div>
|
||||||
<div className="monitors-create-button-holder">
|
<div className="monitors-create-button-holder">
|
||||||
@@ -326,10 +389,10 @@ const CreateNewMonitor = () => {
|
|||||||
level="primary"
|
level="primary"
|
||||||
label="Create new monitor"
|
label="Create new monitor"
|
||||||
sx={{ width: "210px", fontSize: "var(--env-var-font-size-medium)" }}
|
sx={{ width: "210px", fontSize: "var(--env-var-font-size-medium)" }}
|
||||||
onClick={() => handleCreateNewMonitor()}
|
onClick={handleCreateNewMonitor}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ const Monitors = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="monitors">
|
<div className="monitors">
|
||||||
{/* <CurrentStats monitors={monitorState.monitors} /> */}
|
<CurrentStats monitors={monitorState.monitors} />
|
||||||
<CreateNewMonitor />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -173,7 +173,6 @@
|
|||||||
|
|
||||||
.settings .MuiStack-root:has(p.MuiTypography-root.input-error) {
|
.settings .MuiStack-root:has(p.MuiTypography-root.input-error) {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
}
|
||||||
.settings .text-field-icon {
|
.settings .text-field-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -82,43 +82,41 @@ const editProfileValidation = joi.object({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const passwordSchema = joi
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.min(8)
|
||||||
|
.messages({
|
||||||
|
"string.empty": "*Password is required.",
|
||||||
|
"string.min": "*Password must be at least 8 characters long.",
|
||||||
|
})
|
||||||
|
.custom((value, helpers) => {
|
||||||
|
if (!/[A-Z]/.test(value)) {
|
||||||
|
return helpers.message(
|
||||||
|
"*Password must contain at least one uppercase letter."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!/[a-z]/.test(value)) {
|
||||||
|
return helpers.message(
|
||||||
|
"*Password must contain at least one lowercase letter."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!/\d/.test(value)) {
|
||||||
|
return helpers.message("*Password must contain at least one number.");
|
||||||
|
}
|
||||||
|
if (!/[!@#$%^&*]/.test(value)) {
|
||||||
|
return helpers.message(
|
||||||
|
"*Password must contain at least one special character."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
|
||||||
const editPasswordValidation = joi.object({
|
const editPasswordValidation = joi.object({
|
||||||
// TBD - validation for current password ?
|
// TBD - validation for current password ?
|
||||||
password : joi
|
password: passwordSchema,
|
||||||
.string().trim()
|
newpassword: passwordSchema,
|
||||||
.messages({
|
|
||||||
"string.empty": "*Current password is required.",
|
|
||||||
}),
|
|
||||||
newpassword: joi
|
|
||||||
.string()
|
|
||||||
.trim()
|
|
||||||
.min(8)
|
|
||||||
.messages({
|
|
||||||
"string.empty": "*Password is required.",
|
|
||||||
"string.min": "*Password must be at least 8 characters long.",
|
|
||||||
})
|
|
||||||
.custom((value, helpers) => {
|
|
||||||
if (!/[A-Z]/.test(value)) {
|
|
||||||
return helpers.message(
|
|
||||||
"*Password must contain at least one uppercase letter."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!/[a-z]/.test(value)) {
|
|
||||||
return helpers.message(
|
|
||||||
"*Password must contain at least one lowercase letter."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!/\d/.test(value)) {
|
|
||||||
return helpers.message("*Password must contain at least one number.");
|
|
||||||
}
|
|
||||||
if (!/[!@#$%^&*]/.test(value)) {
|
|
||||||
return helpers.message(
|
|
||||||
"*Password must contain at least one special character."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}),
|
|
||||||
confirm: joi
|
confirm: joi
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
@@ -126,15 +124,22 @@ const editPasswordValidation = joi.object({
|
|||||||
"string.empty": "*Password confirmation is required.",
|
"string.empty": "*Password confirmation is required.",
|
||||||
})
|
})
|
||||||
.custom((value, helpers) => {
|
.custom((value, helpers) => {
|
||||||
const { password } = helpers.prefs.context;
|
const { newpassword } = helpers.prefs.context;
|
||||||
if (value !== password) {
|
if (value !== newpassword) {
|
||||||
return helpers.message("*Passwords do not match.");
|
return helpers.message("*Passwords do not match.");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const createMonitorValidation = joi.object({
|
||||||
|
url: joi.string().trim().messages({ "string.empty": "*Url is required." }),
|
||||||
|
name: joi.string().trim().messages({ "string.empty": "*Name is required." }),
|
||||||
|
type: joi.string().trim().messages({ "string.empty": "*Type is required." }),
|
||||||
|
});
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
createMonitorValidation,
|
||||||
registerValidation,
|
registerValidation,
|
||||||
loginValidation,
|
loginValidation,
|
||||||
recoveryValidation,
|
recoveryValidation,
|
||||||
|
|||||||
Reference in new issue
Block a user