Skip to content

Commit

Permalink
fix unnecessary formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sufi Kaur committed Aug 19, 2024
1 parent effb659 commit 04b8c5c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 69 deletions.
18 changes: 8 additions & 10 deletions electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,12 @@ export default function ConfigInput(props) {
}

const handleUpdateDisplayValue = (id, value) => {
let tempFlowsheetData = { ...flowsheetData };
const inputs = getInputs(tempFlowsheetData);

console.debug('updating ' + id + ' with value ' + value + '. previous value was ' + inputs[id].value);
inputs[id].value = value;
setInputsChanged(true);
};
let tempFlowsheetData = {...flowsheetData}
const inputs = getInputs(tempFlowsheetData)
console.debug('updating ' + id + ' with value ' + value + '. previous value was ' + inputs[id].value)
inputs[id].value = value
setInputsChanged(true)
}

const handleUpdateFixed = (id, value, type) => {
let tempFlowsheetData = {...flowsheetData}
Expand Down Expand Up @@ -255,9 +254,8 @@ export default function ConfigInput(props) {
if (key === undefined || key === null) {
_key = key + Math.floor(Math.random() * 100001);
} else {
_key = key + value.display_name + value.output_variables;
_key = key + value.display_name + value.output_variables;
}

if (Object.keys(value.input_variables).length > 0) {
return (<Grid item xs={6} key={_key}>
<InputAccordion
Expand Down Expand Up @@ -361,7 +359,7 @@ export default function ConfigInput(props) {
flowsheetData={flowsheetData}
disableRun={disableRun}
solveType={solveType}
ref={runButtonRef}
ref={runButtonRef}
/>
</Stack>
</Grid>
Expand Down
20 changes: 9 additions & 11 deletions electron/ui/src/views/FlowsheetConfig/ConfigOutput/ConfigOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import SingleOutput from "../../../components/SingleOutput/SingleOutput";


export default function ConfigOutput(props) {
let params = useParams();
let params = useParams();
const {outputData, isSweep, inputsChanged} = props;

// Use a temporary hyperlink to download sweep output
const downloadSweepOutput = () => {
downloadSweepResults(params.id)
Expand All @@ -33,22 +33,20 @@ export default function ConfigOutput(props) {
// Return either sweep or single-output version
return (
<Box>
{inputsChanged ?
<Alert color = "warning" severity = 'warning' >
Inputs changed since last Run

</Alert> : <></>}
{inputsChanged ?
<Alert color="warning" severity='warning' >
Inputs changed since last run
</Alert> : <></>}
<Grid container spacing={2} alignItems="flex-start">
{isSweep ?
<SweepOutput outputData={outputData}
downloadOutput={downloadSweepOutput}/>
downloadOutput={downloadSweepOutput} />
:
<SingleOutput outputData={outputData}
downloadOutput={downloadSingleOutput}
saveConfig={saveConfig}/>
downloadOutput={downloadSingleOutput}
saveConfig={saveConfig} />
}
</Grid>
</Box>
);
}

85 changes: 37 additions & 48 deletions electron/ui/src/views/FlowsheetConfig/FlowsheetConfig.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//import './Page.css';
import React from 'react';
import { useEffect, useState } from 'react';
import { useParams, useNavigate, useLocation } from "react-router-dom";
import {useEffect, useState} from 'react';
import {useParams, useNavigate, useLocation} from "react-router-dom";
import {
getFlowsheet,
saveFlowsheet,
resetFlowsheet
} from "../../services/flowsheet.service";
import { Dialog, DialogTitle, DialogActions, DialogContent } from '@mui/material'
import {Dialog, DialogTitle, DialogActions, DialogContent} from '@mui/material'
import {
Typography,
CircularProgress,
Expand All @@ -16,7 +16,7 @@ import {
Box,
Grid,
Container,
Snackbar,
Snackbar
} from '@mui/material';
import Graph from "../../components/Graph/Graph";
import ConfigInput from "./ConfigInput/ConfigInput";
Expand Down Expand Up @@ -89,12 +89,7 @@ export default function FlowsheetConfig(props) {
const theme = props.theme;
console.log("flowsheet config theme=", theme);


const [inputsChanged, setInputsChanged] = useState(false);
// const [alteredInputs, setAlteredInputs] = useState([])

// const [dialogVisible, setDialogVisible] = useState(false);
// const [pendingPath, setPendingPath] = useState(null);

useEffect(() => {
console.log("params.id", params.id);
Expand Down Expand Up @@ -124,9 +119,9 @@ export default function FlowsheetConfig(props) {
setFlowsheetData({outputData: null, inputData: data, name: data.name});
setTitle(getTitle(data));
}).catch((e) => {
console.error('error getting flowsheet: ', e)
navigateHome(e)
});
console.error('error getting flowsheet: ', e)
navigateHome(e)
});
}, [params.id]);

useEffect(() => {
Expand All @@ -153,18 +148,19 @@ export default function FlowsheetConfig(props) {
setFlowsheetData({outputData: null, inputData: data, name: data.name});
setTitle(getTitle(data));
}).catch((e) => {
console.error('error getting flowsheet: ', e)
navigateHome(e)
});
console.error('error getting flowsheet: ', e)
navigateHome(e)
});
}

const navigateHome = (e) => {
navigate("/flowsheets", { replace: true, state: { error: e } })
navigate("/flowsheets", {replace: true, state: {error: e}})
}

const handleTabChange = (event, newValue) => {
setTabValue(newValue);
};
};


const getTitle = (data) => {
try {
Expand Down Expand Up @@ -236,26 +232,26 @@ export default function FlowsheetConfig(props) {
saveFlowsheet(params.id, data)
.then(response => {
if(response.status === 200) {
response.json()
response.json()
.then((data)=>{
let tempFlowsheetData = {...flowsheetData}
tempFlowsheetData.inputData = data
if (outputData) {
tempFlowsheetData.outputData = outputData
tempFlowsheetData.inputData = data
if (outputData) {
tempFlowsheetData.outputData = outputData

}
if (update) {
console.log("SETTING FLOWSHEET DATA")
setFlowsheetData(tempFlowsheetData)
}
});
}
if (update) {
console.log("SETTING FLOWSHEET DATA")
setFlowsheetData(tempFlowsheetData)
}
});
} else if(response.status === 400) {
console.error("error saving data")
handleError("Infeasible data, configuration not saved")
}

})

console.error("error saving data")
handleError("Infeasible data, configuration not saved")
}
})
};

