diff --git a/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/mapClient.tsx b/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/mapClient.tsx index 14525d9..6fd212f 100644 --- a/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/mapClient.tsx +++ b/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/mapClient.tsx @@ -116,7 +116,7 @@ export function MapClient({ apiUrl }: MapClientProps) { (progress) => { setUploadProgress(progress); }, - (response) => { + async (response) => { if (response.success && response.data) { setLayers((prev) => [ ...prev, @@ -129,6 +129,17 @@ export function MapClient({ apiUrl }: MapClientProps) { }, ]); + // Refresh workspace layers upon successfull upload + try { + const connections = await getWorkspaceConnections(workspaceId); + setWorkspaceConnections(connections); + } catch (error) { + console.error( + "Failed to refresh workspace connections:", + error + ); + } + setUploadSuccess(true); setIsUploading(false); setSelectedFile(null); @@ -147,7 +158,7 @@ export function MapClient({ apiUrl }: MapClientProps) { setIsUploading(false); } }, - [uploadFile, fileName] + [uploadFile, fileName, workspaceId] ); // Abort Upload Handler diff --git a/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/navBars/mainMapNavigation.tsx b/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/navBars/mainMapNavigation.tsx index 6b639dc..bcc3586 100644 --- a/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/navBars/mainMapNavigation.tsx +++ b/gridwalk-ui/src/app/project/[workspaceId]/[projectName]/components/navBars/mainMapNavigation.tsx @@ -1,11 +1,13 @@ "use client"; -import React from "react"; +import React, { useState } from "react"; import { Layers, File, X, Upload, ArrowLeft, CheckCircle2 } from "lucide-react"; +import { Button } from "@/components/ui/button"; import { ModalProps, MainMapNav, WorkspaceConnection } from "./types"; import { useRouter } from "next/navigation"; interface LayersTableProps { - connections: WorkspaceConnection[]; // Changed from sources: Source[] + connections: WorkspaceConnection[]; + onLayerClick?: (connection: WorkspaceConnection) => void; } // Loading dots for file upload @@ -17,33 +19,56 @@ const LoadingDots = () => ( ); -const LayersTable: React.FC = ({ connections }) => ( -
- - - - - - - - {connections.map((connection, index) => ( - - - - ))} - -
- Source Name -
- {String(connection)} -
-
-); +// Table to the available layers +const LayersTable: React.FC = ({ + connections, + onLayerClick, +}) => { + const [selectedButtons, setSelectedButtons] = useState<{ + [key: number]: boolean; + }>({}); + + const toggleButton = (index: number, connection: WorkspaceConnection) => { + setSelectedButtons((prev) => ({ + ...prev, + [index]: !prev[index], + })); + onLayerClick?.(connection); + }; + + return ( +
+ + + {connections.map((connection, index) => ( + + + + ))} + +
+
+ {String(connection)} + +
+
+
+ ); +}; // Modals for uploading files, viewing layers etc const MapModal: React.FC = ({ @@ -77,14 +102,14 @@ const MapModal: React.FC = ({ id: "layers", title: "Layers", icon: "layers", - description: "Visualise map layers", + description: "Visualise available map layers", }, { id: "upload", title: "File Upload", icon: "file", description: - "Upload files and add a layer to the map. Currently accepts .geojson, .json, and .gpkg files.", + "Upload files and add a layer to the map. Currently accepts .geojson, .json, .gpkg files, .xlsx, and .parquet", }, ]; @@ -123,7 +148,6 @@ const MapModal: React.FC = ({ {workspaceConnections?.length > 0 ? (
{" "} - {/* Render table once */}
) : (

No layers available.