Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

refactor(beszel): deduplicate alerts query input and document systemId option

Thomas Camlongd6ced037df77
diff --git a/apps/docs/docs/widgets/beszel-system-stats/index.ts b/apps/docs/docs/widgets/beszel-system-stats/index.ts
index f320a7ea9..4a9e06c79 100644
--- a/apps/docs/docs/widgets/beszel-system-stats/index.ts
+++ b/apps/docs/docs/widgets/beszel-system-stats/index.ts
@@ -8,6 +8,12 @@ export const beszelSystemStatsWidget: WidgetDefinition = {
path: "../../widgets/beszel-system-stats",
configuration: {
items: [
+ {
+ name: "System",
+ description: "The Beszel system to display stats for. Searchable select populated from the integration.",
+ values: { type: "text" },
+ defaultValue: "First available system",
+ },
{
name: "Time period",
description:
diff --git a/packages/widgets/src/beszel-alerts/component.tsx b/packages/widgets/src/beszel-alerts/component.tsx
index 76ef5318e..331028770 100644
--- a/packages/widgets/src/beszel-alerts/component.tsx
+++ b/packages/widgets/src/beszel-alerts/component.tsx
@@ -36,31 +36,21 @@ export default function BeszelAlertsWidget({
isEditMode,
}: WidgetComponentProps<"beszelAlerts">) {
const t = useScopedI18n("widget.beszelAlerts");
- const { data: results = [] } = clientApi.widget.beszel.getAlerts.useQuery(
- {
- integrationIds,
- includeHistory: options.showHistory,
- maxHistoryItems: options.maxHistoryItems,
- },
- { staleTime: 15_000, refetchInterval: 15_000, retry: false },
+ const alertsInput = useMemo(
+ () => ({ integrationIds, includeHistory: options.showHistory, maxHistoryItems: options.maxHistoryItems }),
+ [integrationIds, options.showHistory, options.maxHistoryItems],
);
+ const { data: results = [] } = clientApi.widget.beszel.getAlerts.useQuery(alertsInput, {
+ staleTime: 15_000,
+ refetchInterval: 15_000,
+ retry: false,
+ });
const utils = clientApi.useUtils();
- clientApi.widget.beszel.subscribeAlerts.useSubscription(
- {
- integrationIds,
- includeHistory: options.showHistory,
- maxHistoryItems: options.maxHistoryItems,
- },
- {
- enabled: !isEditMode,
- onData(data) {
- utils.widget.beszel.getAlerts.setData(
- {
- integrationIds,
- includeHistory: options.showHistory,
- maxHistoryItems: options.maxHistoryItems,
- },
+ clientApi.widget.beszel.subscribeAlerts.useSubscription(alertsInput, {
+ enabled: !isEditMode,
+ onData(data) {
+ utils.widget.beszel.getAlerts.setData(alertsInput,
(prev) => {
if (!prev) return prev;
return prev.map((r) =>