diff --git a/client/src/Components/inputs/Slider.tsx b/client/src/Components/inputs/Slider.tsx index 83037ab54..a17fc8a10 100644 --- a/client/src/Components/inputs/Slider.tsx +++ b/client/src/Components/inputs/Slider.tsx @@ -11,20 +11,26 @@ import type { ResponsiveStyleValue } from "@mui/system"; interface SliderInputProps extends SliderProps { sx?: SliderProps["sx"]; showValue?: boolean; + formatDisplayValue?: (value: number) => string; } export const SliderInput = forwardRef( - ({ sx, showValue = false, ...props }, ref) => { + ({ sx, showValue = false, formatDisplayValue, ...props }, ref) => { const theme = useTheme(); const additionalSx = Array.isArray(sx) ? sx : sx ? [sx] : []; + const displayValue = + showValue && formatDisplayValue && typeof props.value === "number" + ? formatDisplayValue(props.value) + : props.value; + return ( - {showValue && {props.value}} + {showValue && {displayValue}} string; sliderMaxWidth?: ResponsiveStyleValue; } export const SliderWithLabel = forwardRef( ( - { fieldLabel, required, showValue = true, value, sliderMaxWidth = "100%", ...props }, + { + fieldLabel, + required, + showValue = true, + formatDisplayValue, + value, + sliderMaxWidth = "100%", + ...props + }, ref ) => { const theme = useTheme(); @@ -82,6 +97,7 @@ export const SliderWithLabel = forwardRef diff --git a/client/src/Pages/Settings/index.tsx b/client/src/Pages/Settings/index.tsx index 44fb4a42f..e96fc4837 100644 --- a/client/src/Pages/Settings/index.tsx +++ b/client/src/Pages/Settings/index.tsx @@ -462,6 +462,43 @@ export const SettingsPage = () => { /> )} + {/* Check Retention */} + {isAdmin && ( + ( + field.onChange(value)} + valueLabelDisplay="auto" + valueLabelFormat={(value: number) => + value >= 366 + ? t("pages.settings.form.retention.option.days.unlimited") + : `${value}` + } + formatDisplayValue={(value: number) => + value >= 366 + ? t("pages.settings.form.retention.option.days.unlimited") + : `${value}` + } + /> + )} + /> + } + /> + )} + {/* Global Thresholds */} {isAdmin && ( (val.trim() === "" ? undefined : val.trim())) diff --git a/client/src/locales/en.json b/client/src/locales/en.json index 5f582cac5..4c4965aec 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -1041,7 +1041,7 @@ }, "stats": { "title": "Monitor history", - "description": "Define how long you want to retain historical data. You can also clear all existing data.", + "description": "Clear all monitoring history and statistics for your team. This action is irreversible.", "option": { "clear": { "label": "Clear all stats. This is irreversible." @@ -1052,6 +1052,16 @@ "description": "This cannot be undone" } }, + "retention": { + "title": "Check retention", + "description": "Set how long check data is retained before being automatically cleaned up.", + "option": { + "days": { + "label": "Retention period (days)", + "unlimited": "Unlimited" + } + } + }, "thresholds": { "title": "Global Thresholds", "description": "Set global CPU, Memory, Disk, and Temperature thresholds for infrastructure monitoring. These apply to all hardware monitors unless overridden.", diff --git a/server/src/service/business/userService.ts b/server/src/service/business/userService.ts index f224e9ba4..3337e491d 100644 --- a/server/src/service/business/userService.ts +++ b/server/src/service/business/userService.ts @@ -349,7 +349,7 @@ export class UserService implements IUserService { if (res && res.length > 0) { await Promise.all( res.map(async (monitor) => { - await this.jobQueue.deleteJob(monitor.id); + await this.jobQueue.deleteJob(monitor); }) ); }