FE UI, userService type fix
This commit is contained in:
1 parent
b1147b8bf9
commit
77af9d2e93
5 files changed
+69
-6
No files matched your search
@@ -11,20 +11,26 @@ import type { ResponsiveStyleValue } from "@mui/system";
|
|||||||
interface SliderInputProps extends SliderProps {
|
interface SliderInputProps extends SliderProps {
|
||||||
sx?: SliderProps["sx"];
|
sx?: SliderProps["sx"];
|
||||||
showValue?: boolean;
|
showValue?: boolean;
|
||||||
|
formatDisplayValue?: (value: number) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SliderInput = forwardRef<HTMLSpanElement, SliderInputProps>(
|
export const SliderInput = forwardRef<HTMLSpanElement, SliderInputProps>(
|
||||||
({ sx, showValue = false, ...props }, ref) => {
|
({ sx, showValue = false, formatDisplayValue, ...props }, ref) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const additionalSx = Array.isArray(sx) ? sx : sx ? [sx] : [];
|
const additionalSx = Array.isArray(sx) ? sx : sx ? [sx] : [];
|
||||||
|
|
||||||
|
const displayValue =
|
||||||
|
showValue && formatDisplayValue && typeof props.value === "number"
|
||||||
|
? formatDisplayValue(props.value)
|
||||||
|
: props.value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gap={theme.spacing(8)}
|
gap={theme.spacing(8)}
|
||||||
direction={"row"}
|
direction={"row"}
|
||||||
alignItems={"center"}
|
alignItems={"center"}
|
||||||
>
|
>
|
||||||
{showValue && <Typography>{props.value}</Typography>}
|
{showValue && <Typography>{displayValue}</Typography>}
|
||||||
<Slider
|
<Slider
|
||||||
{...props}
|
{...props}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@@ -63,12 +69,21 @@ interface SliderWithLabelProps extends SliderProps {
|
|||||||
fieldLabel?: string;
|
fieldLabel?: string;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
showValue?: boolean;
|
showValue?: boolean;
|
||||||
|
formatDisplayValue?: (value: number) => string;
|
||||||
sliderMaxWidth?: ResponsiveStyleValue<number | string>;
|
sliderMaxWidth?: ResponsiveStyleValue<number | string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SliderWithLabel = forwardRef<HTMLSpanElement, SliderWithLabelProps>(
|
export const SliderWithLabel = forwardRef<HTMLSpanElement, SliderWithLabelProps>(
|
||||||
(
|
(
|
||||||
{ fieldLabel, required, showValue = true, value, sliderMaxWidth = "100%", ...props },
|
{
|
||||||
|
fieldLabel,
|
||||||
|
required,
|
||||||
|
showValue = true,
|
||||||
|
formatDisplayValue,
|
||||||
|
value,
|
||||||
|
sliderMaxWidth = "100%",
|
||||||
|
...props
|
||||||
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -82,6 +97,7 @@ export const SliderWithLabel = forwardRef<HTMLSpanElement, SliderWithLabelProps>
|
|||||||
<SliderInput
|
<SliderInput
|
||||||
{...props}
|
{...props}
|
||||||
showValue={showValue}
|
showValue={showValue}
|
||||||
|
formatDisplayValue={formatDisplayValue}
|
||||||
value={value}
|
value={value}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -462,6 +462,43 @@ export const SettingsPage = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Check Retention */}
|
||||||
|
{isAdmin && (
|
||||||
|
<ConfigBox
|
||||||
|
title={t("pages.settings.form.retention.title")}
|
||||||
|
subtitle={t("pages.settings.form.retention.description")}
|
||||||
|
rightContent={
|
||||||
|
<Controller
|
||||||
|
name="checkTTL"
|
||||||
|
control={form.control}
|
||||||
|
defaultValue={defaults.checkTTL}
|
||||||
|
render={({ field }) => (
|
||||||
|
<SliderWithLabel
|
||||||
|
{...field}
|
||||||
|
fieldLabel={t("pages.settings.form.retention.option.days.label")}
|
||||||
|
min={1}
|
||||||
|
max={366}
|
||||||
|
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
||||||
|
value={field.value || 30}
|
||||||
|
onChange={(_, value) => 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 */}
|
{/* Global Thresholds */}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const settingsSchema = z.object({
|
|||||||
systemEmailSecure: z.boolean().optional(),
|
systemEmailSecure: z.boolean().optional(),
|
||||||
systemEmailPool: z.boolean().optional(),
|
systemEmailPool: z.boolean().optional(),
|
||||||
showURL: z.boolean().optional(),
|
showURL: z.boolean().optional(),
|
||||||
checkTTL: z.number().int().min(1, "Please enter a value").max(365, "Maximum 365 days"),
|
checkTTL: z.number().int().min(1, "Please enter a value").max(366, "Maximum 366"),
|
||||||
pagespeedApiKey: z
|
pagespeedApiKey: z
|
||||||
.string()
|
.string()
|
||||||
.transform((val) => (val.trim() === "" ? undefined : val.trim()))
|
.transform((val) => (val.trim() === "" ? undefined : val.trim()))
|
||||||
|
|||||||
@@ -1041,7 +1041,7 @@
|
|||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"title": "Monitor history",
|
"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": {
|
"option": {
|
||||||
"clear": {
|
"clear": {
|
||||||
"label": "Clear all stats. This is irreversible."
|
"label": "Clear all stats. This is irreversible."
|
||||||
@@ -1052,6 +1052,16 @@
|
|||||||
"description": "This cannot be undone"
|
"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": {
|
"thresholds": {
|
||||||
"title": "Global Thresholds",
|
"title": "Global Thresholds",
|
||||||
"description": "Set global CPU, Memory, Disk, and Temperature thresholds for infrastructure monitoring. These apply to all hardware monitors unless overridden.",
|
"description": "Set global CPU, Memory, Disk, and Temperature thresholds for infrastructure monitoring. These apply to all hardware monitors unless overridden.",
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ export class UserService implements IUserService {
|
|||||||
if (res && res.length > 0) {
|
if (res && res.length > 0) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
res.map(async (monitor) => {
|
res.map(async (monitor) => {
|
||||||
await this.jobQueue.deleteJob(monitor.id);
|
await this.jobQueue.deleteJob(monitor);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user