-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from DiamondLightSource/composition
Using Composition over Inheritance
- Loading branch information
Showing
38 changed files
with
1,599 additions
and
1,386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import { Box, Stack } from "@mui/material"; | ||
import { Stack } from "@mui/material"; | ||
import DataSideBar from "./data-entry/dataSideBar"; | ||
import CentrePlot from "./plot/centrePlot"; | ||
import BasicAppBar from "./basicAppBar"; | ||
|
||
export default function App(): JSX.Element { | ||
return ( | ||
<Box> | ||
<> | ||
<BasicAppBar /> | ||
<Stack direction={"row"} spacing={1} margin={1}> | ||
<Box> | ||
<DataSideBar /> | ||
</Box> | ||
<DataSideBar /> | ||
<Stack direction={"column"} spacing={1} flexGrow={1}> | ||
<CentrePlot /> | ||
</Stack> | ||
</Stack> | ||
</Box> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,61 @@ | ||
import AppBar from "@mui/material/AppBar"; | ||
import Box from "@mui/material/Box"; | ||
import Toolbar from "@mui/material/Toolbar"; | ||
import Typography from "@mui/material/Typography"; | ||
import { useDetectorStore } from "./data-entry/detectorStore"; | ||
import { presetConfigRecord } from "./presets/presetManager"; | ||
import { Autocomplete, TextField } from "@mui/material"; | ||
import { useBeamlineConfigStore } from "./data-entry/beamlineconfigStore"; | ||
import { useState } from "react"; | ||
import { useBeamstopStore } from "./data-entry/beamstopStore"; | ||
import { useCameraTubeStore } from "./data-entry/cameraTubeStore"; | ||
import { LengthUnits } from "./utils/units"; | ||
|
||
export default function BasicAppBar(): JSX.Element { | ||
const [preset, setPreset] = useState<string>( | ||
Object.keys(presetConfigRecord)[0], | ||
); | ||
const detectorStore = useDetectorStore(); | ||
const beamlineConfigStore = useBeamlineConfigStore(); | ||
const beamstopStore = useBeamstopStore(); | ||
const cameraTubeStore = useCameraTubeStore(); | ||
|
||
const handlePreset = (preset: string) => { | ||
const { beamstop, cameraTube, detector, beamline } = | ||
presetConfigRecord[preset]; | ||
detectorStore.updateDetector(detector); | ||
beamstopStore.updateBeamstop(beamstop); | ||
cameraTubeStore.updateCameraTube(cameraTube); | ||
beamlineConfigStore.updateBeamline(beamline); | ||
beamstopStore.updateDiameter( | ||
beamlineConfigStore.beamlineRecord[beamline].beamstopDiameter, | ||
LengthUnits.millimetre, | ||
); | ||
cameraTubeStore.updateDiameter( | ||
beamlineConfigStore.beamlineRecord[beamline].cameratubeDiameter, | ||
LengthUnits.millimetre, | ||
); | ||
setPreset(preset); | ||
}; | ||
|
||
return ( | ||
<Box > | ||
<AppBar position="static"> | ||
<Toolbar> | ||
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> | ||
Dedi Web | ||
</Typography> | ||
</Toolbar> | ||
</AppBar> | ||
</Box> | ||
<AppBar position="static"> | ||
<Toolbar> | ||
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> | ||
Dedi Web | ||
</Typography> | ||
<Autocomplete | ||
size="small" | ||
options={Object.keys(presetConfigRecord)} | ||
value={preset} | ||
sx={{ width: 300, color: "white" }} | ||
renderInput={(params) => ( | ||
<TextField {...params} label="preset" sx={{ color: "black" }} /> | ||
)} | ||
onChange={(_, value) => { | ||
value ? handlePreset(value) : {}; | ||
}} | ||
/> | ||
</Toolbar> | ||
</AppBar> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.