diff --git a/frontend/src/components/LayoutObject.tsx b/frontend/src/components/LayoutObject.tsx index b5b4e315..a65580ac 100644 --- a/frontend/src/components/LayoutObject.tsx +++ b/frontend/src/components/LayoutObject.tsx @@ -24,8 +24,7 @@ export const LayoutComponent: FC = (props) => { setSelectedOption(null); } else { setSelectedOption(option); - props.onChange(option) - + props.onChange(option); } }; const handleTextChange = (event: ChangeEvent) => { diff --git a/frontend/src/components/MediaObject.tsx b/frontend/src/components/MediaObject.tsx index 0aba0faf..6d609468 100644 --- a/frontend/src/components/MediaObject.tsx +++ b/frontend/src/components/MediaObject.tsx @@ -26,7 +26,7 @@ export const MediaComponent: FC = (props) => { setSelectedOption(null); } else { setSelectedOption(option); - props.onChange(option) + props.onChange(option); props.value = option; } }; diff --git a/frontend/src/components/ModelObject.tsx b/frontend/src/components/ModelObject.tsx index 3edcbeba..2afafdc4 100644 --- a/frontend/src/components/ModelObject.tsx +++ b/frontend/src/components/ModelObject.tsx @@ -4,7 +4,6 @@ import { Checkbox, FormGroup, FormControlLabel, - Button, RadioGroup, Radio, FormLabel, @@ -21,7 +20,7 @@ interface ModelComponentProps { onChange: (arg0: MetabolicModel) => void; } -const defaultParams: MetabolicModel['params'] = { +const defaultParams: MetabolicModel["params"] = { demographicNoise: false, demographicNoiseAmplitude: 0, uptakeVMax: 0, @@ -33,20 +32,21 @@ const defaultParams: MetabolicModel['params'] = { export const ModelComponent: FC = (props) => { const [selectedOption, setSelectedOption] = useState(); - const [modelParams, setModelParams] = useState(defaultParams); + const [modelParams, setModelParams] = + useState(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); diff --git a/frontend/src/components/SidebarObject.tsx b/frontend/src/components/SidebarObject.tsx index 7f0523dc..81457466 100644 --- a/frontend/src/components/SidebarObject.tsx +++ b/frontend/src/components/SidebarObject.tsx @@ -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 = (props) => { return ( - - - + + } aria-controls="panel1-content" id="panel1-header" > {props.item.label} - - { - Object.keys(props.item.info.params).map(key => { - let ret; - if(typeof(props.item.info.params[key]) === 'boolean'){ - ret = {textPairing[key]}: {String(props.item.info.params[key])} - }else{ - ret = {textPairing[key]}: {props.item.info.params[key]} - } - return( - ret - ) - }) - } + {Object.keys(props.item.info.params).map((key) => { + let ret; + if (typeof props.item.info.params[key] === "boolean") { + ret = ( + + {textPairing[key]}: {String(props.item.info.params[key])} + + ); + } else { + ret = ( + + {textPairing[key]}: {props.item.info.params[key]} + + ); + } + return ret; + })} - ); }; diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index cf4cdad5..5c6ab75d 100644 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -100,8 +100,7 @@ export function DashboardPage() { - - + To start your layout, click continue. - - - - - + + + + diff --git a/frontend/src/pages/ExperimentSetup.tsx b/frontend/src/pages/ExperimentSetup.tsx index 7532f8ca..07ea1657 100644 --- a/frontend/src/pages/ExperimentSetup.tsx +++ b/frontend/src/pages/ExperimentSetup.tsx @@ -14,10 +14,17 @@ import React, { useState } from "react"; import { MediaComponent } from "../components/MediaObject"; import { LayoutComponent } from "../components/LayoutObject"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; -import DeleteIcon from '@mui/icons-material/Delete'; +import DeleteIcon from "@mui/icons-material/Delete"; import { ModelComponent } from "../components/ModelObject"; import { SidebarCard } from "../components/SidebarObject"; -import { MetabolicModel, Layout, Media, SummaryCard, GlobalParameters, cometsType } from "../types/ExperimentTypes"; +import { + MetabolicModel, + Layout, + Media, + SummaryCard, + GlobalParameters, + cometsType, +} from "../types/ExperimentTypes"; const mediaOptions: Media[] = [ { @@ -26,9 +33,9 @@ const mediaOptions: Media[] = [ mainMetabolites: "Glucose", min: 1, max: 3, - params:{ - mediaConcentration: 0 - } + params: { + mediaConcentration: 0, + }, }, { name: "Core Acetate", @@ -36,9 +43,9 @@ const mediaOptions: Media[] = [ mainMetabolites: "Acetate", min: 1, max: 3, - params:{ - mediaConcentration: 0 - } + params: { + mediaConcentration: 0, + }, }, { name: "M9 Minimal Glucose", @@ -46,9 +53,9 @@ const mediaOptions: Media[] = [ mainMetabolites: "Glucose", min: 1, max: 3, - params:{ - mediaConcentration: 0 - } + params: { + mediaConcentration: 0, + }, }, { name: "M9 Minimal Acetate", @@ -56,9 +63,9 @@ const mediaOptions: Media[] = [ mainMetabolites: "Acetate", min: 1, max: 3, - params:{ - mediaConcentration: 0 - } + params: { + mediaConcentration: 0, + }, }, { name: "LB Rich", @@ -66,9 +73,9 @@ const mediaOptions: Media[] = [ mainMetabolites: "Acetate", min: 1, max: 3, - params:{ - mediaConcentration: 0 - } + params: { + mediaConcentration: 0, + }, }, ]; @@ -79,8 +86,8 @@ const layoutOptions: Layout[] = [ min: 1, max: 12, params: { - mediaVolume: 0 - } + mediaVolume: 0, + }, }, { name: "9 cm Petri Dish (Random Lawn)", @@ -88,8 +95,8 @@ const layoutOptions: Layout[] = [ min: 1, max: 50, params: { - mediaVolume: 0 - } + mediaVolume: 0, + }, }, { name: "10 ml Test Tube", @@ -97,8 +104,8 @@ const layoutOptions: Layout[] = [ min: 1, max: 50, params: { - mediaVolume: 0 - } + mediaVolume: 0, + }, }, { name: "EcoFab", @@ -106,8 +113,8 @@ const layoutOptions: Layout[] = [ min: 1, max: 50, params: { - mediaVolume: 0 - } + mediaVolume: 0, + }, }, ]; @@ -122,7 +129,7 @@ const modelOptions: MetabolicModel[] = [ uptakeKm: 0, deathRate: 0, biomassLinearDiffusivity: 0, - biomassNonlinearDiffusivity: 0 + biomassNonlinearDiffusivity: 0, }, }, { @@ -135,7 +142,7 @@ const modelOptions: MetabolicModel[] = [ uptakeKm: 0, deathRate: 0, biomassLinearDiffusivity: 0, - biomassNonlinearDiffusivity: 0 + biomassNonlinearDiffusivity: 0, }, }, { @@ -148,7 +155,7 @@ const modelOptions: MetabolicModel[] = [ uptakeKm: 0, deathRate: 0, biomassLinearDiffusivity: 0, - biomassNonlinearDiffusivity: 0 + biomassNonlinearDiffusivity: 0, }, }, ]; @@ -170,11 +177,13 @@ export function ExperimentSetupPage() { simulatedTime: 0, timeSteps: 0, nutrientDiffusivity: 0, - logFrequency: 0 - } + logFrequency: 0, + }, }); const [sidebarItems, setSidebarItems] = useState([]); - const [modelChoice, setModelChoice] = useState(modelOptions[0]); + const [modelChoice, setModelChoice] = useState( + modelOptions[0], + ); const [layoutChoice, setLayoutChoice] = useState(layoutOptions[0]); const [mediaChoice, setMediaChoice] = useState(mediaOptions[0]); const [textfieldError, setTextfieldError] = useState(false); @@ -187,21 +196,20 @@ export function ExperimentSetupPage() { const handleDelete = (index: number) => { // Create a copy of the sidebarItems array const updatedSidebarItems = [...sidebarItems]; - switch ((updatedSidebarItems[index].type)){ + switch (updatedSidebarItems[index].type) { case "MetabolicModel": - setNumOfModel(prevCount => prevCount - 1); - if(numOfModel <= 0){ - setNumOfModel(0) - setIsModelPicked(false) + setNumOfModel((prevCount) => prevCount - 1); + if (numOfModel <= 0) { + setNumOfModel(0); + setIsModelPicked(false); + console.log(isModelPicked) } - console.log(numOfModel) break; case "Media": - setIsMediaPicked(true); + setIsMediaPicked(false); break; case "Layout": - setIsLayoutPicked(true); - + setIsLayoutPicked(false); } // Remove the item at the specified index updatedSidebarItems.splice(index, 1); @@ -209,17 +217,16 @@ export function ExperimentSetupPage() { setSidebarItems(updatedSidebarItems); }; - const handleTextChange = (field: string, value: string) => { if (/^\d*$/.test(value)) { const updatedParams = { name: "Global Parameters", desc: "Desc of global parameters", params: { - ...globalParams['params'], - [field]: parseInt(value) - } - } + ...globalParams["params"], + [field]: parseInt(value), + }, + }; setGlobalParams(updatedParams); setTextfieldError(false); } else { @@ -237,26 +244,27 @@ export function ExperimentSetupPage() { } }; - const handleSubmit = (item: MetabolicModel | Media | Layout | GlobalParameters) => { - if (item === null){ - return + const handleSubmit = ( + item: MetabolicModel | Media | Layout | GlobalParameters, + ) => { + if (item === null) { + return; } // make a shallow copy to pass by value - const i = {...item}; - const sidebarItem: SummaryCard = - { - "label": i.name, - "desc": i.desc, - "info": i, - "type": cometsType(item) - } - - setSidebarItems([...sidebarItems, sidebarItem]) - switch (cometsType(item)){ + const i = { ...item }; + const sidebarItem: SummaryCard = { + label: i.name, + desc: i.desc, + info: i, + type: cometsType(item), + }; + + setSidebarItems([...sidebarItems, sidebarItem]); + switch (cometsType(item)) { case "MetabolicModel": - setNumOfModel(prevCount => prevCount + 1) - if(numOfModel > 0 && numOfModel >= maxModel){ - setIsModelPicked(true) + setNumOfModel((prevCount) => prevCount + 1); + if (numOfModel > 0 && numOfModel >= maxModel) { + setIsModelPicked(true); } break; case "Media": @@ -292,7 +300,11 @@ export function ExperimentSetupPage() { - + } aria-controls="layoutPanelbh-content" @@ -310,12 +322,13 @@ export function ExperimentSetupPage() { /> + sx={{ margin: 2, width: "90%" }} + variant="outlined" + onClick={() => handleSubmit(layoutChoice)} + disabled={isLayoutPicked} + > + ADD LAYOUT + - + /> + sx={{ margin: 2, width: "90%" }} + variant="outlined" + onClick={() => handleSubmit(mediaChoice)} + disabled={isMediaPicked} + > + ADD MEDIA + + sx={{ margin: 2, width: "90%" }} + variant="outlined" + onClick={() => handleSubmit(modelChoice)} + disabled={numOfModel >= maxModel} + > + ADD MODEL + @@ -396,7 +410,7 @@ export function ExperimentSetupPage() { variant="filled" type="number" fullWidth - value={(globalParams.params.simulatedTime)} + value={globalParams.params.simulatedTime} onChange={(event) => handleTextChange("simulatedTime", event.target.value) } @@ -422,7 +436,7 @@ export function ExperimentSetupPage() { variant="filled" type="number" fullWidth - value={(globalParams.params.timeSteps)} + value={globalParams.params.timeSteps} onChange={(event) => handleTextChange("timeSteps", event.target.value) } @@ -448,7 +462,7 @@ export function ExperimentSetupPage() { variant="filled" type="number" fullWidth - value={(globalParams.params.nutrientDiffusivity)} + value={globalParams.params.nutrientDiffusivity} onChange={(event) => handleTextChange("nutrientDiffusivity", event.target.value) } @@ -474,7 +488,7 @@ export function ExperimentSetupPage() { variant="filled" type="number" fullWidth - value={(globalParams.params.logFrequency)} + value={globalParams.params.logFrequency} onChange={(event) => handleTextChange("logFrequency", event.target.value) } @@ -486,14 +500,13 @@ export function ExperimentSetupPage() { /> - {/* Cart drawer on the right */} Modal Selection - - {sidebarItems.map((item, index) => - - + + About COMETS + +