const handleSuccessSaveConfirmationClose = () => {
Expand All @@ -276,9 +272,9 @@ export default function FlowsheetConfig(props) {
setFlowsheetData({outputData: null, inputData: data, name: data.name});
setTitle(getTitle(data));
}).catch((e) => {
console.error('error getting flowsheet: ', e)
navigateHome(e)
});
console.error('error getting flowsheet: ', e)
navigateHome(e)
});
}

const handleSelectSolveType = (event) => {
Expand All @@ -296,12 +292,12 @@ export default function FlowsheetConfig(props) {

const handleSaveConfiguration = () => {
if (analysisName.length > 0) {

} else {
setOpenErrorMessage(true)
setErrorMessage("Please provide a name for analysis.")
}
}
}

const formatOptionType = (option) => {
try {
Expand All @@ -311,13 +307,6 @@ export default function FlowsheetConfig(props) {
}
}

// useEffect(()=>{
// if(alteredInputs.length >= 1) {
// setInputsChanged(true)
// }

// }, [alteredInputs])

console.log("Returning container for FlowsheetConfig. build_options=", flowsheetData.inputData.build_options, "isBuilt=", isBuilt,
"loadingFlowsheetData=", loadingFlowsheetData);
return (
Expand Down Expand Up @@ -434,7 +423,7 @@ export default function FlowsheetConfig(props) {
isSweep={sweep}
solveType={solveType}
inputsChanged={inputsChanged}
>
>
</ConfigOutput>
</TabPanel>
<TabPanel value={tabValue} index={2}>
Expand All @@ -449,8 +438,8 @@ export default function FlowsheetConfig(props) {
)
}
<SolveDialog open={solveDialogOpen} handleSolved={handleSolved}
handleError={handleError} flowsheetData={flowsheetData}
id={params.id} isSweep={sweep}></SolveDialog>
handleError={handleError} flowsheetData={flowsheetData}
id={params.id} isSweep={sweep}></SolveDialog>
<Snackbar
open={openSuccessSaveConfirmation}
autoHideDuration={2000}
Expand Down

0 comments on commit 04b8c5c

Please sign in to comment.