Skip to content

Commit

Permalink
added popup modal for rerun optimization with functionality for overw…
Browse files Browse the repository at this point in the history
…rite current scenario, still needs functionality for create new scenario; added prop to all instances of popupmodal
  • Loading branch information
MichaelPesce committed Aug 2, 2023
1 parent 5bd414f commit d5a4e91
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
29 changes: 25 additions & 4 deletions electron/ui/src/components/Bottombar/Bottombar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import PopupModal from '../../components/PopupModal/PopupModal';

export default function Bottombar(props) {
const [ openSaveModal, setOpenSaveModal ] = useState(false)
const [ openRerunModal, setOpenRerunModal] = useState(false)
// const [ disableOptimize, setDisableOptimize ] = useState(false)
const [ key, setKey ] = useState(null)
const [ hasOverride, setHasOverride ] = useState(false)
const handleOpenSaveModal = () => setOpenSaveModal(true);
const handleCloseSaveModal = () => setOpenSaveModal(false);
const handleCloseRerunModal = () => setOpenRerunModal(false);
const styles = {
filled: {
backgroundColor: '#01678f',
Expand Down Expand Up @@ -94,12 +96,15 @@ export default function Bottombar(props) {
}

const handleRunOptimize = () => {
// console.log('rerun with the following overrides: ')
// console.log(props.scenario.override_values)

handleCloseRerunModal()
props.handleRunModel()
}

const reoptimizeNewScenario = () => {
// create function in app.js for this
// props.handleRunModel()
}

return (
<Box sx={{ width: 500 }}>
<CssBaseline />
Expand All @@ -116,7 +121,7 @@ export default function Bottombar(props) {
<Box sx={{display: 'flex', justifyContent: 'flex-end', marginRight:'10px'}}>
{props.section === 0 && <Button sx={styles.filled} onClick={() => handleClick(1)} variant="contained" size="large" endIcon={<ArrowForwardIcon /> }> continue to optimization </Button>}
{props.section === 1 && <Button onClick={handleRunOptimize} sx={styles.filled} variant="contained" size="large" disabled={props.disableOptimize ? true : false} endIcon={<ArrowForwardIcon /> }> Optimize </Button>}
{(props.section === 2 && hasOverride) && <Button onClick={handleRunOptimize} sx={styles.filled} variant="contained" size="large" disabled={props.disableOptimize ? true : false} endIcon={<ArrowForwardIcon /> }> Re-run Optimization </Button>}
{(props.section === 2 && hasOverride) && <Button onClick={() => setOpenRerunModal(true)} sx={styles.filled} variant="contained" size="large" disabled={props.disableOptimize ? true : false} endIcon={<ArrowForwardIcon /> }> Re-run Optimization </Button>}
</Box>
</Grid>
</Grid>
Expand All @@ -137,6 +142,22 @@ export default function Bottombar(props) {
buttonTwoText='Discard'
buttonTwoColor='error'
buttonTwoVariant='outlined'
width={400}
/>
<PopupModal
hasTwoButtons
open={openRerunModal}
handleClose={handleCloseRerunModal}
handleSave={reoptimizeNewScenario}
handleButtonTwoClick={handleRunOptimize}
text="Would you like to create a new scenario for this optimization, or overwrite the current scenario?"
buttonText='+ Create New Scenario'
buttonColor='primary'
buttonVariant='contained'
buttonTwoText='Overwrite Current Scenario'
buttonTwoColor='secondary'
buttonTwoVariant='outlined'
width={775}
/>
</Box>
);
Expand Down
8 changes: 4 additions & 4 deletions electron/ui/src/components/PopupModal/PopupModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Dashboard(props) {
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 400,
width: props.width !== undefined ? props.width : 400,
bgcolor: 'background.paper',
border: '2px solid #000',
boxShadow: 24,
Expand Down Expand Up @@ -53,11 +53,11 @@ export default function Dashboard(props) {
{props.hasTwoButtons ?
<>
<Grid item xs={1}></Grid>
<Grid item xs={4}>
<Grid item xs={4.5}>
<Button fullWidth onClick={props.handleButtonTwoClick} variant={props.buttonTwoVariant} color={props.buttonTwoColor}>{props.buttonTwoText}</Button>
</Grid>
<Grid item xs={2}></Grid>
<Grid item xs={4}>
<Grid item xs={1}></Grid>
<Grid item xs={4.5}>
<Button fullWidth onClick={props.handleSave} variant={props.buttonVariant} color={props.buttonColor}>{props.buttonText}</Button>
</Grid>
<Grid item xs={1}></Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default function ProcessToolbar(props) {
buttonTwoText='Discard'
buttonTwoColor='error'
buttonTwoVariant='outlined'
width={400}
/>
</Box>
);
Expand Down
1 change: 1 addition & 0 deletions electron/ui/src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export default function Sidebar(props) {
buttonTwoText='Discard'
buttonTwoColor='error'
buttonTwoVariant='outlined'
width={400}
/>
</Box>
);
Expand Down
1 change: 1 addition & 0 deletions electron/ui/src/views/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export default function Dashboard(props) {
buttonText='Save'
buttonColor='primary'
buttonVariant='contained'
width={400}
/>
<Grid item xs={4}>
<div>
Expand Down
2 changes: 2 additions & 0 deletions electron/ui/src/views/ScenarioList/ScenarioList.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export default function ScenarioList(props) {
buttonText='Save'
buttonColor='primary'
buttonVariant='contained'
width={400}
/>
<PopupModal
open={openDeleteModal}
Expand All @@ -262,6 +263,7 @@ export default function ScenarioList(props) {
buttonText='Delete'
buttonColor='error'
buttonVariant='contained'
width={400}
/>
{
showError && <ErrorBar duration={2000} setOpen={setShowError} severity="error" errorMessage={errorMessage} />
Expand Down

0 comments on commit d5a4e91

Please sign in to comment.