diff --git a/src/bin/BinSettings.tsx b/src/bin/BinSettings.tsx index 345812e..e540b20 100644 --- a/src/bin/BinSettings.tsx +++ b/src/bin/BinSettings.tsx @@ -47,10 +47,10 @@ import { RadiansToDegrees, TriangleOppositeLength } from "common/TrigFunctions"; -// import FanPicker from "fans/fanPicker"; +import FanPicker from "fans/fanPicker"; import { GrainOptions, ToGrainOption } from "grain"; import GrainDescriber from "grain/GrainDescriber"; -// import GrainTransaction from "grain/GrainTransaction"; +import GrainTransaction from "grain/GrainTransaction"; import { GetGrainUseOptions, ToGrainUseOption } from "grain/GrainUse"; import { useMobile, useSnackbar } from "hooks"; import { clone, cloneDeep } from "lodash"; @@ -450,7 +450,6 @@ export default function BinSettings(props: Props) { form.lowTemp = lowTempC; form.autoGrainNode = autoTopNode; if (form.inventory) form.inventory.inventoryControl = inventoryControl; - binAPI .updateBin(bin.key(), form) .then(response => { @@ -473,19 +472,18 @@ export default function BinSettings(props: Props) { newBin.settings.inventory.grainBushels = bin.settings.inventory?.grainBushels ?? 0; //but also need to use the old inventory amount so the diff is applied correctly } return ( - // { - // setGrainUpdate(false); - // setGrainDiff(0); - // }} - // callback={() => { - // close(true); - // }} - // /> - null + { + setGrainUpdate(false); + setGrainDiff(0); + }} + callback={() => { + close(true); + }} + /> ); } }; @@ -839,7 +837,6 @@ export default function BinSettings(props: Props) { row value={inventoryControl} onChange={(_, value) => { - console.log(value); setInventoryControl(+value); }}> { return ( - // { - // if (fanId !== undefined) { - // //set the fan id in the bin settings form - // form.fanId = fanId; - // //remove the old fan from the bin - // form.fan = null; - // } - // }} - // fanID={form.fanId} - // useCardView - // /> - null + { + if (fanId !== undefined) { + //set the fan id in the bin settings form + form.fanId = fanId; + //remove the old fan from the bin + form.fan = null; + } + }} + fanID={form.fanId} + useCardView + /> ); }; diff --git a/src/component/ComponentForm.tsx b/src/component/ComponentForm.tsx index 0f477b6..7b7b406 100644 --- a/src/component/ComponentForm.tsx +++ b/src/component/ComponentForm.tsx @@ -30,6 +30,7 @@ import { extension, getMeasurements, hasDimensions, + hasFan, isController, isMultiSensor, primaryMeasurement @@ -45,6 +46,7 @@ import { makeStyles } from "@mui/styles"; import { getDistanceUnit } from "utils"; import { GrainOptions } from "grain"; import CompModes from "component/ComponentMode.json"; +import FanPicker from "fans/fanPicker"; const useStyles = makeStyles((theme: Theme) => { return ({ @@ -874,8 +876,8 @@ export default function ComponentForm(props: Props) { disabled={!canEdit} /> {/* TODO-CS: Change this to have a parameter in the extensions that gets checked rather then checking for the component type */} - {/*hasFan(component.type()) && (*/} - {/* { component.settings.fanId = fanID; @@ -890,8 +892,8 @@ export default function ComponentForm(props: Props) { ); } }} - /> */} - {/* )} */} + /> + )} {component.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE && grainSelect()} {component.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE && ( diff --git a/src/models/Transaction.ts b/src/models/Transaction.ts new file mode 100644 index 0000000..b5d3804 --- /dev/null +++ b/src/models/Transaction.ts @@ -0,0 +1,19 @@ +import { cloneDeep } from "lodash"; +import { pond } from "protobuf-ts/pond"; +import { or } from "utils/types"; + +export class Transaction { + public transaction: pond.Transaction = pond.Transaction.create(); + + public static create(pb?: pond.Transaction): Transaction { + let my = new Transaction(); + if (pb) { + my.transaction = pond.Transaction.fromObject(cloneDeep(or(pb, {}))); + } + return my; + } + + public static any(data: any): Transaction { + return Transaction.create(pond.Transaction.fromObject(cloneDeep(data))); + } +} \ No newline at end of file diff --git a/src/navigation/Router.tsx b/src/navigation/Router.tsx index a281c13..5d1e931 100644 --- a/src/navigation/Router.tsx +++ b/src/navigation/Router.tsx @@ -18,6 +18,7 @@ import Site from "pages/Site"; import Heaters from "pages/Heaters"; import Heater from "pages/Heater"; import Tasks from "pages/Tasks"; +import Transactions from "pages/Transactions"; //import Site from "pages/Site"; const DeviceHistory = lazy(() => import("pages/DeviceHistory")); @@ -301,6 +302,7 @@ export default function Router(props: Props) { {/* Hello!} /> */} } /> } /> + } /> {/* Map pages */} } /> diff --git a/src/navigation/SideNavigator.tsx b/src/navigation/SideNavigator.tsx index a48de00..dad3529 100644 --- a/src/navigation/SideNavigator.tsx +++ b/src/navigation/SideNavigator.tsx @@ -1,4 +1,4 @@ -import { ChevronRight, People, Person } from "@mui/icons-material"; +import { ChevronRight, People, Person, SyncAlt } from "@mui/icons-material"; import ChevronLeft from "@mui/icons-material/ChevronLeft"; import { darken, @@ -307,7 +307,19 @@ export default function SideNavigator(props: Props) { - {open && } + {open && } + + + + goTo("/transactions")} + classes={getClasses("/transactions")} + > + + + + {open && } diff --git a/src/pages/Transactions.tsx b/src/pages/Transactions.tsx new file mode 100644 index 0000000..1f2a747 --- /dev/null +++ b/src/pages/Transactions.tsx @@ -0,0 +1,165 @@ +import { useEffect, useState } from "react"; +import PageContainer from "./PageContainer"; +import { Box, Grid2 as Grid, TextField, Typography } from "@mui/material"; +import { Moment } from "moment"; +import { pond } from "protobuf-ts/pond"; +import SearchSelect, { Option } from "common/SearchSelect"; +import TransactionViewer from "transactions/transactionViewer"; +import { TransactionOptions } from "objects/ObjectDescriber"; +import { GetDefaultDateRange } from "common/time/DateRange"; +import TimeBar from "common/time/TimeBar"; +import { useTransactionAPI } from "providers"; +import { Transaction } from "models/Transaction"; +import { makeStyles } from "@mui/styles"; + +const useStyles = makeStyles(() => { + return ({ + page: { + padding: 10 + } + }); +}); + +//this page will have the dropdown selectors to set the variables for query +export default function Transactions() { + const classes = useStyles(); + const defaultDateRange = GetDefaultDateRange(); + const [startDate, setStartDate] = useState(defaultDateRange.start); + const [endDate, setEndDate] = useState(defaultDateRange.end); + //these two variables are the object type + const [fromObject, setFromObject] = useState(undefined); + const [toObject, setToObject] = useState(undefined); + //these are simply for controlling what is shown in the select boxes + const [selectedFromObject, setSelectedFromObject] = useState