diff --git a/src/routes/(app)/settings/+page.svelte b/src/routes/(app)/settings/+page.svelte index de7ae8d..173578d 100644 --- a/src/routes/(app)/settings/+page.svelte +++ b/src/routes/(app)/settings/+page.svelte @@ -3,20 +3,223 @@ import Button from "$lib/components/ui/button/button.svelte"; import Input from "$lib/components/ui/input/input.svelte"; import Label from "$lib/components/ui/label/label.svelte"; + import Card from "$lib/components/ui/card/card.svelte"; + import CardContent from "$lib/components/ui/card/card-content.svelte"; + import CardDescription from "$lib/components/ui/card/card-description.svelte"; + import CardHeader from "$lib/components/ui/card/card-header.svelte"; + import CardTitle from "$lib/components/ui/card/card-title.svelte"; + import { Thermometer, Droplets, Gauge, Mountain, Upload, Cpu } from "@lucide/svelte"; const { form } = $props(); + + let floorPlanImage = $state(null); + let availableDevices = $state([ + { id: "esp8266-1", name: "ESP8266 #1", type: "esp8266", status: "online" }, + { id: "esp8266-2", name: "ESP8266 #2", type: "esp8266", status: "online" }, + { id: "esp8266-3", name: "ESP8266 #3", type: "esp8266", status: "offline" }, + { id: "esp8266-4", name: "ESP8266 #4", type: "esp8266", status: "online" }, + ]); + + let placedDevices = $state([]); + let draggedDevice = $state(null); + let floorPlanRef = $state(null); + + function handleFileUpload(event) { + const file = event.target.files?.[0]; + if (file && file.type.startsWith("image/")) { + const reader = new FileReader(); + reader.onload = (e) => { + floorPlanImage = e.target.result; + }; + reader.readAsDataURL(file); + } + } + + function handleDragStart(device) { + draggedDevice = device; + } + + function handleDragOver(event) { + event.preventDefault(); + } + + function handleDrop(event) { + event.preventDefault(); + if (!draggedDevice || !floorPlanRef) return; + + const rect = floorPlanRef.getBoundingClientRect(); + const x = ((event.clientX - rect.left) / rect.width) * 100; + const y = ((event.clientY - rect.top) / rect.height) * 100; + + // Check if device is already placed + const existingIndex = placedDevices.findIndex((d) => d.id === draggedDevice.id); + + if (existingIndex >= 0) { + // Update position + placedDevices[existingIndex] = { ...placedDevices[existingIndex], x, y }; + } else { + // Add new device + placedDevices = [...placedDevices, { ...draggedDevice, x, y }]; + } + + draggedDevice = null; + } + + function removeDevice(deviceId) { + placedDevices = placedDevices.filter((d) => d.id !== deviceId); + } -
-{#if form?.message} - -{/if} ++ Drag ESP8266 devices from below onto the floor plan to place them in specific rooms. +
+ {/if} + +