diff --git a/src/gate/GateList.tsx b/src/gate/GateList.tsx index cd316c4..e864980 100644 --- a/src/gate/GateList.tsx +++ b/src/gate/GateList.tsx @@ -19,6 +19,7 @@ import { UnitMeasurement } from "models/UnitMeasurement"; import { quack } from "protobuf-ts/quack"; import { getTemperatureUnit } from "utils"; import { teal } from "@mui/material/colors"; +import { react } from "@babel/types"; interface Props { //gates: Gate[]; @@ -123,6 +124,15 @@ export default function GateList(props: Props) { color = measurement.colour } }) + + if(isMobile){ + return ( + + {outletDisplay} + {timeSince} + + ) + } return ( @@ -137,6 +147,38 @@ export default function GateList(props: Props) { ) } + const tempDisplay = (gate: Gate) => { + let display = "--" + if(gate.status.pcaState !== pond.PCAState.PCA_STATE_OFF){ + //only display it if the final temp is between -4 and 60 C, is a valid number, and is not exactly 0 + //0 is technically a valid number but the likely hood of the calculation being exactly 0 is negligible + if (gate.status.finalTemp < 60 && gate.status.finalTemp > -40 && !isNaN(gate.status.finalTemp) && gate.status.finalTemp !== 0){ + display = getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? CtoF(gate.status.finalTemp).toFixed(2) + "°F" : gate.status.finalTemp.toFixed(2) + "°C" + } + } + return ( + + {display} + + ) + } + + const conditionDisplay = (gate: Gate) => { + let display = "" + if(gate.status.pcaState === pond.PCAState.PCA_STATE_OFF){ + display = "Inactive" + } else if (gate.status.pcaState === pond.PCAState.PCA_STATE_UNKNOWN){ + display = "--" + } else { + display = gate.status.heating ? "Heating" : "Cooling" + } + return ( + + {display} + + ) + } + const CtoF = (celsius: number) => { return Math.round((celsius * (9 / 5) + 32) * 100) / 100; }; @@ -174,40 +216,21 @@ export default function GateList(props: Props) { { title: "Conditioning", render: gate => { - let display = "" - if(gate.status.pcaState === pond.PCAState.PCA_STATE_OFF){ - display = "Inactive" - } else if (gate.status.pcaState === pond.PCAState.PCA_STATE_UNKNOWN){ - display = "--" - } else { - display = gate.status.heating ? "Heating" : "Cooling" - } return ( - - {display} - + {conditionDisplay(gate)} )} }, { title: "Estimated Temp", render: gate => { - let display = "--" - if(gate.status.pcaState !== pond.PCAState.PCA_STATE_OFF){ - //only display it if the final temp is between -4 and 60 C, is a valid number, and is not exactly 0 - //0 is technically a valid number but the likely hood of the calculation being exactly 0 is negligible - if (gate.status.finalTemp < 60 && gate.status.finalTemp > -40 && !isNaN(gate.status.finalTemp) && gate.status.finalTemp !== 0){ - display = getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? CtoF(gate.status.finalTemp).toFixed(2) + "°F" : gate.status.finalTemp.toFixed(2) + "°C" - } - } return ( - - - {display} - - - )} + + {tempDisplay(gate)} + + ) + } }, { title: "Last FLow", @@ -271,28 +294,25 @@ export default function GateList(props: Props) { {terminalMap.get(gate.terminal()) ?? "None"} - Duct Type: - {gate.ductName() !== "" ? gate.ductName() : "None"} + Conditioning: + {conditionDisplay(gate)} - Duct Size(mm): - {gate.ductDiameter()} - - - DuctLength(m): - {gate.ductLength()} - - - PCA Unit: - {gate.settings.pcaType !== "" ? gate.settings.pcaType : "None"} + Estimated Temp: + {tempDisplay(gate)} Last Flow: - {gate.status.lastMassAirflow} + {gate.status.lastMassAirflow.toFixed(2)} kg/s + {gate.status.lastUpdate !== "" ? moment(gate.status.lastUpdate).fromNow() : "No PCA reading yet"} - Last Reading: - {gate.status.lastUpdate !== "" ? moment(gate.status.lastUpdate).fromNow() : "No PCA reading yet"} + Outlet Temp: + {lastOutletReading(gate.status.lastTempReading)} + + + Outlet Pressure: + {lastOutletReading(gate.status.lastPressureReading)} //