From 282a6777ba9571ac56228677fc6b93f2ab2bbfb1 Mon Sep 17 00:00:00 2001 From: Yousef Moazzam Date: Thu, 2 Jul 2026 14:29:07 +0100 Subject: [PATCH] Add minimal scan selector component --- frontend/unified/src/App.tsx | 7 +- .../unified/src/components/ScanSelector.tsx | 209 ++++++++++++++++++ 2 files changed, 211 insertions(+), 5 deletions(-) create mode 100644 frontend/unified/src/components/ScanSelector.tsx diff --git a/frontend/unified/src/App.tsx b/frontend/unified/src/App.tsx index b5152e5..9122853 100644 --- a/frontend/unified/src/App.tsx +++ b/frontend/unified/src/App.tsx @@ -1,5 +1,6 @@ import { Box, Divider, Grid2 as Grid, Stack, Typography } from "@mui/material"; import { SessionSelector } from "./components/SessionSelector"; +import { ScanSelector } from "./components/ScanSelector"; const VERTICAL_SPACING = 2; const HORIZONTAL_SPACING = 2; @@ -13,11 +14,7 @@ export const App: React.FC = () => { Scan - + App { + const [textInputValue, setTextInputValue] = useState(""); + return ( + + ) => { + setTextInputValue(e.currentTarget.value); + }} + /> + + ); +}; + +const MultiScanSelector: React.FC = () => { + const [mode, setMode] = useState( + MultiScanSelectionMode.Range + ); + + return ( + <> + { + if (toggleButtonLabel === MultiScanSelectionMode.Manual) { + setMode(MultiScanSelectionMode.Manual); + } else if (toggleButtonLabel === MultiScanSelectionMode.Range) { + setMode(MultiScanSelectionMode.Range); + } + }} + > + + {MultiScanSelectionMode.Manual} + + + {MultiScanSelectionMode.Range} + + + {mode === MultiScanSelectionMode.Manual ? ( + + ) : ( + + )} + + ); +}; + +const MultiScanRangeSelector: React.FC = () => { + const [start, setStart] = useState("1"); + const [stop, setStop] = useState("2"); + const [step, setStep] = useState("1"); + + return ( + + ) => + setStart(e.target.value) + } + /> + ) => + setStop(e.target.value) + } + /> + ) => + setStep(e.target.value) + } + /> + + ); +}; + +const MultiScanManualSelector: React.FC = () => { + const [textInputValue, setTextInputValue] = useState("4"); + const [scanIds, setScanIds] = useState([1, 2, 3]); + + const handleDeleteScanIdChip = (idToDelete: number) => { + setScanIds((ids: number[]) => ids.filter((id) => id !== idToDelete)); + }; + + const handleClickAddScanIdButton = (idToAdd: number) => { + if (scanIds.includes(idToAdd)) { + return; + } + setScanIds([...scanIds, idToAdd]); + setTextInputValue(String(Number(textInputValue) + 1)); + }; + + return ( + + ) => { + setTextInputValue(e.currentTarget.value); + }} + slotProps={{ + input: { + endAdornment: ( + + + handleClickAddScanIdButton(Number(textInputValue)) + } + > + + + + ), + }, + }} + /> + + {scanIds.map((scanId: number) => { + return ( + handleDeleteScanIdChip(scanId)} + > + ); + })} + + + ); +}; + +export const ScanSelector: React.FC = () => { + const [scanSelectionMode, setScanSelectionMode] = useState( + ScanSelectionMode.Single + ); + + return ( + + { + if (toggleButtonLabel === ScanSelectionMode.Single) { + setScanSelectionMode(ScanSelectionMode.Single); + } else if (toggleButtonLabel === ScanSelectionMode.Multiple) { + setScanSelectionMode(ScanSelectionMode.Multiple); + } + }} + > + + {ScanSelectionMode.Single} + + + {ScanSelectionMode.Multiple} + + + {scanSelectionMode === ScanSelectionMode.Single ? ( + + ) : ( + + )} + + ); +};