From df9e2dec281190f39cd6a28aa645f76f9adafffd Mon Sep 17 00:00:00 2001
From: Sven van Ginkel
Date: Sat, 2 Aug 2025 23:58:52 +0200
Subject: [PATCH] [Feature] Add custom meter percentages (#942)
---
.../components/routes/settings/general.tsx | 54 ++++++++++++++++++-
.../systems-table/systems-table.tsx | 43 +++++++++++++++
beszel/site/src/lib/stores.ts | 4 ++
beszel/site/src/types.d.ts | 4 ++
4 files changed, 103 insertions(+), 2 deletions(-)
diff --git a/beszel/site/src/components/routes/settings/general.tsx b/beszel/site/src/components/routes/settings/general.tsx
index 0ff3373b..753bb6f1 100644
--- a/beszel/site/src/components/routes/settings/general.tsx
+++ b/beszel/site/src/components/routes/settings/general.tsx
@@ -11,17 +11,30 @@ import { useState } from "react"
import languages from "@/lib/languages"
import { dynamicActivate } from "@/lib/i18n"
import { useLingui } from "@lingui/react/macro"
+import { Input } from "@/components/ui/input"
+// import { setLang } from "@/lib/i18n"
import { Unit } from "@/lib/enums"
export default function SettingsProfilePage({ userSettings }: { userSettings: UserSettings }) {
const [isLoading, setIsLoading] = useState(false)
const { i18n } = useLingui()
+ // Remove all per-metric threshold state and UI
+ // Only keep general yellow/red threshold state and UI
+ const [yellow, setYellow] = useState(userSettings.meterThresholds?.yellow ?? 65)
+ const [red, setRed] = useState(userSettings.meterThresholds?.red ?? 90)
+
+ function handleResetThresholds() {
+ setYellow(65)
+ setRed(90)
+ }
+
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
setIsLoading(true)
const formData = new FormData(e.target as HTMLFormElement)
const data = Object.fromEntries(formData) as Partial
+ data.meterThresholds = { yellow, red }
await saveSettings(data)
setIsLoading(false)
}
@@ -101,6 +114,45 @@ export default function SettingsProfilePage({ userSettings }: { userSettings: Us
+
+
+
+ Dashboard meter thresholds
+
+
+ Choose when the dashboard meters changes colors, based on percentage values.
+
+
+
+
+
+ setYellow(Number(e.target.value))}
+ />
+
+
+
+ setRed(Number(e.target.value))}
+ />
+
+
+
+
+
+ {/* Unit preferences section fixed and wrapped in a div */}
@@ -133,7 +185,6 @@ export default function SettingsProfilePage({ userSettings }: { userSettings: Us
-
-