using the expiry time in the gate status for whehter its missing or not

This commit is contained in:
csawatzky 2026-04-22 14:52:06 -06:00
parent f96d1184b1
commit 6565b854b6
5 changed files with 33 additions and 42 deletions

2
package-lock.json generated
View file

@ -11205,7 +11205,7 @@
}, },
"node_modules/protobuf-ts": { "node_modules/protobuf-ts": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#0aa61453c8641cf5ede545949a5f2f89f6c393ec", "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#29d9765ce93c04ad70d795b80e9873fc2fc5f600",
"dependencies": { "dependencies": {
"protobufjs": "^6.8.8" "protobufjs": "^6.8.8"
} }

View file

@ -20,6 +20,7 @@ interface Props {
ambient?: Component ambient?: Component
start: Moment; start: Moment;
end: Moment; end: Moment;
multiGraphZoom?: (domain: number[] | string[]) => void;
} }
export default function GateDeltaTempGraph(props: Props){ export default function GateDeltaTempGraph(props: Props){
@ -28,7 +29,8 @@ export default function GateDeltaTempGraph(props: Props){
ambient, ambient,
deviceID, deviceID,
start, start,
end end,
multiGraphZoom
} = props } = props
const [data, setData] = useState<SSAreaDataPoint[]>([]) const [data, setData] = useState<SSAreaDataPoint[]>([])
const [{user}] = useGlobalState() const [{user}] = useGlobalState()
@ -216,7 +218,8 @@ export default function GateDeltaTempGraph(props: Props){
tooltipUnit={user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C"} tooltipUnit={user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C"}
yAxisLabel={"Delta T" + (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C")} yAxisLabel={"Delta T" + (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C")}
colourAboveZero={{colour: warmingColour, label: "Heating"}} colourAboveZero={{colour: warmingColour, label: "Heating"}}
colourBelowZero={{colour: coolingColour, label: "Cooling"}}/> colourBelowZero={{colour: coolingColour, label: "Cooling"}}
multiGraphZoom={multiGraphZoom}/>
</Card> </Card>
) )

View file

@ -25,7 +25,6 @@ interface Props {
ambient?: string; ambient?: string;
newXDomain?: number[] | string[]; newXDomain?: number[] | string[];
pressureComponent?: string; pressureComponent?: string;
// setPCAState: (state: boolean) => void;
multiGraphZoom?: (domain: number[] | string[]) => void; multiGraphZoom?: (domain: number[] | string[]) => void;
} }
@ -55,7 +54,6 @@ export default function GateFlowGraph(props: Props) {
device, device,
ambient, ambient,
pressureComponent, pressureComponent,
// setPCAState,
start, start,
end, end,
newXDomain, newXDomain,
@ -132,15 +130,6 @@ export default function GateFlowGraph(props: Props) {
} }
}); });
setRuntime(moment.duration(runtime)); setRuntime(moment.duration(runtime));
// let state = false;
// if (
// data.length > 1 &&
// data[data.length - 1].value > gate.lowerFlow() &&
// data[data.length - 1].value < gate.upperFlow()
// ) {
// state = true;
// }
// setPCAState(state);
} }
setFlowData(data); setFlowData(data);
setLoadingChartData(false); setLoadingChartData(false);

View file

