feat(notification): add option to convert metric units in request body (#147)

* feat(notification): add option to convert metric units in request body

* rename fields

* add prettierignore

* chore: auto-fix linting and formatting issues
This commit is contained in:
UUBulb
2026-01-10 17:27:13 +08:00
committed by GitHub
parent f5fd7c390c
commit b4221213a0
12 changed files with 44 additions and 11 deletions
+23
View File
@@ -57,6 +57,7 @@ const notificationFormSchema = z.object({
request_body: z.string(),
verify_tls: asOptionalField(z.boolean()),
skip_check: asOptionalField(z.boolean()),
format_metric_units: asOptionalField(z.boolean()),
})
export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
@@ -75,6 +76,7 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
request_body: data.request_body ?? "",
verify_tls: (data as any).verify_tls ?? false,
skip_check: (data as any).skip_check ?? false,
format_metric_units: (data as any).format_body ?? false,
}
: {
name: "",
@@ -85,6 +87,7 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
request_body: "",
verify_tls: false,
skip_check: false,
format_body: false,
},
resetOptions: {
keepDefaultValues: false,
@@ -283,6 +286,26 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
</FormItem>
)}
/>
<FormField
control={form.control}
name="format_metric_units"
render={({ field }) => (
<FormItem className="flex items-center space-x-2">
<FormControl>
<div className="flex items-center gap-2">
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
/>
<Label className="text-sm">
{t("FormatMetricUnits")}
</Label>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<DialogFooter className="justify-end">
<DialogClose asChild>
<Button type="button" className="my-2" variant="secondary">
+6 -2
View File
@@ -446,7 +446,9 @@ export const ServerCard: React.FC<ServerCardProps> = ({ data, mutate }) => {
{publicNoteObj.billingDataMod
?.startDate
? new Date(
publicNoteObj.billingDataMod!.startDate!,
publicNoteObj
.billingDataMod!
.startDate!,
).toLocaleDateString()
: "YYYY-MM-DD"}
</Button>
@@ -471,7 +473,9 @@ export const ServerCard: React.FC<ServerCardProps> = ({ data, mutate }) => {
.billingDataMod
?.startDate
? new Date(
publicNoteObj.billingDataMod!.startDate!,
publicNoteObj
.billingDataMod!
.startDate!,
)
: undefined
}
+1 -2
View File
@@ -23,8 +23,7 @@ const badgeVariants = cva(
)
export interface BadgeProps
extends HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
extends HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return <div className={cn(badgeVariants({ variant }), className)} {...props} />
+1 -2
View File
@@ -31,8 +31,7 @@ const buttonVariants = cva(
)
export interface ButtonProps
extends ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
extends ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
asChild?: boolean
}
+2 -1
View File
@@ -67,7 +67,8 @@ const multiSelectVariants = cva(
* Props for MultiSelect component
*/
interface MultiSelectProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
extends
React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof multiSelectVariants> {
/**
* An array of option objects to be displayed in the multi-select component.
+2 -1
View File
@@ -37,7 +37,8 @@ const sheetVariants = cva(
)
interface SheetContentProps
extends ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
extends
ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
VariantProps<typeof sheetVariants> {
setOpen: Dispatch<SetStateAction<boolean>>
}