From 63cb4e7f1d8c0a4451d6ab6d4ae38fc6d1770995 Mon Sep 17 00:00:00 2001 From: Shemy Gan Date: Wed, 6 Nov 2024 11:13:02 -0500 Subject: [PATCH] - Add basic joi validation to match what's available in BE - Extract/ refactor the custom alert section to its own function - WIP UI added custom alert section, retain log section and maxreties in advaced setting section - Extend Field component to accomodate for custom alert narrower text field --- Client/src/Components/Inputs/Field/index.css | 9 + Client/src/Components/Inputs/Field/index.jsx | 4 +- .../infrastructureMonitorsSlice.js | 3 +- .../CreateMonitor/index.jsx | 305 ++++++++---------- Client/src/Validation/validation.js | 24 ++ 5 files changed, 170 insertions(+), 175 deletions(-) diff --git a/Client/src/Components/Inputs/Field/index.css b/Client/src/Components/Inputs/Field/index.css index 2d251e4bf..3dfaf6142 100644 --- a/Client/src/Components/Inputs/Field/index.css +++ b/Client/src/Components/Inputs/Field/index.css @@ -1,6 +1,15 @@ .field { min-width: 250px; } + +.field-infrastructure-alert { + max-width: 100px; +} + +.field-infrastructure-alert .MuiInputBase-root:has(input) { + height: 34px; +} + .field h3.MuiTypography-root, .field h5.MuiTypography-root, .field input, diff --git a/Client/src/Components/Inputs/Field/index.jsx b/Client/src/Components/Inputs/Field/index.jsx index 4ead8a705..0e52dda2d 100644 --- a/Client/src/Components/Inputs/Field/index.jsx +++ b/Client/src/Components/Inputs/Field/index.jsx @@ -46,6 +46,7 @@ const Field = forwardRef( error, disabled, hidden, + className }, ref ) => { @@ -56,7 +57,7 @@ const Field = forwardRef( return ( { + const CustomAlertStack = ({ + checkboxId, + checkboxLabel, + checkboxValue, + isChecked, + onChange, + fieldId, + fieldValue, + alertUnit, + }) => { + console.log("fieldValue") + console.log(fieldValue) + return ( + + + + + + + + {alertUnit} + + + + );} + const MS_PER_MINUTE = 60000; const { user, authToken } = useSelector((state) => state.auth); const monitorState = useSelector((state) => state.infrastructureMonitor); @@ -30,19 +80,16 @@ const CreateInfrastructureMonitor = () => { "monitor-url": "url", "monitor-name": "name", "monitor-secret": "secret", - "monitor-checks-http": "type", - "monitor-checks-ping": "type", "notify-email-default": "notification-email", }; const [infrastructureMonitor, setInfrastructureMonitor] = useState({ url: "", name: "", - type: "http", notifications: [], interval: 1, + threshold: {cpu: "", disk: "", memory: ""} }); - const [https, setHttps] = useState(true); const [errors, setErrors] = useState({}); const handleChange = (event, name) => { @@ -80,7 +127,7 @@ const CreateInfrastructureMonitor = () => { [name]: value, })); - const { error } = monitorValidation.validate( + const { error } = infrastractureMonitorValidation.validate( { [name]: value }, { abortEarly: false } ); @@ -98,20 +145,15 @@ const CreateInfrastructureMonitor = () => { event.preventDefault(); //obj to submit let form = { - url: - //preprending protocol for url - infrastructureMonitor.type === "http" - ? `http${https ? "s" : ""}://` + infrastructureMonitor.url - : infrastructureMonitor.url, + url:infrastructureMonitor.url, name: infrastructureMonitor.name === "" ? infrastructureMonitor.url : infrastructureMonitor.name, - type: infrastructureMonitor.type, interval: infrastructureMonitor.interval * MS_PER_MINUTE, }; - const { error } = monitorValidation.validate(form, { + const { error } =infrastractureMonitorValidation.validate(form, { abortEarly: false, }); @@ -287,166 +329,75 @@ const CreateInfrastructureMonitor = () => { - - - handleChange(event)} - /> - - - - - - - - % - - - - - - - handleChange(event)} - /> - - - - - % - - - - - - - handleChange(event)} - /> - - - - - % - - - - - - - handleChange(event)} - /> - - - - - °C - - - - - - - handleChange(event)} - /> - - - - - % - - - + handleChange(event)} + alertUnit="%" + /> + handleChange(event)} + alertUnit="%" + /> + handleChange(event)} + alertUnit="%" + /> + {/* handleChange(event)} + alertUnit="°C" + /> + handleChange(event)} + alertUnit="%" + /> + handleChange(event)} + alertUnit="%" + /> */} - + + + Logging retention + + Configure how logn logs are stored. After this period, the Uptime Manager + will start deleting oldest data. + + + {/* + handleChange(event)} + alertUnit="days" + /> + */} + Advanced settings @@ -459,6 +410,14 @@ const CreateInfrastructureMonitor = () => { onChange={(event) => handleChange(event, "interval")} items={frequencies} /> +