@ -101,19 +101,24 @@ export default function GateGraphs(props: Props) {
}); });
}, [gate, endDate, gateAPI, startDate, as]); // eslint-disable-line react-hooks/exhaustive-deps }, [gate, endDate, gateAPI, startDate, as]); // eslint-disable-line react-hooks/exhaustive-deps
const updateDateRange = (newStartDate: any, newEndDate: any) => { const updateDateRange = (newStartDate: moment.Moment, newEndDate: moment.Moment) => {
// let range = GetDefaultDateRange();
// range.start = newStartDate;
// range.end = newEndDate;
setStartDate(newStartDate); setStartDate(newStartDate);
setEndDate(newEndDate); setEndDate(newEndDate);
}; };
// const zoomOut = () => { const zoomGraphs = (domain: string[] | number[]) => {
// setXDomain(["dataMin", "dataMax"]); setZoomed(true)
if((domain[0] && !isNaN(parseInt(domain[0] as string))) && (domain[1] && !isNaN(parseInt(domain[1] as string)))){
updateDateRange(moment(domain[0]),moment(domain[1]))
}
}
// setZoomed(false); const zoomOut = () => {
// }; let d = GetDefaultDateRange()
setStartDate(d.start)
setEndDate(d.end)
setZoomed(false);
};
const lineGraph = ( const lineGraph = (
unitMeasurement: UnitMeasurement, unitMeasurement: UnitMeasurement,
@ -176,9 +181,7 @@ export default function GateGraphs(props: Props) {
tooltip tooltip
newXDomain={xDomain} newXDomain={xDomain}
multiGraphZoom={domain => { multiGraphZoom={domain => {
setXDomain(domain); zoomGraphs(domain)
setZoomed(true);
//set new start and end here as well
}} }}
multiGraphZoomOut multiGraphZoomOut
/> />
@ -241,9 +244,7 @@ export default function GateGraphs(props: Props) {
tooltip tooltip
newXDomain={xDomain} newXDomain={xDomain}
multiGraphZoom={domain => { multiGraphZoom={domain => {
setXDomain(domain); zoomGraphs(domain)
setZoomed(true);
//update the start and end here as well
}} }}
multiGraphZoomOut multiGraphZoomOut
/> />
@ -358,17 +359,8 @@ export default function GateGraphs(props: Props) {
gate={gate} gate={gate}
ambient={ambient} ambient={ambient}
pressureComponent={pressure} pressureComponent={pressure}
// setPCAState={(state: boolean) => {
// setPCAState(state);
// }}
multiGraphZoom={domain => { multiGraphZoom={domain => {
//need to update the dateRange here so that the graph re-loads data zoomGraphs(domain)
if(domain[0] && !isNaN(parseInt(domain[0] as string))){
setStartDate(moment(domain[0]))
}
if(domain[1] && !isNaN(parseInt(domain[1] as string))){
setEndDate(moment(domain[1]))
}
}} }}
/> />
{/* add a new chart here for the delta temp over time */} {/* add a new chart here for the delta temp over time */}
@ -379,7 +371,9 @@ export default function GateGraphs(props: Props) {
end={endDate} end={endDate}
tempComponent={tempComp} tempComponent={tempComp}
ambient={ambientComp} ambient={ambientComp}
multiGraphZoom={domain => {
zoomGraphs(domain)
}}
/> />
} }
</Box> </Box>
@ -401,13 +395,13 @@ export default function GateGraphs(props: Props) {
<React.Fragment> <React.Fragment>
<Box display="flex" justifyContent="space-between" alignItems="center" marginBottom={2}> <Box display="flex" justifyContent="space-between" alignItems="center" marginBottom={2}>
<TimeBar updateDateRange={updateDateRange} startDate={startDate} endDate={endDate} /> <TimeBar updateDateRange={updateDateRange} startDate={startDate} endDate={endDate} />
{/* {zoomed && ( {zoomed && (
<Tooltip title="Zoom Out Graphs"> <Tooltip title="Zoom Out Graphs">
<Button variant="outlined" onClick={zoomOut}> <Button variant="outlined" onClick={zoomOut}>
<ZoomOut /> <ZoomOut />
</Button> </Button>
</Tooltip> </Tooltip>
)} */} )}
</Box> </Box>
{loading ? <LinearProgress /> : showGraphs()} {loading ? <LinearProgress /> : showGraphs()}
</React.Fragment> </React.Fragment>

View file

@ -272,7 +272,12 @@ export default function GateList(props: Props) {
// cellStyle: {width: 100000}, // cellStyle: {width: 100000},
// sortKey: "state", // sortKey: "state",
render: gate => { render: gate => {
const deviceStateHelper = getDeviceStateHelper(gate.status.pcaDeviceState); let deviceStateHelper = getDeviceStateHelper(pond.DeviceState.DEVICE_STATE_UNKNOWN);
if(moment().isAfter(moment(gate.status.deviceStateExpires).add(1, 'hour'))){
deviceStateHelper = getDeviceStateHelper(pond.DeviceState.DEVICE_STATE_MISSING)
}else{
deviceStateHelper = getDeviceStateHelper(gate.status.pcaDeviceState)
}
return ( return (
<Box className={classes.cellContainer}> <Box className={classes.cellContainer}>
<Tooltip title={deviceStateHelper.description}>{deviceStateHelper.icon}</Tooltip> <Tooltip title={deviceStateHelper.description}>{deviceStateHelper.icon}</Tooltip>