Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ZimLim committed Mar 4, 2024
1 parent dbfca67 commit 5085fb4
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 261 deletions.
3 changes: 1 addition & 2 deletions frontend/src/components/LayoutObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const LayoutComponent: FC<LayoutComponentProps> = (props) => {
setSelectedOption(null);
} else {
setSelectedOption(option);
props.onChange(option)

props.onChange(option);
}
};
const handleTextChange = (event: ChangeEvent<HTMLInputElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/MediaObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const MediaComponent: FC<MediaComponentProps> = (props) => {
setSelectedOption(null);
} else {
setSelectedOption(option);
props.onChange(option)
props.onChange(option);
props.value = option;
}
};
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/ModelObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Checkbox,
FormGroup,
FormControlLabel,
Button,
RadioGroup,
Radio,
FormLabel,
Expand All @@ -21,7 +20,7 @@ interface ModelComponentProps {
onChange: (arg0: MetabolicModel) => void;
}

const defaultParams: MetabolicModel['params'] = {
const defaultParams: MetabolicModel["params"] = {
demographicNoise: false,
demographicNoiseAmplitude: 0,
uptakeVMax: 0,
Expand All @@ -33,20 +32,21 @@ const defaultParams: MetabolicModel['params'] = {

export const ModelComponent: FC<ModelComponentProps> = (props) => {
const [selectedOption, setSelectedOption] = useState<MetabolicModel | null>();
const [modelParams, setModelParams] = useState<MetabolicModel['params']>(defaultParams);
const [modelParams, setModelParams] =
useState<MetabolicModel["params"]>(defaultParams);
const [textfieldError, setTextfieldError] = useState(false);
const handleCheckboxChange = (option: MetabolicModel) => {
if (selectedOption === option) {
setSelectedOption(null);
} else {
setSelectedOption(option);
props.onChange(option)
props.onChange(option);
}
};
const handleTextChange = (field: string, value: string) => {
if (/^\d*$/.test(value)) {
setModelParams({ ...modelParams, [field]: parseInt(value) });
props.value.params = { ...modelParams, [field]: parseInt(value) }
props.value.params = { ...modelParams, [field]: parseInt(value) };
setTextfieldError(false);
} else {
setTextfieldError(true);
Expand Down
74 changes: 38 additions & 36 deletions frontend/src/components/SidebarObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,69 @@ import {
List,
ListItemText,
Typography,
Button
} from "@mui/material";
import { FC, useState, ChangeEvent } from "react";
import { FC } from "react";
import { SummaryCard } from "../types/ExperimentTypes";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
export interface SidebarcardProps {
item: SummaryCard
item: SummaryCard;
key: number;
}

const textPairing: { [key: string]: string } = {
"mediaVolume": "Media Volume(ml)",
"mediaConcentration": "Media Concentration(mmol/cm3)",
"demographicNoise": "Demographic Noise",
"demographicNoiseAmplitude": "Demographic Noise Amplitude",
"uptakeVMax": "Uptake Vmax",
"uptakeKm": "Uptake Km",
"deathRate": "Death Rate",
"biomassLinearDiffusivity": "Biomass Linear Diffusivity",
"biomassNonlinearDiffusivity": "Biomass Non-Linear Diffusivity",
"simulatedTime": "Simulated Time",
"timeSteps": "Time Steps",
"nutrientDiffusivity": "Nutrient Diffusivity",
"logFrequency": "Log Frequency"
}

mediaVolume: "Media Volume(ml)",
mediaConcentration: "Media Concentration(mmol/cm3)",
demographicNoise: "Demographic Noise",
demographicNoiseAmplitude: "Demographic Noise Amplitude",
uptakeVMax: "Uptake Vmax",
uptakeKm: "Uptake Km",
deathRate: "Death Rate",
biomassLinearDiffusivity: "Biomass Linear Diffusivity",
biomassNonlinearDiffusivity: "Biomass Non-Linear Diffusivity",
simulatedTime: "Simulated Time",
timeSteps: "Time Steps",
nutrientDiffusivity: "Nutrient Diffusivity",
logFrequency: "Log Frequency",
};

export const SidebarCard: FC<SidebarcardProps> = (props) => {
return (
<Box sx={{ width: "95%", marginLeft: 1, paddingBottom:'0.5vh' }} key={props.key}>

<Accordion>
<Box
sx={{ width: "95%", marginLeft: 1, paddingBottom: "0.5vh" }}
key={props.key}
>
<Accordion>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1-content"
id="panel1-header"
>
<Typography variant="h6">{props.item.label}</Typography>

</AccordionSummary>
<AccordionDetails>
<List>
<ListItemText>
{
Object.keys(props.item.info.params).map(key => {
let ret;
if(typeof(props.item.info.params[key]) === 'boolean'){
ret = <Typography textAlign={'left'} textOverflow={'wrap'}>{textPairing[key]}: {String(props.item.info.params[key])}</Typography>
}else{
ret = <Typography textAlign={'left'} textOverflow={'wrap'}>{textPairing[key]}: {props.item.info.params[key]}</Typography>
}
return(
ret
)
})
}
{Object.keys(props.item.info.params).map((key) => {
let ret;
if (typeof props.item.info.params[key] === "boolean") {
ret = (
<Typography textAlign={"left"} textOverflow={"wrap"}>
{textPairing[key]}: {String(props.item.info.params[key])}
</Typography>
);
} else {
ret = (
<Typography textAlign={"left"} textOverflow={"wrap"}>
{textPairing[key]}: {props.item.info.params[key]}
</Typography>
);
}
return ret;
})}
</ListItemText>
</List>
</AccordionDetails>
</Accordion>

</Box>
);
};
30 changes: 14 additions & 16 deletions frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ export function DashboardPage() {
</Typography>
</Grid>

<Grid item flexDirection={'column'}>

<Grid item flexDirection={"column"}>
<Typography
variant="h4"
sx={{
Expand All @@ -115,20 +114,19 @@ export function DashboardPage() {
>
To start your layout, click continue.
</Typography>

<NavLink to="/experimentSetup">
<Button
variant="contained"
endIcon={<ChevronRightIcon />}
sx={{
height: "7.5vh",
width: "25vw"
}}
>
<Typography variant="h5">CONTINUE TO LAYOUT BUILDER</Typography>
</Button>
</NavLink>


<NavLink to="/experimentSetup">
<Button
variant="contained"
endIcon={<ChevronRightIcon />}
sx={{
height: "7.5vh",
width: "25vw",
}}
>
<Typography variant="h5">CONTINUE TO LAYOUT BUILDER</Typography>
</Button>
</NavLink>
</Grid>
</Grid>
</Box>
Expand Down
Loading

0 comments on commit 5085fb4

Please sign in to comment.