feat: Implement drag-and-drop with position persistence for dashboard…#11
Merged
StuartF303 merged 1 commit intomainfrom Nov 9, 2025
Merged
Conversation
… overlays Fixes drag functionality and adds position persistence for tank and control overlays on the dashboard diagram. Index.razor (Frontend): - Replace broken HTML5 drag API with mouse event handlers - @onmousedown: Captures overlay and mouse position when drag starts - @OnMouseMove: Updates overlay position in real-time during drag - @onMouseUp: Saves position to backend when drag ends - Add ElementReference for diagram container to calculate dimensions - Add JSRuntime to get container dimensions for percentage calculations - Add LoadOverlayPositions method to fetch saved positions from API - Add SaveOverlayPosition method to persist positions to backend - Update CreateOverlaysFromTanks/Controls to use saved positions - Add savedPositions dictionary to cache positions locally - Add BoundingBox class for container dimension calculations - Add OverlayPositionDto class for API communication - Fix cursor changes (4-way arrow in edit mode) - Add user-select: none to prevent text selection during drag SettingsController.cs (Backend): - Add ConcurrentDictionary to store overlay positions in memory - Add GET /api/settings/overlay-positions endpoint - Returns all saved overlay positions - Add POST /api/settings/overlay-positions endpoint - Saves or updates overlay position - Logs position changes for debugging - Add DELETE /api/settings/overlay-positions/{id} endpoint - Removes saved position for overlay - Add OverlayPosition class - Id: Guid of tank or control - Type: "Tank" or "Control" - X, Y: Position as percentage (0-100) Drag Behavior: - Only works in edit mode (toggle lock/edit icon) - Smooth dragging with real-time position updates - Position constrained to 0-100% (stays within container) - Success notification when position saved - Positions persist across page reloads and app restarts - Each tank and control remembers its last saved position Technical Implementation: - Mouse events preferred over HTML5 drag API for better Blazor WASM support - Positions stored as percentages for responsive layout - In-memory storage (can be persisted to database later) - Delta-based position calculation for smooth movement - Container dimensions calculated via JavaScript interop Fixes: - Icons now drag smoothly when in edit mode - Cursor correctly shows 4-way arrow on hover in edit mode - Positions saved automatically on drag end - Saved positions loaded on page initialization - No more broken drag events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… overlays
Fixes drag functionality and adds position persistence for tank and control overlays on the dashboard diagram.
Index.razor (Frontend):
SettingsController.cs (Backend):
Drag Behavior:
Technical Implementation:
Fixes: