Skip to content

Commit

Permalink
Merge pull request watertap-org#89 from MichaelPesce/0.9.0
Browse files Browse the repository at this point in the history
Move solve/sweep toggle location; disable run sweep button when no sweep variables are selected
  • Loading branch information
MichaelPesce authored Jul 6, 2023
2 parents 6eac0ff + 4947b18 commit 9350ba8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/electron-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: App build
on:
push:
branches:
- 0.9.0rc0
- "0.9.0"

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "watertap-ui",
"author": "Michael Pesce <[email protected]>",
"version": "0.9.0rc0",
"version": "0.9.0",
"private": true,
"main": "build/main.js",
"dependencies": {
Expand Down
45 changes: 26 additions & 19 deletions electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import InputAccordion from "../../../components/InputAccordion/InputAccordion";
import { loadConfig, listConfigNames } from '../../../services/output.service.js'
import { useParams } from "react-router-dom";
import { deleteConfig } from '../../../services/input.service.js'
import { Button, Box, Modal, Select, Stack, Toolbar, Typography } from '@mui/material';
import { ToggleButton, ToggleButtonGroup, Grid, InputLabel, MenuItem, FormControl } from '@mui/material';
import { Button, Box, Modal, Select, Stack, Toolbar, Tooltip } from '@mui/material';
import { Grid, InputLabel, MenuItem, FormControl } from '@mui/material';
import RefreshIcon from '@mui/icons-material/Refresh';
import DeleteForeverIcon from '@mui/icons-material/DeleteForever';

Expand All @@ -16,12 +16,13 @@ import DeleteForeverIcon from '@mui/icons-material/DeleteForever';

export default function ConfigInput(props) {
let params = useParams();
const { flowsheetData, updateFlowsheetData, reset, solveType, handleToggleSolveType } = props;
const { flowsheetData, updateFlowsheetData, reset, solveType } = props;
const [ displayData, setDisplayData ] = useState({})
const [ previousConfigs, setPreviousConfigs ] = useState([])
const [ configName, setConfigName ] = React.useState("");
const [ openDeleteConfig, setOpenDeleteConfig] = useState(false)
const [ openErrorMessage, setOpenErrorMessage ] = useState(false);
const [ disableRun, setDisableRun ] = useState(false)

const modalStyle = {
position: 'absolute',
Expand All @@ -36,7 +37,7 @@ export default function ConfigInput(props) {
};


useEffect(()=>{
useEffect(()=>{
setDisplayData(JSON.parse(JSON.stringify(flowsheetData.inputData)))
listConfigNames(params.id, flowsheetData.inputData.version)
.then(response => {
Expand All @@ -56,6 +57,22 @@ export default function ConfigInput(props) {
}
})
}, [flowsheetData.inputData]);

useEffect(()=>{
if (solveType === "solve") setDisableRun(false)
else {
let tempDisableRun = true
for(let each of Object.keys(flowsheetData.inputData.model_objects)) {
let modelObject = flowsheetData.inputData.model_objects[each]
if(modelObject.is_sweep) {
tempDisableRun = false
break
}
}
setDisableRun(tempDisableRun)
}

}, [flowsheetData.inputData, solveType]);

const handleConfigSelection = (event) => {
const {
Expand Down Expand Up @@ -211,19 +228,6 @@ export default function ConfigInput(props) {
<>
<Toolbar spacing={2}>
<Stack direction="row" spacing={2}>
<ToggleButtonGroup
orientation="horizontal"
value={solveType}
exclusive
onChange={handleToggleSolveType}
>
<ToggleButton value="solve" aria-label="solve">
<Typography>Solve</Typography>
</ToggleButton>
<ToggleButton value="sweep" aria-label="sweep">
<Typography>Sweep</Typography>
</ToggleButton>
</ToggleButtonGroup>
{previousConfigs.length > 0 &&
<>
<InputLabel style={{paddingTop:"8px"}} id="previous-configs-label">Previous Configurations:</InputLabel>
Expand Down Expand Up @@ -262,8 +266,11 @@ export default function ConfigInput(props) {
{/* <Button variant="outlined" startIcon={<SaveIcon />} onClick={()=>updateFlowsheetData(flowsheetData.inputData,null)}>UPDATE FLOWSHEET</Button> */}

<Button variant="outlined" startIcon={<RefreshIcon />} onClick={reset}>RESET FLOWSHEET</Button>
<Button variant="contained" onClick={()=>updateFlowsheetData(flowsheetData.inputData,solveType)}>RUN</Button>
{/* <Button variant="contained" onClick={()=>updateFlowsheetData(flowsheetData.inputData,"sweep")}>SWEEP</Button> */}
<Tooltip title={disableRun ? "To run a sweep, at least one variable must be set to sweep" : ""}>
<div>
<Button variant="contained" onClick={()=>updateFlowsheetData(flowsheetData.inputData,solveType)} disabled={disableRun}>RUN</Button>
</div>
</Tooltip>
</Stack>
</Toolbar>

Expand Down
29 changes: 26 additions & 3 deletions electron/ui/src/views/FlowsheetConfig/FlowsheetConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import {useEffect, useState } from 'react';
import { useParams, useNavigate } from "react-router-dom";
import { getFlowsheet, saveFlowsheet, resetFlowsheet } from "../../services/flowsheet.service";
import { Dialog, DialogTitle, DialogActions, DialogContent } from '@mui/material'
import { Typography, CircularProgress, Tabs, Tab, Box, Grid, Container, Snackbar } from '@mui/material';
import { ToggleButton, ToggleButtonGroup, Dialog, DialogTitle, DialogActions, DialogContent } from '@mui/material'
import { Typography, CircularProgress, Tabs, Tab, Box, Grid, Container, Snackbar, Stack } from '@mui/material';
import Graph from "../../components/Graph/Graph";
import ConfigInput from "./ConfigInput/ConfigInput";
import ConfigOutput from "./ConfigOutput/ConfigOutput";
Expand Down Expand Up @@ -239,6 +239,30 @@ export default function FlowsheetConfig() {


<Grid container>
<Grid item xs={12}>
<Stack
direction="row"
justifyContent="left"
alignItems="left"
spacing={2}
>
<ToggleButtonGroup
orientation="horizontal"
value={solveType}
exclusive
onChange={handleToggleSolveType}
disabled={tabValue!==0}
>
<ToggleButton value="solve" aria-label="solve">
<Typography>Solve</Typography>
</ToggleButton>
<ToggleButton value="sweep" aria-label="sweep">
<Typography>Sweep</Typography>
</ToggleButton>
</ToggleButtonGroup>
</Stack>

</Grid>
<Grid item xs={12}>
<Tabs value={tabValue} onChange={handleTabChange} aria-label="process tabs">
<Tab label="Input" {...a11yProps(0)} />
Expand All @@ -254,7 +278,6 @@ export default function FlowsheetConfig() {
updateFlowsheetData={updateFlowsheetData}
reset={reset}
solveType={solveType}
handleToggleSolveType={handleToggleSolveType}
>
</ConfigInput>
</TabPanel>
Expand Down

0 comments on commit 9350ba8

Please sign in to comment.