global threshold slider fix
This commit is contained in:
1 parent
85edea713a
commit
dede689990
4 files changed
+48
-5
No files matched your search
@@ -6,3 +6,4 @@ mongo
|
|||||||
node_modules/
|
node_modules/
|
||||||
docs/architecture
|
docs/architecture
|
||||||
docs/reviews
|
docs/reviews
|
||||||
|
docs/todo
|
||||||
@@ -1,6 +1,13 @@
|
|||||||
import { BasePage, ConfigBox, TextLink } from "@/Components/design-elements";
|
import { BasePage, ConfigBox, TextLink } from "@/Components/design-elements";
|
||||||
import { Autocomplete, Select, Dialog, SwitchComponent } from "@/Components/inputs";
|
import { Autocomplete, Select, Dialog, SwitchComponent } from "@/Components/inputs";
|
||||||
import { Stack, useTheme, MenuItem, Link, type SelectChangeEvent } from "@mui/material";
|
import {
|
||||||
|
Stack,
|
||||||
|
useTheme,
|
||||||
|
MenuItem,
|
||||||
|
Link,
|
||||||
|
Alert,
|
||||||
|
type SelectChangeEvent,
|
||||||
|
} from "@mui/material";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
@@ -257,8 +264,7 @@ export const SettingsPage = () => {
|
|||||||
(acc as any)[typedKey] = Object.entries(value).reduce(
|
(acc as any)[typedKey] = Object.entries(value).reduce(
|
||||||
(nested, [nestedKey, nestedValue]) => ({
|
(nested, [nestedKey, nestedValue]) => ({
|
||||||
...nested,
|
...nested,
|
||||||
[nestedKey]:
|
[nestedKey]: nestedValue === undefined ? "" : nestedValue,
|
||||||
nestedValue === undefined || nestedValue === 0 ? "" : nestedValue,
|
|
||||||
}),
|
}),
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
@@ -523,7 +529,7 @@ export const SettingsPage = () => {
|
|||||||
"pages.settings.form.thresholds.option.temperature.label"
|
"pages.settings.form.thresholds.option.temperature.label"
|
||||||
)}
|
)}
|
||||||
min={1}
|
min={1}
|
||||||
max={100}
|
max={150}
|
||||||
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
||||||
value={field.value || 1}
|
value={field.value || 1}
|
||||||
onChange={(_, value) => field.onChange(value)}
|
onChange={(_, value) => field.onChange(value)}
|
||||||
@@ -965,6 +971,39 @@ export const SettingsPage = () => {
|
|||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* Validation Error Display */}
|
||||||
|
{Object.keys(form.formState.errors).length > 0 && (
|
||||||
|
<Alert
|
||||||
|
severity="error"
|
||||||
|
sx={{ mb: 2, flexGrow: 1, mr: 2 }}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ fontWeight: 600, mb: 1 }}
|
||||||
|
>
|
||||||
|
{t("pages.settings.form.validation.errorMessage")}
|
||||||
|
</Typography>
|
||||||
|
<Box
|
||||||
|
component="ul"
|
||||||
|
sx={{ m: 0, pl: 2 }}
|
||||||
|
>
|
||||||
|
{Object.entries(form.formState.errors).map(([field, error]) => {
|
||||||
|
const message =
|
||||||
|
typeof error === "object" && error?.message
|
||||||
|
? error.message
|
||||||
|
: "Invalid value";
|
||||||
|
return (
|
||||||
|
<li key={field}>
|
||||||
|
<Typography variant="body2">
|
||||||
|
<strong>{field}:</strong> {message}
|
||||||
|
</Typography>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
loading={isSaving}
|
loading={isSaving}
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const settingsSchema = z.object({
|
|||||||
cpu: z.number().int().min(1).max(100),
|
cpu: z.number().int().min(1).max(100),
|
||||||
memory: z.number().int().min(1).max(100),
|
memory: z.number().int().min(1).max(100),
|
||||||
disk: z.number().int().min(1).max(100),
|
disk: z.number().int().min(1).max(100),
|
||||||
temperature: z.number().int().min(1).max(100),
|
temperature: z.number().int().min(1).max(150),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1127,6 +1127,9 @@
|
|||||||
"about": {
|
"about": {
|
||||||
"title": "About",
|
"title": "About",
|
||||||
"developedBy": "Developed by Bluewave Labs"
|
"developedBy": "Developed by Bluewave Labs"
|
||||||
|
},
|
||||||
|
"validation": {
|
||||||
|
"errorMessage": "Please fix the following validation errors:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user