diff --git a/package-lock.json b/package-lock.json index 0e25c26..e347c77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10953,7 +10953,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#3f647071f211c4552c2acc23a8ecabb6904a4156", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#75f64f81d9b4ba7639d9978af37c361fca34c279", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/src/app/UserWrapper.tsx b/src/app/UserWrapper.tsx index cb4cdf8..110439c 100644 --- a/src/app/UserWrapper.tsx +++ b/src/app/UserWrapper.tsx @@ -12,6 +12,7 @@ import { makeStyles } from '@mui/styles' import { CssBaseline, Theme } from '@mui/material' import { AppThemeProvider } from 'theme/AppThemeProvider' import HTTPProvider from 'providers/http' +import { useSnackbar } from 'hooks' // import FirmwareLoader from './FirmwareLoader' const reducer = (state: GlobalState, action: GlobalStateAction): GlobalState => { @@ -64,6 +65,7 @@ export default function UserWrapper(props: Props) { const useAuth = useAuth0(); const hasFetched = useRef(false); const [global, setGlobal] = useState(undefined) + const snackbar = useSnackbar() const user_id = or(useAuth.user?.sub, "") @@ -81,7 +83,8 @@ export default function UserWrapper(props: Props) { backgroundTasksComplete: false, firmware: new Map() }) - }).catch(() => { + }).catch((err) => { + snackbar.error("get user and team: "+err) userAPI.getUser(user_id).then(user => { setGlobal({ user: user ? user : User.create(), @@ -92,7 +95,8 @@ export default function UserWrapper(props: Props) { backgroundTasksComplete: false, firmware: new Map() }) - }).catch(() => { + }).catch((err) => { + snackbar.error("get user: "+err) setGlobal(globalDefault) }) diff --git a/src/bin/BinCardV2.tsx b/src/bin/BinCardV2.tsx index a4afc33..b4b465c 100644 --- a/src/bin/BinCardV2.tsx +++ b/src/bin/BinCardV2.tsx @@ -200,25 +200,27 @@ export default function BinCard(props: Props) { const typeDisplay = () => { let grainType = bin.settings.inventory?.grainType ?? pond.Grain.GRAIN_NONE; - if (bin.storage() === pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN) { - return ( - - - {GrainDescriber(grainType).name} - - - {bin.settings.inventory?.grainSubtype} - - + switch (bin.storage()){ + case pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN: + return ( + + + {GrainDescriber(grainType).name} + + + {bin.settings.inventory?.grainSubtype} + + + ) + default: + return ( + + + {bin.grainName()} + + ); } - return ( - - - {bin.settings.inventory?.customTypeName} - - - ); }; const tempDisplay = () => { @@ -417,6 +419,7 @@ export default function BinCard(props: Props) { hottestNodeTemp={valDisplay === "high" ? hotNode?.temp : undefined} coldestNodeTemp={valDisplay === "low" ? coldNode?.temp : undefined} inventoryControl={bin.inventoryControl()} + customGrain={bin.customGrain()} /> diff --git a/src/bin/BinConditioningCard.tsx b/src/bin/BinConditioningCard.tsx index cf3b3aa..8caac52 100644 --- a/src/bin/BinConditioningCard.tsx +++ b/src/bin/BinConditioningCard.tsx @@ -39,11 +39,12 @@ interface Props { heaters?: Controller[]; fans?: Controller[]; grain?: pond.Grain; + customGrain?: pond.GrainSettings } export default function BinConditioningCard(props: Props) { const classes = useStyles(); - const { interactions, interactionDevices, plenums, ambients, heaters, fans, grain, mode } = props; + const { interactions, interactionDevices, plenums, ambients, heaters, fans, grain, mode, customGrain } = props; const [sourceMap, setSourceMap] = useState>(new Map()); const [sinkMap, setSinkMap] = useState>(new Map()); @@ -87,6 +88,7 @@ export default function BinConditioningCard(props: Props) { sink={sink} source={source} grain={grain} + customGrain={customGrain} /> ); } diff --git a/src/bin/BinConditioningInteraction.tsx b/src/bin/BinConditioningInteraction.tsx index 7fe8bea..bd6c3c7 100644 --- a/src/bin/BinConditioningInteraction.tsx +++ b/src/bin/BinConditioningInteraction.tsx @@ -84,10 +84,11 @@ interface Props { source: Component; sink: Component; grain?: pond.Grain; + customGrain?: pond.GrainSettings } export default function BinConditioningInteraction(props: Props) { - const { interaction, source, sink, grain, deviceId } = props; + const { interaction, source, sink, grain, deviceId, customGrain } = props; const [sliderVals, setSliderVals] = useState>(new Map()); const [sliderMarks, setSliderMarks] = useState>(new Map()); //this is the emc value calculated from the interactions temp and humidity conditions @@ -127,7 +128,6 @@ export default function BinConditioningInteraction(props: Props) { if ( grain !== undefined && grain !== pond.Grain.GRAIN_INVALID && - grain !== pond.Grain.GRAIN_CUSTOM && temp && hum ) { @@ -135,8 +135,9 @@ export default function BinConditioningInteraction(props: Props) { //the emc calc needs the temp to be in celsius temp = fahrenheitToCelsius(temp); } - let emc = ExtractMoisture(grain, temp, hum); - setBaseEMC(emc); + let emc = ExtractMoisture(grain, temp, hum, customGrain) + setBaseEMC(emc === hum ? undefined : emc); + } }, [sliderVals, grain]); diff --git a/src/bin/BinSVGV2.tsx b/src/bin/BinSVGV2.tsx index f3c3454..ecbeb53 100644 --- a/src/bin/BinSVGV2.tsx +++ b/src/bin/BinSVGV2.tsx @@ -147,6 +147,7 @@ interface Props { hottestNodeTemp?: number; coldestNodeTemp?: number; inventoryControl?: pond.BinInventoryControl; + customGrain?: pond.GrainSettings; } interface GrainNodePoint { @@ -211,7 +212,8 @@ export default function BinSVGV2(props: Props) { hottestNodeTemp, coldestNodeTemp, inventoryControl, - co2Sensors + co2Sensors, + customGrain } = props; const [{ user }] = useGlobalState(); const [extraDetails, setExtraDetails] = useState<"temps" | "hums">("temps"); @@ -683,7 +685,7 @@ export default function BinSVGV2(props: Props) { x: cablePos, y: nodeY + 10, stroke: "green", - value: ExtractMoisture(props.grainType, temp, cable.humidities[index] ?? 0).toFixed(1)+"%", + value: ExtractMoisture(props.grainType, temp, cable.humidities[index] ?? 0, customGrain).toFixed(1)+"%", }) !showTempHum && nodeClickData.push({ diff --git a/src/bin/BinSettings.tsx b/src/bin/BinSettings.tsx index 61389f9..4192974 100644 --- a/src/bin/BinSettings.tsx +++ b/src/bin/BinSettings.tsx @@ -65,6 +65,7 @@ import { getDistanceUnit, or, getTemperatureUnit, getGrainUnit } from "utils"; import { makeStyles } from "@mui/styles"; import { useNavigate } from "react-router-dom"; import BinSelector from "./BinSelector"; +import CustomGrainSelector from "grain/CustomGrainSelector"; // import BinSelector from "./BinSelector"; const useStyles = makeStyles((theme: Theme) => { @@ -205,6 +206,7 @@ export default function BinSettings(props: Props) { const libracartAPI = useLibraCartProxyAPI() const [lcDestination, setlcDestination] = useState