small change

This commit is contained in:
2025-07-17 06:01:10 +02:00
parent 266cad96e1
commit 1e4011fa8f
3 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
[] [{"name":"name","ip":"pass"},{"name":"name","ip":"pass"}]
+9 -1
View File
@@ -5,7 +5,7 @@ import "maplibre-gl/dist/maplibre-gl.css";
export default function MapSelect({ export default function MapSelect({
setLocation, setLocation,
}: { }: {
setLocation: (coors: [number, number]) => void; setLocation: (coords: [number, number] | undefined) => void;
}) { }) {
const mapContainer = useRef<HTMLDivElement | null>(null); const mapContainer = useRef<HTMLDivElement | null>(null);
const map = useRef<maplibregl.Map | null>(null); const map = useRef<maplibregl.Map | null>(null);
@@ -39,6 +39,14 @@ export default function MapSelect({
.addTo(map.current!); .addTo(map.current!);
}); });
map.current.on("contextmenu", () => {
if (marker.current) {
marker.current.remove();
marker.current = null;
setLocation(undefined);
}
});
return () => { return () => {
// Clean up marker // Clean up marker
if (marker.current) { if (marker.current) {
+9 -2
View File
@@ -42,15 +42,21 @@ export default function NewServerDialog({
<DialogHeader> <DialogHeader>
<DialogTitle>Add Server</DialogTitle> <DialogTitle>Add Server</DialogTitle>
</DialogHeader> </DialogHeader>
<Label className="mt-2">Server Name</Label> <Label className="mt-2">
Server Name<span className="text-red-500">*</span>
</Label>
<Input <Input
placeholder="Main Server, Database, etc" placeholder="Main Server, Database, etc"
required
onInput={(e) => setName(e.currentTarget.value)} onInput={(e) => setName(e.currentTarget.value)}
/> />
<Label className="mt-2">Server IP</Label> <Label className="mt-2">
Server IP<span className="text-red-500">*</span>
</Label>
<Input <Input
placeholder="10.7.1.10, etc" placeholder="10.7.1.10, etc"
required
onInput={(e) => setIp(e.currentTarget.value)} onInput={(e) => setIp(e.currentTarget.value)}
/> />
@@ -68,6 +74,7 @@ export default function NewServerDialog({
<MapSelect setLocation={setCoordinates} /> <MapSelect setLocation={setCoordinates} />
<DialogFooter> <DialogFooter>
<Button <Button
disabled={name == "" || ip == ""}
onClick={() => { onClick={() => {
session session
?.addServer({ name, ip, coordinates, location }) ?.addServer({ name, ip, coordinates, location })