infra thresholds FE

This commit is contained in:
Alex Holliday committed 2025-12-07 03:34:33 +00:00
1 parent 7631e65cd2
commit 0453b790af
9 files changed
+191 -25

No files matched your search

@@ -37,8 +37,12 @@ const InfraConfigurePage = () => {
secret: data.secret,
name: data.name,
notificationChannels: data.notificationChannels,
thresholds: data.thresholds,
interval,
};
console.log(JSON.stringify(submitData, null, 2));
const result = await patch(`/monitors/${id}`, submitData);
if (result) {
navigate(`/infrastructure/${id}`);
@@ -1,22 +1,21 @@
import { InfraForm } from "@/pages/infrastructure/InfraForm";
import humanInterval from "human-interval";
import { useNavigate } from "react-router";
import { z } from "zod";
import { monitorSchemaInfra } from "@/validation/zod";
import { useGet, usePost } from "@/hooks/UseApi";
import type { ApiResponse } from "@/hooks/UseApi";
import { useNavigate } from "react-router";
import type { INotificationChannel } from "@/types/notification-channel";
const InfraCreatePage = () => {
type FormValues = z.infer<typeof monitorSchemaInfra>;
type SubmitValues = Omit<FormValues, "interval"> & {
interval: number | undefined;
};
const navigate = useNavigate();
const { response } = useGet<ApiResponse<INotificationChannel[]>>(
"/notification-channels"
);
const { post, loading, error } = usePost<SubmitValues, any>();
const navigate = useNavigate();
const onSubmit = async (data: FormValues) => {
let interval = humanInterval(data.interval);
+67 -1
View File
@@ -190,7 +190,9 @@ export const InfraForm = ({
<TextInput
{...field}
type="number"
fieldLabel={t("createMonitorPage.incidentConfigStatusCheckNumber")}
fieldLabel={t(
"createMonitorPage.incidentConfigStatusCheckNumber"
)}
fullWidth
error={!!errors.n}
helperText={errors.n ? errors.n.message : ""}
@@ -203,6 +205,70 @@ export const InfraForm = ({
/>
}
/>
<ConfigBox
title={t("Threshold Alerts")}
subtitle={t("Set percentage thresholds to trigger incidents.")}
rightContent={
<Stack gap={theme.spacing(4)}>
<Controller
name="thresholds.cpu"
control={control}
render={({ field }) => (
<TextInput
{...field}
type="number"
fieldLabel={t("CPU %")}
fullWidth
error={!!errors.thresholds?.cpu}
helperText={errors.thresholds?.cpu?.message ?? ""}
/>
)}
/>
<Controller
name="thresholds.memory"
control={control}
render={({ field }) => (
<TextInput
{...field}
type="number"
fieldLabel={t("Memory %")}
fullWidth
error={!!errors.thresholds?.memory}
helperText={errors.thresholds?.memory?.message ?? ""}
/>
)}
/>
<Controller
name="thresholds.disk"
control={control}
render={({ field }) => (
<TextInput
{...field}
type="number"
fieldLabel={t("Disk %")}
fullWidth
error={!!errors.thresholds?.disk}
helperText={errors.thresholds?.disk?.message ?? ""}
/>
)}
/>
<Controller
name="thresholds.temperature"
control={control}
render={({ field }) => (
<TextInput
{...field}
type="number"
fieldLabel={t("Temperature °C")}
fullWidth
error={!!errors.thresholds?.temperature}
helperText={errors.thresholds?.temperature?.message ?? ""}
/>
)}
/>
</Stack>
}
/>
<ConfigBox
title={t("notificationConfig.title")}
subtitle={t("notificationConfig.description")}