finished the refactoring of the bin mode change to allow for more components to be selected
This commit is contained in:
parent
70bd91bbe7
commit
3df6db8a01
6 changed files with 350 additions and 272 deletions
|
|
@ -7,11 +7,9 @@ import {
|
|||
darken,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
Grid2 as Grid,
|
||||
IconButton,
|
||||
InputAdornment,
|
||||
lighten,
|
||||
Link,
|
||||
Skeleton,
|
||||
|
|
@ -19,8 +17,6 @@ import {
|
|||
Switch,
|
||||
TextField,
|
||||
Theme,
|
||||
ToggleButton,
|
||||
ToggleButtonGroup,
|
||||
Typography,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
|
|
@ -31,8 +27,8 @@ import HumidityIcon from "component/HumidityIcon";
|
|||
import TemperatureIcon from "component/TemperatureIcon";
|
||||
import GrainDescriber, { GrainOptions, ToGrainOption } from "grain/GrainDescriber";
|
||||
import useViewport from "hooks/useViewport";
|
||||
import { cloneDeep, round } from "lodash";
|
||||
import { Bin, Component, Device, Interaction } from "models";
|
||||
import { round } from "lodash";
|
||||
import { Bin, Component, Device } from "models";
|
||||
import { GetComponentIcon } from "pbHelpers/ComponentType";
|
||||
import { describeMeasurement } from "pbHelpers/MeasurementDescriber";
|
||||
import { useMobile } from "hooks";
|
||||
|
|
@ -49,7 +45,6 @@ import { useBinAPI } from "providers/pond/binAPI";
|
|||
import BindaptIcon from "products/Bindapt/BindaptIcon";
|
||||
import {
|
||||
AccessTime,
|
||||
ArrowForward,
|
||||
ArrowForwardIos,
|
||||
CheckCircleOutline,
|
||||
Error,
|
||||
|
|
@ -59,7 +54,6 @@ import {
|
|||
TrendingUp,
|
||||
Warning
|
||||
} from "@mui/icons-material";
|
||||
import DevicePresetsFromPicker from "device/DevicePresetsFromPicker";
|
||||
import { Plenum } from "models/Plenum";
|
||||
import { Pressure } from "models/Pressure";
|
||||
import { GrainCable } from "models/GrainCable";
|
||||
|
|
@ -73,7 +67,7 @@ import { Ambient } from "models/Ambient";
|
|||
import { ExtractMoisture } from "grain";
|
||||
import SearchSelect, { Option } from "common/SearchSelect";
|
||||
import Edit from "@mui/icons-material/Edit";
|
||||
import { makeStyles, styled } from "@mui/styles";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import ButtonGroup from "common/ButtonGroup";
|
||||
import ModeChangeDialog from "./conditioning/modeChangeDialog";
|
||||
|
||||
|
|
@ -191,8 +185,6 @@ interface Props {
|
|||
ambient?: Ambient;
|
||||
cables?: GrainCable[];
|
||||
pressures?: Pressure[];
|
||||
interactions?: Interaction[];
|
||||
//changeBinMode: (binMode: pond.BinMode) => boolean;
|
||||
refresh: (showSnack?: boolean) => void;
|
||||
afterUpdate?(): void;
|
||||
preferences?: Map<string, pond.BinComponentPreferences>;
|
||||
|
|
@ -204,8 +196,6 @@ interface Props {
|
|||
export default function BinVisualizer(props: Props) {
|
||||
const {
|
||||
bin,
|
||||
//changeBinMode,
|
||||
//changeGrainAmount,
|
||||
plenums,
|
||||
ambient,
|
||||
pressures,
|
||||
|
|
@ -216,7 +206,6 @@ export default function BinVisualizer(props: Props) {
|
|||
preferences,
|
||||
componentDevices,
|
||||
permissions,
|
||||
//interactions,
|
||||
refresh,
|
||||
updateComponentCallback,
|
||||
binPresets
|
||||
|
|
@ -243,9 +232,9 @@ export default function BinVisualizer(props: Props) {
|
|||
const pressColour = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE).colour();
|
||||
const emcColour = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_GRAIN_EMC).colour();
|
||||
// const [showInputMoisture, setShowInputMoisture] = useState<boolean>(false);
|
||||
const [moistureInput, setMoistureInput] = useState<string>("");
|
||||
const [tempInput, setTempInput] = useState<string>("");
|
||||
const [outdoorHumidityInput, setOutdoorHumidityInput] = useState<string>("");
|
||||
const [targetMoisture, setTargetMoisture] = useState(0);
|
||||
const [outdoorTemp, setOutdoorTemp] = useState(0);
|
||||
const [outdoorHumidity, setOutdoorHumidity] = useState(0);
|
||||
const [modeTime, setModeTime] = useState<Moment>(moment());
|
||||
const [grainUpdate, setGrainUpdate] = useState<boolean>(false);
|
||||
const [openStorageTime, setOpenStorageTime] = useState(false);
|
||||
|
|
@ -331,7 +320,7 @@ export default function BinVisualizer(props: Props) {
|
|||
setStorageType(bin.storage());
|
||||
// setNewPreset(pond.BinMode.BIN_MODE_NONE);
|
||||
if (bin.settings.inventory) {
|
||||
setMoistureInput(bin.settings.inventory.initialMoisture.toString());
|
||||
setTargetMoisture(bin.settings.inventory.initialMoisture);
|
||||
setCustomTypeName(bin.settings.inventory.customTypeName);
|
||||
setGrainType(bin.settings.inventory.grainType);
|
||||
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
|
||||
|
|
@ -344,9 +333,9 @@ export default function BinVisualizer(props: Props) {
|
|||
if (user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
t = CtoF(t);
|
||||
}
|
||||
setTempInput(t.toString());
|
||||
setOutdoorTemp(t);
|
||||
}
|
||||
if (bin.settings) setOutdoorHumidityInput(bin.settings.outdoorHumidity.toString());
|
||||
if (bin.settings) setOutdoorHumidity(bin.settings.outdoorHumidity);
|
||||
}, [bin, user]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -774,7 +763,7 @@ export default function BinVisualizer(props: Props) {
|
|||
setIsCustomInventory(bin.storage() !== pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN);
|
||||
setStorageType(bin.storage());
|
||||
if (bin.settings.inventory) {
|
||||
setMoistureInput(bin.settings.inventory.initialMoisture.toString());
|
||||
setTargetMoisture(bin.settings.inventory.initialMoisture);
|
||||
setCustomTypeName(bin.settings.inventory.customTypeName);
|
||||
setGrainType(bin.settings.inventory.grainType);
|
||||
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
|
||||
|
|
@ -1960,83 +1949,6 @@ export default function BinVisualizer(props: Props) {
|
|||
setOpenModeChange(true)
|
||||
};
|
||||
|
||||
// const closeMoistureDialog = () => {
|
||||
// // setNewPreset(0);
|
||||
// setNewBinMode(bin.settings.mode);
|
||||
// setShowInputMoisture(false);
|
||||
// };
|
||||
|
||||
// const moistureDialog = () => {
|
||||
// return (
|
||||
// <ResponsiveDialog open={showInputMoisture} onClose={closeMoistureDialog}>
|
||||
// <DialogTitle>Input new grain moisture</DialogTitle>
|
||||
// <DialogContent>
|
||||
// <DialogContentText style={{ paddingBottom: theme.spacing(0) }}>
|
||||
// Updating the current grain moisture will calibrate the estimate for more accurate
|
||||
// results. The outdoor temperature will have some effect on the estimate as well; consider
|
||||
// updating with drastic changes in the weather or using a predicted average.
|
||||
// </DialogContentText>
|
||||
// <TextField
|
||||
// label={"Grain Moisture"}
|
||||
// value={moistureInput}
|
||||
// onChange={event => setMoistureInput(event.target.value)}
|
||||
// InputProps={{
|
||||
// endAdornment: <InputAdornment position="end">%</InputAdornment>
|
||||
// }}
|
||||
// style={{ marginTop: theme.spacing(2) }}
|
||||
// fullWidth
|
||||
// variant="outlined"
|
||||
// />
|
||||
// <Typography variant="body1" style={{ marginTop: theme.spacing(2) }}>
|
||||
// Weather
|
||||
// </Typography>
|
||||
// <TextField
|
||||
// label={"Outdoor Temperature"}
|
||||
// value={tempInput}
|
||||
// onChange={event => setTempInput(event.target.value)}
|
||||
// InputProps={{
|
||||
// endAdornment: (
|
||||
// <InputAdornment position="end">
|
||||
// {getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
// ? "°F"
|
||||
// : "℃"}
|
||||
// </InputAdornment>
|
||||
// )
|
||||
// }}
|
||||
// style={{ marginTop: theme.spacing(2) }}
|
||||
// fullWidth
|
||||
// variant="outlined"
|
||||
// />
|
||||
// <TextField
|
||||
// label={"Outdoor Humidity"}
|
||||
// value={outdoorHumidityInput}
|
||||
// onChange={event => setOutdoorHumidityInput(event.target.value)}
|
||||
// InputProps={{
|
||||
// endAdornment: <InputAdornment position="end">%</InputAdornment>
|
||||
// }}
|
||||
// style={{ marginTop: theme.spacing(2) }}
|
||||
// fullWidth
|
||||
// variant="outlined"
|
||||
// />
|
||||
// </DialogContent>
|
||||
// <DialogActions>
|
||||
// <Button
|
||||
// onClick={() => {
|
||||
// // setNewPreset(0);
|
||||
// setNewBinMode(bin.settings.mode);
|
||||
// setShowInputMoisture(false);
|
||||
// }}
|
||||
// color="primary">
|
||||
// Cancel
|
||||
// </Button>
|
||||
// <Button onClick={setModeConditioning} color="primary">
|
||||
// Update
|
||||
// </Button>
|
||||
// </DialogActions>
|
||||
// </ResponsiveDialog>
|
||||
// );
|
||||
// };
|
||||
|
||||
if (loading) {
|
||||
return <Skeleton variant="rectangular" height={460} />;
|
||||
}
|
||||
|
|
@ -2046,7 +1958,7 @@ export default function BinVisualizer(props: Props) {
|
|||
b.settings.storage = storageType;
|
||||
if (b.settings.inventory) {
|
||||
if (b.settings.inventory.initialMoisture)
|
||||
b.settings.inventory.initialMoisture = Number(moistureInput);
|
||||
b.settings.inventory.initialMoisture = targetMoisture;
|
||||
//update all the grain stuff
|
||||
b.settings.inventory.grainType = grainType;
|
||||
b.settings.inventory.customTypeName = customTypeName;
|
||||
|
|
@ -2057,14 +1969,14 @@ export default function BinVisualizer(props: Props) {
|
|||
}
|
||||
|
||||
if (b.settings.outdoorTemp !== undefined) {
|
||||
let t = Number(tempInput);
|
||||
let t = outdoorTemp;
|
||||
if (user.settings.temperatureUnit === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
t = FtoC(Number(tempInput));
|
||||
t = FtoC(outdoorTemp);
|
||||
}
|
||||
b.settings.outdoorTemp = t;
|
||||
}
|
||||
if (b.settings.outdoorHumidity !== undefined)
|
||||
b.settings.outdoorHumidity = Number(outdoorHumidityInput);
|
||||
b.settings.outdoorHumidity = outdoorHumidity;
|
||||
|
||||
if (b.settings.mode != newBinMode){
|
||||
if(b.settings.inventory){
|
||||
|
|
@ -2080,26 +1992,10 @@ export default function BinVisualizer(props: Props) {
|
|||
|
||||
return (
|
||||
<Card raised className={classes.cardContent}>
|
||||
{/* {moistureDialog()} */}
|
||||
{cfmLowDialog()}
|
||||
{cfmHighDialog()}
|
||||
{changeGrain()}
|
||||
{storageTimeDialog()}
|
||||
{/* <DevicePresetsFromPicker
|
||||
preferences={preferences}
|
||||
binKey={bin.key()}
|
||||
devices={devices}
|
||||
refreshCallback={success => {
|
||||
setShowInputMoisture(false);
|
||||
setNewPreset(0)
|
||||
if (success) updateBin();
|
||||
}}
|
||||
parentPreset={newPreset}
|
||||
grain={bin.settings.inventory?.grainType}
|
||||
binCables={cables}
|
||||
compDevMap={componentDevices}
|
||||
presets={binPresets}
|
||||
/> */}
|
||||
<ModeChangeDialog
|
||||
binKey={bin.key()}
|
||||
binMode={newBinMode}
|
||||
|
|
@ -2107,18 +2003,32 @@ export default function BinVisualizer(props: Props) {
|
|||
devices={devices}
|
||||
open={openModeChange}
|
||||
binCables={cables}
|
||||
presets={binPresets}
|
||||
compDevMap={componentDevices}
|
||||
preferences={preferences}
|
||||
onClose={(refresh) => {
|
||||
setOpenModeChange(false)
|
||||
if(refresh) updateBin();
|
||||
}}
|
||||
defaultTargetMoisture={bin.settings.inventory?.initialMoisture}
|
||||
// defaultOutdoorTemp={get this from any ambient sensors}
|
||||
// defaultOutdoorHumidity={get this from any ambient sensors}
|
||||
changeTargetMoisture={newMoisture => {
|
||||
setTargetMoisture(newMoisture)
|
||||
}}
|
||||
changeOutdoorTemp={newTemp => {
|
||||
setOutdoorTemp(newTemp)
|
||||
}}
|
||||
changeOutdoorHumidity={newHumidity => {
|
||||
setOutdoorHumidity(newHumidity)
|
||||
}}
|
||||
startChange={() => {
|
||||
setModeChangeInProgress(true)
|
||||
}}
|
||||
changeComplete={() => {
|
||||
setModeChangeInProgress(false)
|
||||
}}
|
||||
|
||||
/>
|
||||
<Box paddingRight={1}>
|
||||
{binMode()}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue