diff --git a/applications/visualizer/frontend/src/components/AppLauncher.tsx b/applications/visualizer/frontend/src/components/AppLauncher.tsx index ec8dea00..9df2684d 100644 --- a/applications/visualizer/frontend/src/components/AppLauncher.tsx +++ b/applications/visualizer/frontend/src/components/AppLauncher.tsx @@ -1,6 +1,7 @@ import { Typography, Card, CardContent, CardActionArea, Grid, Container, Box, AppBar, Toolbar, Button } from '@mui/material'; import { useGlobalContext } from "../contexts/GlobalContext.tsx"; import footerImage from '../assets/summary-neurons.png'; +import {parseURLParams} from "../helpers/parseURLHelper.ts"; function AppLauncher() { @@ -20,7 +21,10 @@ function AppLauncher() { }; const handlePasteUrlClick = () => { - console.log('Paste URL option clicked'); + const exampleURL = 'http://localhost:8080/mode=default&ws_name=workspace1&ids=ADAL,AIBR,RIML&ws_name=workspace3&ids=RIFL,REMV&ws_name=test&ids=ADAL'; + + const parsedParams = parseURLParams(exampleURL); + console.log(parsedParams) }; return ( diff --git a/applications/visualizer/frontend/src/helpers/parseURLHelper.ts b/applications/visualizer/frontend/src/helpers/parseURLHelper.ts new file mode 100644 index 00000000..3d71d68d --- /dev/null +++ b/applications/visualizer/frontend/src/helpers/parseURLHelper.ts @@ -0,0 +1,39 @@ +interface WorkspaceParams { + mode: string; + workspaces: { + name: string; + ids: string[]; + }[]; +} + +export function parseURLParams(url: string): WorkspaceParams { + const params = new URLSearchParams(url); + let mode = ''; + const workspaces: { name: string; ids: string[] }[] = []; + + let currentWorkspace: { name: string; ids: string[] } | null = null; + + params.forEach((value, key) => { + if (key.includes('mode')) { + mode = value; + } else if (key.startsWith('ws_name')) { + if (currentWorkspace) { + workspaces.push(currentWorkspace); + } + currentWorkspace = { + name: value, + ids: [] + }; + } else if (key.startsWith('ids')) { + if (currentWorkspace) { + currentWorkspace.ids = value.split(','); + } + } + }); + + if (currentWorkspace) { + workspaces.push(currentWorkspace); + } + + return { mode: mode, workspaces: workspaces }; +} \ No newline at end of file