Revert "feat: refine mobile dashboard experience"

This reverts commit 315520beca.
This commit is contained in:
ajnart committed 2026-07-29 20:07:17 +02:00
1 parent bbc560706a
commit 5c4cc81b05
114 files changed
+535 -2349

No files matched your search

@@ -1,6 +1,6 @@
"use client";
import { useCallback, useMemo, useState } from "react";
import { useCallback, useMemo } from "react";
import { Box, Button, Center, Loader, Menu, ScrollArea, Select, Stack, Text } from "@mantine/core";
import { IconQuestionMark, IconServer, IconServerOff } from "@tabler/icons-react";
@@ -15,20 +15,9 @@ import classes from "./component.module.css";
import type { WidgetComponentProps } from "../definition";
import type { BeszelTimePeriod } from "../beszel/_shared/chart";
import { BeszelIntegrationErrorIndicator } from "../beszel/_shared/error-indicator";
import { BeszelSystemsMobileSummary } from "../beszel/_shared/mobile-summary";
import { BeszelStatsView } from "../beszel/_shared/stats-view";
export default function BeszelSystemStatsWidget({ displayMode, ...props }: WidgetComponentProps<"beszelSystemStats">) {
const t = useScopedI18n("widget.beszelSystemStats");
if (displayMode === "mobileSummary") {
return <BeszelSystemsMobileSummary integrationIds={props.integrationIds} statusFilter="all" label={t("name")} />;
}
return <BeszelSystemStatsContent {...props} />;
}
function BeszelSystemStatsContent({
export default function BeszelSystemStatsWidget({
options,
integrationIds,
isEditMode,
@@ -36,7 +25,6 @@ function BeszelSystemStatsContent({
boardId,
itemId,
setOptions,
isReadOnly = false,
}: WidgetComponentProps<"beszelSystemStats">) {
const t = useScopedI18n("widget.beszelSystemStats");
const board = useOptionalBoard();
@@ -53,29 +41,18 @@ function BeszelSystemStatsContent({
() => systemsResult.flatMap((result) => result.systems.map((system) => ({ value: system.id, label: system.name }))),
[systemsResult],
);
const [temporarySystemId, setTemporarySystemId] = useState<string | null>(null);
const [temporaryTimePeriod, setTemporaryTimePeriod] = useState<BeszelTimePeriod | null>(null);
const configuredSystem = temporarySystemId ?? options.systemId;
const selectedSystem =
isReadOnly && !systems.some((system) => system.value === configuredSystem)
? (systems[0]?.value ?? "")
: configuredSystem || systems[0]?.value || "";
const selectedSystem = options.systemId || systems[0]?.value || "";
const selectedLabel = systems.find((system) => system.value === selectedSystem)?.label;
const systemExists = systems.some((system) => system.value === selectedSystem);
const handleSelectSystem = useCallback(
(value: string) => {
if (isReadOnly) {
setTemporarySystemId(value);
return;
}
setOptions({ newOptions: { systemId: value } });
if (hasChangeAccess && boardId && itemId) {
saveItemOptions({ boardId, itemId, newOptions: { systemId: value } });
}
},
[setOptions, isReadOnly, hasChangeAccess, boardId, itemId, saveItemOptions],
[setOptions, hasChangeAccess, boardId, itemId, saveItemOptions],
);
if (systemsError) throw systemsError;
@@ -163,7 +140,7 @@ function BeszelSystemStatsContent({
<BeszelStatsView
integrationIds={integrationIds}
systemId={selectedSystem}
timePeriod={temporaryTimePeriod ?? (options.timePeriod as BeszelTimePeriod)}
timePeriod={options.timePeriod as BeszelTimePeriod}
columns={width > 600 ? 2 : 1}
visibility={{
cpu: options.showCpu,
@@ -175,13 +152,7 @@ function BeszelSystemStatsContent({
dockerMemory: options.showDockerMemory,
dockerNetwork: options.showDockerNetwork,
}}
onSwitchToHistorical={() => {
if (isReadOnly) {
setTemporaryTimePeriod("1h");
return;
}
setOptions({ newOptions: { timePeriod: "1h" } });
}}
onSwitchToHistorical={() => setOptions({ newOptions: { timePeriod: "1h" } })}
/>
</Stack>
</ScrollArea>
@@ -16,13 +16,6 @@ const timePeriodOptions = [
export const { definition, componentLoader } = createWidgetDefinition("beszelSystemStats", {
icon: IconChartAreaLine,
mobile: {
width: 2,
height: 1,
supportsCompactSummary: true,
supportsDetailView: true,
unmountWhenOffscreen: true,
},
queryKey: [["widget", "beszel"]],
supportedIntegrations: ["beszel", "mock"],
integrationsRequired: true,