updated the node dialog on the bin page to allow for excluding nodes from there

This commit is contained in:
csawatzky 2025-08-01 11:32:34 -06:00
parent 03ab16614d
commit 06df78c5fe
2 changed files with 44 additions and 26 deletions

View file

@ -91,6 +91,7 @@ export default function GrainNodeInteractions(props: Props) {
const humDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_PERCENT);
const moistureDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_GRAIN_EMC);
const [topNode, setTopNode] = useState(false);
const [excluded, setExcluded] = useState(false);
const componentAPI = useComponentAPI();
const interactionAPI = useInteractionsAPI();
const binAPI = useBinAPI();
@ -131,6 +132,13 @@ export default function GrainNodeInteractions(props: Props) {
} else {
setTopNode(false);
}
//determine if the node is excluded
if (cable.excludedNodes.includes(displayNode - 1)){
setExcluded(true)
}else{
setExcluded(false)
}
}, [cable, displayNode]);
const goToComponent = () => {
@ -167,6 +175,7 @@ export default function GrainNodeInteractions(props: Props) {
.then(resp => {})
.catch(err => {});
});
updateComponentCallback(cable.key())
})
.catch(err => {
openSnack("Failed to update component");
@ -204,6 +213,15 @@ export default function GrainNodeInteractions(props: Props) {
setTopNode(checked);
};
const updateNodeExclusion = (checked: boolean) => {
if (checked) {
cable.settings.excludedNodes.push(selectedNode-1)
} else {
cable.settings.excludedNodes.splice(cable.settings.excludedNodes.indexOf(selectedNode - 1), 1)
}
setExcluded(checked)
}
const displayTemp = () => {
let tempFinal = nodeTemp ?? 0;
if (user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
@ -312,15 +330,38 @@ export default function GrainNodeInteractions(props: Props) {
);
};
const fillNodeSet = () => {
const nodeControl = () => {
return (
<Box style={{ marginTop: 10 }}>
<Typography style={{ fontSize: 20, fontWeight: 650 }}>Top Node Control</Typography>
<Typography style={{ fontSize: 20, fontWeight: 650 }}>Node Control</Typography>
<FormControlLabel
style={{ marginTop: 10 }}
control={
<Checkbox
checked={excluded}
onChange={e => {
updateNodeExclusion(e.target.checked);
}}
name="excludedNode"
/>
}
label={
<React.Fragment>
<Typography style={{ fontSize: 15, fontWeight: 650 }}>
Exclude Node
</Typography>
<Typography style={{ fontSize: 15 }}>
If checked this will set the node to be disabled and will not be used for any calculations done for the bin
</Typography>
</React.Fragment>
}
/>
<FormControlLabel
style={{ marginTop: 10 }}
control={
<Checkbox
checked={topNode}
disabled={excluded}
onChange={e => {
updateTopNode(e.target.checked);
}}
@ -418,7 +459,7 @@ export default function GrainNodeInteractions(props: Props) {
</DialogTitle>
<DialogContent>
{latestReading()}
{fillNodeSet()}
{nodeControl()}
{interactionDisplay()}
</DialogContent>
<DialogActions>