From 89429c70cf87280df911dcba43040d4c92561736 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 21 Sep 2026 09:46:53 +0000 Subject: [PATCH] Tag --- frontend/src/views/DashboardPage.tsx | 24 +++++++++++++----------- frontend/src/views/LoginPage.tsx | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/frontend/src/views/DashboardPage.tsx b/frontend/src/views/DashboardPage.tsx index 14a00e3..85556bc 100644 --- a/frontend/src/views/DashboardPage.tsx +++ b/frontend/src/views/DashboardPage.tsx @@ -99,6 +99,8 @@ type DashboardNote = { const dashboardPreferenceVersion = 3; const rowHeight = 48; const gridColumns = 12; +const maxWidgetHeight = 40; +const maxWidgetY = 120; const widgetDefinitions: WidgetDefinition[] = [ { type: "dayControl", title: "Tagessteuerung", defaultSize: { w: 6, h: 5 }, minSize: { w: 4, h: 4 }, fixed: true }, @@ -278,9 +280,9 @@ function normalizePreference(preference: Partial): Dashboar type: widget.type, title: typeof widget.title === "string" ? widget.title : widgetTitle(widget.type), x: clampNumber(widget.x, 0, gridColumns - 1), - y: clampNumber(widget.y, 0, 30), + y: clampNumber(widget.y, 0, maxWidgetY), w: clampNumber(widget.w, widgetMinSize(widget.type).w, gridColumns), - h: clampNumber(widget.h, widgetMinSize(widget.type).h, 8), + h: clampNumber(widget.h, widgetMinSize(widget.type).h, maxWidgetHeight), config: normalizeWidgetConfig(widget.type, widget.config) })) .reduce((placed, widget) => [...placed, resolveWidgetPlacement(placed, widget)], []); @@ -332,14 +334,14 @@ function columnsOverlap(left: DashboardWidget, right: DashboardWidget) { function normalizeWidgetPlacement(changed: DashboardWidget) { const minSize = widgetMinSize(changed.type); const w = clampNumber(changed.w, minSize.w, gridColumns); - const h = clampNumber(changed.h, minSize.h, 8); + const h = clampNumber(changed.h, minSize.h, maxWidgetHeight); return { ...changed, w, h, x: clampNumber(changed.x, 0, gridColumns - w), - y: clampNumber(changed.y, 0, 80) + y: clampNumber(changed.y, 0, maxWidgetY) }; } @@ -352,7 +354,7 @@ function resolveWidgetPlacement(widgets: DashboardWidget[], changed: DashboardWi return next; } - const maxExistingRow = Math.max(80, ...widgets.filter((widget) => widget.id !== next.id).map((widget) => widget.y + widget.h + next.h)); + const maxExistingRow = Math.max(maxWidgetY, ...widgets.filter((widget) => widget.id !== next.id).map((widget) => widget.y + widget.h + next.h)); for (let distance = 1; distance <= maxExistingRow + next.h; distance += 1) { const yAbove = next.y - distance; @@ -367,7 +369,7 @@ function resolveWidgetPlacement(widgets: DashboardWidget[], changed: DashboardWi } } - return { ...next, y: maxExistingRow + h }; + return { ...next, y: maxExistingRow + next.h }; } function moveCollidingWidgetsDown(widgets: DashboardWidget[], lockedWidgetId: string) { @@ -462,7 +464,7 @@ function placeWidget(widgets: DashboardWidget[], changed: DashboardWidget) { return layoutWidgetsWithPlacement(widgets, changed); } -function widgetPlacementFromPoint(gridElement: HTMLDivElement, widgets: DashboardWidget[], widget: DashboardWidget, clientX: number, clientY: number) { +function widgetPlacementFromPoint(gridElement: HTMLDivElement, widget: DashboardWidget, clientX: number, clientY: number) { const rect = gridElement.getBoundingClientRect(); const styles = window.getComputedStyle(gridElement); const columnGap = Number.parseFloat(styles.columnGap) || 0; @@ -473,7 +475,7 @@ function widgetPlacementFromPoint(gridElement: HTMLDivElement, widgets: Dashboar return normalizeWidgetPlacement({ ...widget, x: clampNumber(Math.floor((clientX - rect.left) / columnStep), 0, gridColumns - widget.w), - y: clampNumber(Math.floor((clientY - rect.top) / rowStep), 0, 80) + y: clampNumber(Math.floor((clientY - rect.top) / rowStep), 0, maxWidgetY) }); } @@ -1122,7 +1124,7 @@ export function DashboardPage({ onNavigate }: DashboardPageProps) { const next = dragPreview?.id === widget.id ? dragPreview - : widgetPlacementFromPoint(gridRef.current, preference.widgets, widget, clientX, clientY); + : widgetPlacementFromPoint(gridRef.current, widget, clientX, clientY); setPreference((current) => ({ ...current, @@ -1143,7 +1145,7 @@ export function DashboardPage({ onNavigate }: DashboardPageProps) { return; } - setDragPreview(widgetPlacementFromPoint(gridRef.current, preference.widgets, widget, clientX, clientY)); + setDragPreview(widgetPlacementFromPoint(gridRef.current, widget, clientX, clientY)); } function startResize(event: PointerEvent, widget: DashboardWidget) { @@ -1161,7 +1163,7 @@ export function DashboardPage({ onNavigate }: DashboardPageProps) { function onMove(moveEvent: globalThis.PointerEvent) { updateWidget(widget.id, { w: clampNumber(startW + Math.round((moveEvent.clientX - startX) / columnWidth), minSize.w, gridColumns - widget.x), - h: clampNumber(startH + Math.round((moveEvent.clientY - startY) / rowHeight), minSize.h, 8) + h: clampNumber(startH + Math.round((moveEvent.clientY - startY) / rowHeight), minSize.h, maxWidgetHeight) }); } diff --git a/frontend/src/views/LoginPage.tsx b/frontend/src/views/LoginPage.tsx index 2def6c0..858adec 100644 --- a/frontend/src/views/LoginPage.tsx +++ b/frontend/src/views/LoginPage.tsx @@ -21,7 +21,7 @@ export function LoginPage({ onLogin }: LoginPageProps) { setLoading(true); try { - const result = await login({ username, password }); + const result = await login({ username: username.trim(), password }); onLogin(result.user); } catch (error) { toast.error("Login fehlgeschlagen", {