small change
This commit is contained in:
@@ -1 +1 @@
|
|||||||
[]
|
[{"name":"name","ip":"pass"},{"name":"name","ip":"pass"}]
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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 })
|
||||||
|
|||||||
Reference in New Issue
Block a user