fix(beszel): restore timePeriod cast and improve error visibility
- Restore timePeriod union cast to fix typecheck (TS2769) - Clear live data on subscription error so error UI always shows - Emit error when no integration is configured for live subscription - Add error state to system select input when query fails
This commit is contained in:
5 files changed
+11
-4
No files matched your search
@@ -162,7 +162,10 @@ export const beszelRouter = createTRPCRouter({
|
||||
containerStats: BeszelContainerStatsRecord | null;
|
||||
}>((emit) => {
|
||||
const integration = ctx.integrations[0];
|
||||
if (!integration) return () => {};
|
||||
if (!integration) {
|
||||
emit.error(new Error("No Beszel integration configured"));
|
||||
return () => {};
|
||||
}
|
||||
|
||||
const abortController = new AbortController();
|
||||
|
||||
|
||||
@@ -3669,7 +3669,8 @@
|
||||
"configureIntegrationFirst": "Configure a Beszel integration first",
|
||||
"loading": "Loading systems...",
|
||||
"placeholder": "Select a system",
|
||||
"noSystems": "No systems found"
|
||||
"noSystems": "No systems found",
|
||||
"loadError": "Failed to load systems"
|
||||
},
|
||||
"timePeriod": {
|
||||
"label": "Time period"
|
||||
|
||||
@@ -16,7 +16,7 @@ export const WidgetBeszelSystemInput = ({ property, kind }: CommonWidgetInputPro
|
||||
|
||||
const integrationIds = form.values.integrationIds;
|
||||
|
||||
const { data: systemsResult = [], isPending } = clientApi.widget.beszel.getSystems.useQuery(
|
||||
const { data: systemsResult = [], isPending, isError } = clientApi.widget.beszel.getSystems.useQuery(
|
||||
{ integrationIds },
|
||||
{ enabled: integrationIds.length > 0, staleTime: 30_000 },
|
||||
);
|
||||
@@ -40,6 +40,8 @@ export const WidgetBeszelSystemInput = ({ property, kind }: CommonWidgetInputPro
|
||||
searchable
|
||||
nothingFoundMessage={t("noSystems")}
|
||||
data={systems}
|
||||
disabled={isError}
|
||||
error={isError ? t("loadError") : undefined}
|
||||
{...form.getInputProps(`options.${property}`)}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -71,7 +71,7 @@ export default function BeszelSystemStatsWidget({
|
||||
{
|
||||
integrationIds,
|
||||
systemId: selectedSystem,
|
||||
timePeriod: options.timePeriod,
|
||||
timePeriod: options.timePeriod as "1m" | "1h" | "12h" | "24h" | "1w" | "30d",
|
||||
includeDocker: showDocker,
|
||||
},
|
||||
{ staleTime: 30 * 1000, enabled: !isLive && systemReady && selectedSystem !== "" },
|
||||
|
||||
@@ -37,6 +37,7 @@ export const useLiveStats = (integrationIds: string[], systemId: string, enabled
|
||||
);
|
||||
|
||||
const onError = useCallback((err: unknown) => {
|
||||
setData(null);
|
||||
setError(err instanceof Error ? err : new Error(String(err)));
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in new issue
Block a user