fixing bug to make sure controller from other devices dont show as options for interactions when using the nodes on the bin svg

This commit is contained in:
csawatzky 2026-03-11 11:21:36 -06:00
parent 863f87da1c
commit c7016be6cd

View file

@ -290,11 +290,7 @@ export default function BinVisualizer(props: Props) {
const [modeChangeInProgress, setModeChangeInProgress] = useState(false) const [modeChangeInProgress, setModeChangeInProgress] = useState(false)
const [newGrainSettings, setNewGrainSettings] = useState<pond.GrainSettings>() const [newGrainSettings, setNewGrainSettings] = useState<pond.GrainSettings>()
const componentAPI = useComponentAPI() const [filteredComponents, setFilteredComponents] = useState<Component[]>([])
const [openControllerDIalog, setOpenControllerDialog] = useState(false)
const [controllerOutputStates, setControllerOutputStates] = useState<Map<string, number>>(new Map<string, number>())
const [selectedController, setSelectedController] = useState<Component>()
const [newOutputState, setNewOutputState] = useState()
useEffect(() => { useEffect(() => {
setModeTime(moment(bin.status.lastModeChange)); setModeTime(moment(bin.status.lastModeChange));
@ -1420,13 +1416,21 @@ export default function BinVisualizer(props: Props) {
coldestNodeTemp={valueDisplay === "low" ? lowNodeConditions?.tempC : undefined} coldestNodeTemp={valueDisplay === "low" ? lowNodeConditions?.tempC : undefined}
cableNodeClicked={(cable, fillNode) => { cableNodeClicked={(cable, fillNode) => {
if (cable) { if (cable) {
let devId = componentDevices?.get(cable.key()); let devId = componentDevices.get(cable.key());
if (devId) { if (devId) {
let device = devMap.get(devId); let device = devMap.get(devId);
if (device) { if (device) {
setSelectedCable(cable); setSelectedCable(cable);
setSelectedNode(fillNode); setSelectedNode(fillNode);
setCableDevice(device); setCableDevice(device);
//need to set the filtered components so that components on other devices do not show up as options in interaction settings
let filtered: Component[] = []
components.forEach((component, key) => {
if(componentDevices.get(key) === devId){
filtered.push(component)
}
})
setFilteredComponents(filtered)
setOpenNodeDialog(true); setOpenNodeDialog(true);
} }
} }
@ -1556,7 +1560,7 @@ export default function BinVisualizer(props: Props) {
let device = componentDevices.get(fan.key) let device = componentDevices.get(fan.key)
if(fanComp && device){ if(fanComp && device){
return ( return (
<BinControllerDisplay key={fanComp.key()} component={fanComp} deviceID={device} currentState/> <BinControllerDisplay key={fanComp.key()} component={fanComp} deviceID={device} currentState={fan.state}/>
) )
} }
})} })}
@ -2075,7 +2079,7 @@ export default function BinVisualizer(props: Props) {
{selectedCable && cableDevice && ( {selectedCable && cableDevice && (
<GrainNodeInteractions <GrainNodeInteractions
binKey={bin.key()} binKey={bin.key()}
interactionComponents={Array.from(components.values())} interactionComponents={filteredComponents}
grain={bin.grain()} grain={bin.grain()}
cable={selectedCable} cable={selectedCable}
open={openNodeDialog} open={openNodeDialog}