infra thresholds FE
This commit is contained in:
1 parent
7631e65cd2
commit
0453b790af
9 files changed
+191
-25
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { BasePage, InfoBox, PlanCard } from "@/components/design-elements";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import Box from "@mui/material/Box";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { Button } from "@/components/inputs";
|
||||
|
||||
import { useAppDispatch, useAppSelector } from "@/hooks/AppHooks";
|
||||
@@ -27,7 +26,6 @@ const BillingPage = () => {
|
||||
const { post, loading: isPosting } = usePost();
|
||||
const plans = response?.data ?? [];
|
||||
|
||||
const theme = useTheme();
|
||||
const selectedPlan = user?.entitlements?.plan || null;
|
||||
const dispatch = useAppDispatch();
|
||||
const selectedTeamId = useAppSelector((s) => s.auth.selectedTeamId);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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")}
|
||||
|
||||
Reference in new issue
Block a user