added and all nodes option for the cards and graphs

This commit is contained in:
csawatzky 2026-05-29 12:03:56 -06:00
parent 99f37f7bda
commit c3ee4a518c
3 changed files with 141 additions and 39 deletions

View file

@ -1,5 +1,5 @@
import { AccessTime, MoreVert } from "@mui/icons-material";
import { Avatar, Box, Button, Card, Grid2, IconButton, Menu, MenuItem, Typography, useTheme } from "@mui/material";
import { Avatar, Box, Button, Card, Checkbox, FormControlLabel, Grid2, IconButton, Menu, MenuItem, Typography, useTheme } from "@mui/material";
import BinSensorCard from "bin/BinSensorCard";
import { GetDefaultDateRange } from "common/time/DateRange";
import { ExtractMoisture } from "grain";
@ -71,6 +71,7 @@ export default function BinSensorsDisplay(props: Props){
const defaultDateRange = GetDefaultDateRange();
const [startDate, setStartDate] = useState<Moment>(defaultDateRange.start);
const [endDate, setEndDate] = useState<Moment>(defaultDateRange.end);
const [filterNodes, setFilterNodes] = useState(true)
//organize the components into the correct 'positions' using the bins preferences
useEffect(()=>{
@ -303,21 +304,21 @@ export default function BinSensorsDisplay(props: Props){
const rows: { label: string; min: string; avg: string; max: string }[] = [
{
label: `Temp ${unit}`,
min: cable.minTemp(user.tempUnit()).toFixed(2),
avg: cable.aveTemp(user.tempUnit()).toFixed(2),
max: cable.maxTemp(user.tempUnit()).toFixed(2),
min: cable.minTemp(user.tempUnit(), filterNodes).toFixed(2),
avg: cable.aveTemp(user.tempUnit(), filterNodes).toFixed(2),
max: cable.maxTemp(user.tempUnit(), filterNodes).toFixed(2),
},
...(hasHumidity ? [{
label: "RH %",
min: cable.minHumidity().toFixed(2),
avg: cable.aveHumidity().toFixed(2),
max: cable.maxHumidity().toFixed(2),
min: cable.minHumidity(filterNodes).toFixed(2),
avg: cable.aveHumidity(filterNodes).toFixed(2),
max: cable.maxHumidity(filterNodes).toFixed(2),
}] : []),
...(hasMoisture ? [{
label: "EMC %",
min: cable.minMoisture().toFixed(2),
avg: cable.aveMoisture().toFixed(2),
max: cable.maxMoisture().toFixed(2),
min: cable.minMoisture(filterNodes).toFixed(2),
avg: cable.aveMoisture(filterNodes).toFixed(2),
max: cable.maxMoisture(filterNodes).toFixed(2),
}] : []),
]
@ -695,6 +696,20 @@ export default function BinSensorsDisplay(props: Props){
{showGraphs &&
<TimeBar updateDateRange={updateDateRange} startDate={startDate} endDate={endDate} />
}
{cables.length > 0 &&
<FormControlLabel
control={
<Checkbox
checked={!filterNodes}
onChange={(e, checked) => {
setFilterNodes(!filterNodes)
}}
/>
}
label={<Typography>Show All Nodes
</Typography>}
/>
}
</Box>
)
}
@ -718,11 +733,12 @@ export default function BinSensorsDisplay(props: Props){
<BinSensorGraph
icon={icon}
title={cable.name()}
tag={"Cable"}
tag={"Cable Averages"}
device={device}
component={cable.key()}
component={components.get(cable.key())!}
startDate={startDate}
endDate={endDate}
endDate={endDate}
allNodes={!filterNodes}
onMenuClick={(event) => {
setComponentUnnassigned(false);
setSelectedComponentType(cable.type());
@ -752,7 +768,7 @@ export default function BinSensorsDisplay(props: Props){
title={plenum.name()}
tag={"Plenum"}
device={device}
component={plenum.key()}
component={components.get(plenum.key())!}
startDate={startDate}
endDate={endDate}
onMenuClick={(event) => {
@ -783,7 +799,7 @@ export default function BinSensorsDisplay(props: Props){
title={pressure.name()}
tag={"Pressure"}
device={device}
component={pressure.key()}
component={components.get(pressure.key())!}
startDate={startDate}
endDate={endDate}
onMenuClick={(event) => {
@ -813,7 +829,7 @@ export default function BinSensorsDisplay(props: Props){
title={ambient.name()}
tag={"Ambient"}
device={device}
component={ambient.key()}
component={components.get(ambient.key())!}
startDate={startDate}
endDate={endDate}
onMenuClick={(event) => {
@ -844,7 +860,7 @@ export default function BinSensorsDisplay(props: Props){
title={h.name()}
tag={"Headspace"}
device={device}
component={h.key()}
component={components.get(h.key())!}
startDate={startDate}
endDate={endDate}
onMenuClick={(event) => {
@ -870,7 +886,7 @@ export default function BinSensorsDisplay(props: Props){
let icon = GetComponentIcon(co2.type(), co2.subType(), themeType)
return(
<Grid2 size={{xs: 6, sm: 6, md: 4, lg: 3}}>
<BinSensorGraph device={device} component={co2.key()} startDate={startDate} endDate={endDate} />
<BinSensorGraph device={device} component={components.get(co2.key())!} startDate={startDate} endDate={endDate} />
</Grid2>
)
}
@ -885,7 +901,7 @@ export default function BinSensorsDisplay(props: Props){
if(showGraphs && device){
return(
<Grid2 size={{xs: 6, sm: 6, md: 4, lg: 3}}>
<BinSensorGraph device={device} component={lidar.key()} startDate={startDate} endDate={endDate} />
<BinSensorGraph device={device} component={components.get(lidar.key())!} startDate={startDate} endDate={endDate} />
</Grid2>
)
}
@ -908,7 +924,7 @@ export default function BinSensorsDisplay(props: Props){
if(showGraphs && device){
return(
<Grid2 size={{xs: 6, sm: 6, md: 4, lg: 3}}>
<BinSensorGraph device={device} component={heater.key()} startDate={startDate} endDate={endDate} />
<BinSensorGraph device={device} component={components.get(heater.key())!} startDate={startDate} endDate={endDate} />
</Grid2>
)
}
@ -923,7 +939,7 @@ export default function BinSensorsDisplay(props: Props){
if(showGraphs && device){
return(
<Grid2 size={{xs: 6, sm: 6, md: 4, lg: 3}}>
<BinSensorGraph device={device} component={fan.key()} startDate={startDate} endDate={endDate} />
<BinSensorGraph device={device} component={components.get(fan.key())!} startDate={startDate} endDate={endDate} />
</Grid2>
)
}