add global thresholds configbox

This commit is contained in:
Alex Holliday
2026-02-19 17:33:28 +00:00
parent a3a25b2add
commit 216c7753b4
2 changed files with 106 additions and 1 deletions
+84 -1
View File
@@ -327,11 +327,93 @@ export const SettingsPage = () => {
color="error"
onClick={() => setIsStatsDialogOpen(true)}
>
{t("common.buttons.clear")}
{t("pages.settings.form.stats.buttonText")}
</Button>
}
/>
)}
{/* Global Thresholds */}
{isAdmin && (
<ConfigBox
title={t("pages.settings.form.thresholds.title")}
subtitle={t("pages.settings.form.thresholds.description")}
rightContent={
<Stack spacing={2}>
<Controller
name="globalThresholds.cpu"
control={form.control}
defaultValue={defaults.globalThresholds?.cpu}
render={({ field, fieldState }) => (
<TextField
{...field}
fieldLabel={t("pages.settings.form.thresholds.option.cpu.label")}
type="number"
placeholder={t(
"pages.settings.form.thresholds.option.cpu.placeholder"
)}
error={!!fieldState.error}
helperText={fieldState.error?.message}
/>
)}
/>
<Controller
name="globalThresholds.memory"
control={form.control}
defaultValue={defaults.globalThresholds?.memory}
render={({ field, fieldState }) => (
<TextField
{...field}
fieldLabel={t("pages.settings.form.thresholds.option.memory.label")}
type="number"
placeholder={t(
"pages.settings.form.thresholds.option.memory.placeholder"
)}
error={!!fieldState.error}
helperText={fieldState.error?.message}
/>
)}
/>
<Controller
name="globalThresholds.disk"
control={form.control}
defaultValue={defaults.globalThresholds?.disk}
render={({ field, fieldState }) => (
<TextField
{...field}
fieldLabel={t("pages.settings.form.thresholds.option.disk.label")}
type="number"
placeholder={t(
"pages.settings.form.thresholds.option.disk.placeholder"
)}
error={!!fieldState.error}
helperText={fieldState.error?.message}
/>
)}
/>
<Controller
name="globalThresholds.temperature"
control={form.control}
defaultValue={defaults.globalThresholds?.temperature}
render={({ field, fieldState }) => (
<TextField
{...field}
fieldLabel={t(
"pages.settings.form.thresholds.option.temperature.label"
)}
type="number"
placeholder={t(
"pages.settings.form.thresholds.option.temperature.placeholder"
)}
error={!!fieldState.error}
helperText={fieldState.error?.message}
/>
)}
/>
</Stack>
}
/>
)}
</Stack>
{/* Clear Stats Confirmation Dialog */}
@@ -370,6 +452,7 @@ export const SettingsPage = () => {
{t("common.buttons.save")}
</Button>
</Stack>
<pre>{JSON.stringify(form.formState.isValid, null, 2)}</pre>
</BasePage>
);
};
+22
View File
@@ -994,6 +994,28 @@
"title": "Clear all monitoring history?",
"description": "This cannot be undone"
}
},
"thresholds": {
"title": "Global Thresholds",
"description": "Set global CPU, Memory, Disk, and Temperature thresholds for infrastructure monitoring. These apply to all hardware monitors unless overridden.",
"option": {
"cpu": {
"label": "CPU Threshold (%)",
"placeholder": "0 - 100"
},
"memory": {
"label": "Memory Threshold (%)",
"placeholder": "0 - 100"
},
"disk": {
"label": "Disk Threshold (%)",
"placeholder": "0 - 100"
},
"temperature": {
"label": "Temperature Threshold (°C)",
"placeholder": "0 - 150"
}
}
}
}
},