mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-20 08:39:43 -06:00
- WIP add memory and disk usage
This commit is contained in:
@@ -116,16 +116,18 @@ const CreateInfrastructureMonitor = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleBlur = (event) => {
|
||||
const handleBlur = (event, appenedID) => {
|
||||
event.preventDefault();
|
||||
const { value, id } = event.target;
|
||||
if (id?.startsWith("notify-email-")) return;
|
||||
const { error } = infrastractureMonitorValidation.validate(
|
||||
{ [id]: value },
|
||||
{ [id ?? appenedID]: value },
|
||||
{
|
||||
abortEarly: false,
|
||||
}
|
||||
);
|
||||
setErrors((prev) => {
|
||||
return buildErrors(prev, id, error);
|
||||
return buildErrors(prev, id ?? appenedID, error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -202,7 +204,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
if (hasValidationErrors(form, infrastractureMonitorValidation, setErrors)) {
|
||||
return;
|
||||
} else {
|
||||
const checkEndpointAction = await dispatch(
|
||||
const checkEndpointAction = dispatch(
|
||||
checkInfrastructureEndpointResolution({ authToken, monitorURL: form.url })
|
||||
);
|
||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||
@@ -212,7 +214,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
setErrors({ url: "The entered URL is not reachable." });
|
||||
return;
|
||||
}
|
||||
const action = await dispatch(
|
||||
const action = dispatch(
|
||||
createInfrastructureMonitor({ authToken, monitor: generatePayload(form) })
|
||||
);
|
||||
if (action.meta.requestStatus === "fulfilled") {
|
||||
@@ -372,7 +374,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
onBlur={handleBlur}
|
||||
alertUnit="%"
|
||||
/>
|
||||
{/* <CustomAlertStack
|
||||
<CustomAlertStack
|
||||
checkboxId="memory"
|
||||
checkboxLabel="Memory"
|
||||
checkboxValue={""}
|
||||
@@ -391,7 +393,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
alertUnit="%"
|
||||
/> */}
|
||||
/>
|
||||
{/* <CustomAlertStack
|
||||
checkboxId="customize-temperature"
|
||||
checkboxLabel="Temperature"
|
||||
@@ -448,7 +450,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
label="Check frequency"
|
||||
value={infrastructureMonitor.interval || 15}
|
||||
onChange={(e) => handleChange(e, "interval")}
|
||||
onBlur={handleBlur}
|
||||
onBlur={(e) => handleBlur(e, "interval")}
|
||||
items={frequencies}
|
||||
/>
|
||||
{/* <Field
|
||||
|
||||
@@ -22,14 +22,22 @@ const hasValidationErrors = (form, validation, setErrors) => {
|
||||
"dbConnectionString",
|
||||
"refreshTokenTTL",
|
||||
"jwtTTL",
|
||||
"notify-email-list",
|
||||
].includes(err.path[0])
|
||||
) {
|
||||
newErrors[err.path[0]] = err.message ?? "Validation error";
|
||||
}
|
||||
|
||||
// Handle conditionally usage number required cases
|
||||
if (!form.cpu || (form.cpu && form.usage_cpu)) {
|
||||
delete newErrors["usage_cpu"];
|
||||
}
|
||||
}
|
||||
if (!form.memory || (form.memory && form.usage_memory)) {
|
||||
delete newErrors["usage_memory"];
|
||||
}
|
||||
if (!form.disk || (form.disk && form.usage_disk)) {
|
||||
delete newErrors["usage_disk"];
|
||||
}
|
||||
});
|
||||
if (Object.keys(newErrors).length > 0) {
|
||||
setErrors(newErrors);
|
||||
|
||||
@@ -187,8 +187,16 @@ const infrastractureMonitorValidation = joi.object({
|
||||
"any.required": "CPU threshold is required.",
|
||||
}),
|
||||
cpu:joi.boolean(),
|
||||
// usage_memory: joi.number(),
|
||||
// usage_disk: joi.number(),
|
||||
memory:joi.boolean(),
|
||||
disk:joi.boolean(),
|
||||
usage_memory: joi.number().messages({
|
||||
"number.base": "Memory threshold must be a number.",
|
||||
"any.required": "Memory threshold is required.",
|
||||
}),
|
||||
usage_disk: joi.number().messages({
|
||||
"number.base": "Disk threshold must be a number.",
|
||||
"any.required": "Disk threshold is required.",
|
||||
}),
|
||||
// usage_temperature: joi.number().messages({
|
||||
// "number.base": "Temperature must be a number.",
|
||||
// }),
|
||||
|
||||
Reference in New Issue
Block a user