had cursor replace uses of getDistanceUnit with using the distance unit in the users settings so that it no longer relies on local storage
This commit is contained in:
parent
c6bb7aa24a
commit
dc54f99abd
20 changed files with 273 additions and 199 deletions
|
|
@ -4,7 +4,7 @@ import SearchSelect, { Option } from "common/SearchSelect";
|
|||
import { useMobile } from "hooks";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { getDistanceUnit } from "utils";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
interface Props {
|
||||
optionsChanged: (binOptions: jsonBin[]) => void;
|
||||
|
|
@ -13,6 +13,7 @@ interface Props {
|
|||
|
||||
export default function BinSelector(props: Props) {
|
||||
const { optionsChanged, vertical } = props;
|
||||
const [{user}] = useGlobalState();
|
||||
const isMobile = useMobile();
|
||||
const [manufacturerOptions, SetManufacturerOptions] = useState<Option[]>([]);
|
||||
const [manufacturer, SetManufacturer] = useState<Option | null>(null);
|
||||
|
|
@ -126,7 +127,7 @@ export default function BinSelector(props: Props) {
|
|||
}}
|
||||
label={
|
||||
"Minimum Diameter " +
|
||||
(getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)")
|
||||
(user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)")
|
||||
}
|
||||
/>
|
||||
</Grid>
|
||||
|
|
@ -143,7 +144,7 @@ export default function BinSelector(props: Props) {
|
|||
}}
|
||||
label={
|
||||
"Maximum Diameter " +
|
||||
(getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)")
|
||||
(user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)")
|
||||
}
|
||||
/>
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ import { pond } from "protobuf-ts/pond";
|
|||
import { useBinAPI, useBinYardAPI, useGlobalState, useLibraCartProxyAPI } from "providers";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
// import { useHistory } from "react-router";
|
||||
import { getDistanceUnit, or, getGrainUnit } from "utils";
|
||||
import { or, getGrainUnit } from "utils";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import BinSelector from "./BinSelector";
|
||||
|
|
@ -269,7 +269,7 @@ export default function BinSettings(props: Props) {
|
|||
let sidewallHeight = "";
|
||||
let hopperHeight = "";
|
||||
if (initForm.specs) {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
h = (initForm.specs.heightCm * 0.0328).toFixed(2);
|
||||
d = (initForm.specs.diameterCm * 0.0328).toFixed(2);
|
||||
if (initForm.specs.advancedDimensions) {
|
||||
|
|
@ -350,7 +350,7 @@ export default function BinSettings(props: Props) {
|
|||
setMoistureTargetDeviation(initForm.inventory?.moistureTargetDeviation.toString() ?? "0");
|
||||
setAutoFillThreshold(initForm.inventory?.autoThreshold ?? 5)
|
||||
let dropDistance = initForm.inventory?.lidarDropCm ?? 0
|
||||
if(getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
if(user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
dropDistance = Math.round((dropDistance/30.48)*100)/100
|
||||
}
|
||||
setLidarDropDistance(dropDistance)
|
||||
|
|
@ -475,7 +475,7 @@ export default function BinSettings(props: Props) {
|
|||
if (form.inventory) {
|
||||
form.inventory.inventoryControl = inventoryControl
|
||||
form.inventory.autoThreshold = autoFillThreshold
|
||||
form.inventory.lidarDropCm = getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? lidarDropDistance * 30.48 : lidarDropDistance
|
||||
form.inventory.lidarDropCm = user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? lidarDropDistance * 30.48 : lidarDropDistance
|
||||
if(form.inventory.grainType !== pond.Grain.GRAIN_CUSTOM){
|
||||
form.inventory.customGrain = undefined
|
||||
}else{
|
||||
|
|
@ -529,7 +529,7 @@ export default function BinSettings(props: Props) {
|
|||
form.inventory.inventoryControl = inventoryControl
|
||||
form.inventory.autoThreshold = autoFillThreshold
|
||||
//if the users preferences are in feet convert the distance to cm otherwise it was entered as cm so use that
|
||||
form.inventory.lidarDropCm = getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? lidarDropDistance * 30.48 : lidarDropDistance
|
||||
form.inventory.lidarDropCm = user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? lidarDropDistance * 30.48 : lidarDropDistance
|
||||
if(form.inventory.grainType !== pond.Grain.GRAIN_CUSTOM){
|
||||
form.inventory.customGrain = undefined
|
||||
}else{
|
||||
|
|
@ -1099,7 +1099,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "ft" : "cm"}
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "ft" : "cm"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -1435,7 +1435,7 @@ export default function BinSettings(props: Props) {
|
|||
let sH = sidewallHeight;
|
||||
let hH = hopperHeight ?? 0;
|
||||
let d = diameter;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
tcH = tcH * 3.281;
|
||||
sH = sH * 3.281;
|
||||
hH = hH * 3.281;
|
||||
|
|
@ -1463,7 +1463,7 @@ export default function BinSettings(props: Props) {
|
|||
let hopperHeight = formExtension.hopperHeight;
|
||||
let diameter = formExtension.diameter;
|
||||
|
||||
// if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
// if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
// diameterM = (Number(diameterM) * 3.28084).toFixed(2);
|
||||
// heightM = (Number(heightM) * 3.28084).toFixed(2);
|
||||
// }
|
||||
|
|
@ -1552,7 +1552,7 @@ export default function BinSettings(props: Props) {
|
|||
let d = diameter;
|
||||
let valueM = value;
|
||||
let dM = diameter;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
valueM = (Number(value) * 0.3048).toFixed(2);
|
||||
dM = (Number(d) * 0.3048).toFixed(2);
|
||||
}
|
||||
|
|
@ -1577,7 +1577,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -1637,7 +1637,7 @@ export default function BinSettings(props: Props) {
|
|||
let value = event?.target.value;
|
||||
let valueM = value;
|
||||
setModelID(0);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
valueM = (Number(value) * 0.3048).toFixed(2);
|
||||
}
|
||||
let coneCM =
|
||||
|
|
@ -1674,7 +1674,7 @@ export default function BinSettings(props: Props) {
|
|||
|
||||
//need to get the total height in cm
|
||||
let totalHeightCM = s + t + h; //the total height in the users units
|
||||
if(getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
if(user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
totalHeightCM = totalHeightCM * 30.48 //convert from feet to cm
|
||||
}else{
|
||||
totalHeightCM = totalHeightCM * 100 //convert from m to cm
|
||||
|
|
@ -1698,7 +1698,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
? "m"
|
||||
: "ft"}
|
||||
</InputAdornment>
|
||||
|
|
@ -1725,7 +1725,7 @@ export default function BinSettings(props: Props) {
|
|||
//calculate the new cone height for the roof angle
|
||||
let coneCM = TriangleOppositeLength(d / 2, angle ?? 0);
|
||||
let newConeHeight =
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
? (coneCM / 30.48).toFixed(2)
|
||||
: (coneCM / 100).toFixed(2);
|
||||
|
||||
|
|
@ -1749,7 +1749,7 @@ export default function BinSettings(props: Props) {
|
|||
|
||||
//need to get the total height in cm
|
||||
let totalHeightCM = s + t + h; //the total height in the users units
|
||||
if(getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
if(user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
totalHeightCM = totalHeightCM * 30.48 //convert from feet to cm
|
||||
}else{
|
||||
totalHeightCM = totalHeightCM * 100 //convert from m to cm
|
||||
|
|
@ -1786,7 +1786,7 @@ export default function BinSettings(props: Props) {
|
|||
onChange={event => {
|
||||
let value = event?.target.value;
|
||||
let valueM = value;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
valueM = (Number(value) * 0.3048).toFixed(2);
|
||||
}
|
||||
let ext = cloneDeep(formExtension);
|
||||
|
|
@ -1811,7 +1811,7 @@ export default function BinSettings(props: Props) {
|
|||
|
||||
//need to get the total height in cm
|
||||
let totalHeightCM = s + t + h; //the total height in the users units
|
||||
if(getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
if(user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET){
|
||||
totalHeightCM = totalHeightCM * 30.48 //convert from feet to cm
|
||||
}else{
|
||||
totalHeightCM = totalHeightCM * 100 //convert from m to cm
|
||||
|
|
@ -1838,7 +1838,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
? "m"
|
||||
: "ft"}
|
||||
</InputAdornment>
|
||||
|
|
@ -1868,7 +1868,7 @@ export default function BinSettings(props: Props) {
|
|||
let coneCM = TriangleOppositeLength(d / 2, angle ?? 0);
|
||||
|
||||
let newHopperHeight =
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
? (coneCM / 30.48).toFixed(2)
|
||||
: (coneCM / 100).toFixed(2);
|
||||
|
||||
|
|
@ -1926,7 +1926,7 @@ export default function BinSettings(props: Props) {
|
|||
onChange={event => {
|
||||
let value = event?.target.value;
|
||||
let valueM = value;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
valueM = (Number(value) * 0.3048).toFixed(2);
|
||||
}
|
||||
|
||||
|
|
@ -1982,7 +1982,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET
|
||||
? "m"
|
||||
: "ft"}
|
||||
</InputAdornment>
|
||||
|
|
@ -2009,7 +2009,7 @@ export default function BinSettings(props: Props) {
|
|||
let h = height;
|
||||
let valueM = value;
|
||||
let hM = height;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
valueM = (Number(value) * 0.3048).toFixed(2);
|
||||
hM = (Number(h) * 0.3048).toFixed(2);
|
||||
}
|
||||
|
|
@ -2063,7 +2063,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -2253,7 +2253,7 @@ export default function BinSettings(props: Props) {
|
|||
let userHopperHeight = hopperHeight;
|
||||
let userDiameter = jsonBin.Diameter;
|
||||
//since the jsone data is in feet just check if we need to make it in meters
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
userHeight = userHeight / 3.281;
|
||||
userDiameter = userDiameter / 3.281;
|
||||
userTopCone = userTopCone / 3.281;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { colors } from "@mui/material";
|
|||
import { jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import { useEffect, useState } from "react";
|
||||
import { distanceConversion } from "utils";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
|
|
@ -22,6 +23,8 @@ export default function SideView(props: Props) {
|
|||
const dimensionFontSize = 7;
|
||||
const gapSize = svgViewBoxSize * 0.05;
|
||||
const { bin } = props;
|
||||
const [{ user }] = useGlobalState();
|
||||
const distanceUnit = user.distanceUnit();
|
||||
const [scale, setScale] = useState(0); //the scale to multiply the bin dimension by in order to determine how long to draw the line
|
||||
const [hopperHeight, setHopperHeight] = useState(0);
|
||||
const [roofHeight, setRoofHeight] = useState(0);
|
||||
|
|
@ -194,7 +197,7 @@ export default function SideView(props: Props) {
|
|||
"bottomText",
|
||||
svgViewBoxSize / 2,
|
||||
y2,
|
||||
distanceConversion(bin.Diameter).toFixed(1)
|
||||
distanceConversion(bin.Diameter, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -231,7 +234,7 @@ export default function SideView(props: Props) {
|
|||
let y2 = (roofHeight + bin.Sidewall) * scale;
|
||||
|
||||
d.push(
|
||||
dimensionText("sidewallText", x2, midpoint, distanceConversion(bin.Sidewall).toFixed(1))
|
||||
dimensionText("sidewallText", x2, midpoint, distanceConversion(bin.Sidewall, distanceUnit).toFixed(1))
|
||||
);
|
||||
d.push(
|
||||
dimensionPath(
|
||||
|
|
@ -270,7 +273,7 @@ export default function SideView(props: Props) {
|
|||
"peakText",
|
||||
xText,
|
||||
midpoint,
|
||||
distanceConversion(bin.Sidewall + roofHeight).toFixed(1)
|
||||
distanceConversion(bin.Sidewall + roofHeight, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
d.push(
|
||||
|
|
@ -313,7 +316,7 @@ export default function SideView(props: Props) {
|
|||
"totalText",
|
||||
x2,
|
||||
midpoint,
|
||||
distanceConversion(roofHeight + bin.Sidewall + hopperHeight).toFixed(1)
|
||||
distanceConversion(roofHeight + bin.Sidewall + hopperHeight, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
d.push(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import {
|
|||
//import MaterialTable from "material-table";
|
||||
//import { getTableIcons } from "common/ResponsiveTable";
|
||||
import CableDisplay from "./cableDisplay";
|
||||
import { distanceConversion, getDistanceUnit } from "utils";
|
||||
import { distanceConversion } from "utils";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import CableQuote from "./cableQuote";
|
||||
import { useMobile } from "hooks";
|
||||
|
|
@ -33,6 +33,7 @@ import {
|
|||
} from "common/TrigFunctions";
|
||||
import ResponsiveTable, { Column } from "common/ResponsiveTable";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
sliderThumb: {
|
||||
|
|
@ -56,6 +57,7 @@ export default function CableEstimator() {
|
|||
//the conversion constant to convert cubic feet to bushels
|
||||
const conversionConstantFT = 0.7786;
|
||||
const classes = useStyles();
|
||||
const [{ user }] = useGlobalState();
|
||||
const [binOptions, setBinOptions] = useState<jsonBin[]>([]);
|
||||
const [displayedRows, setDisplayedRows] = useState<jsonBin[]>([]);
|
||||
const [tablePage, setTablePage] = useState(0)
|
||||
|
|
@ -67,21 +69,21 @@ export default function CableEstimator() {
|
|||
const [quoteOpen, setQuoteOpen] = useState(false);
|
||||
const [useCustomBin, setUseCustomBin] = useState(false);
|
||||
const [diameterFormEntry, setDiameterFormEntry] = useState(
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "9.1" : "30"
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "9.1" : "30"
|
||||
);
|
||||
//const [capacityFormEntry, setCapacityFormEntry] = useState("0");
|
||||
const [ringsFormEntry, setRingsFormEntry] = useState("0");
|
||||
const [ringHeightFormEntry, setRingHeightFormEntry] = useState("0");
|
||||
const [ringHeightFt, setRingHeightFt] = useState(0);
|
||||
const [sidewallFormEntry, setSidewallFormEntry] = useState(
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "7" : "23"
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "7" : "23"
|
||||
);
|
||||
const [peakFormEntry, setPeakFormEntry] = useState(
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "9.1" : "30"
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "9.1" : "30"
|
||||
);
|
||||
//const [eaveToPeakFormEntry, setEaveToPeakFormEntry] = useState("0");
|
||||
const [roofAngleFormEntry, setRoofAngleFormEntry] = useState(
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "7.6" : "25"
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "7.6" : "25"
|
||||
);
|
||||
const [hopperAngleFormEntry, setHopperAngleFormEntry] = useState("0");
|
||||
const nodeSpacing = 4;
|
||||
|
|
@ -129,24 +131,40 @@ export default function CableEstimator() {
|
|||
render: (row: jsonBin) => <Box padding={2}>{row.HopperAngle}</Box>
|
||||
},
|
||||
{
|
||||
title: "Diameter " + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "Diameter " + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
sortKey: "Diameter",
|
||||
render: (row: jsonBin) => <Box padding={2}>{distanceConversion(row.Diameter).toFixed(2)}</Box>
|
||||
render: (row: jsonBin) => (
|
||||
<Box padding={2}>
|
||||
{distanceConversion(row.Diameter, user.distanceUnit()).toFixed(2)}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "Sidewall" + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "Sidewall" + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
sortKey: "Sidewall",
|
||||
render: (row: jsonBin) => <Box padding={2}>{distanceConversion(row.Sidewall).toFixed(2)}</Box>
|
||||
render: (row: jsonBin) => (
|
||||
<Box padding={2}>
|
||||
{distanceConversion(row.Sidewall, user.distanceUnit()).toFixed(2)}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "Peak Height" + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "Peak Height" + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
sortKey: "Peak",
|
||||
render: (row: jsonBin) => <Box padding={2}>{distanceConversion(row.Peak).toFixed(2)}</Box>
|
||||
render: (row: jsonBin) => (
|
||||
<Box padding={2}>
|
||||
{distanceConversion(row.Peak, user.distanceUnit()).toFixed(2)}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "Eave To Peak" + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "Eave To Peak" + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
sortKey: "EaveToPeak",
|
||||
render: (row: jsonBin) => <Box padding={2}>{distanceConversion(row.EaveToPeak).toFixed(2)}</Box>
|
||||
render: (row: jsonBin) => (
|
||||
<Box padding={2}>
|
||||
{distanceConversion(row.EaveToPeak, user.distanceUnit()).toFixed(2)}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "Roof Angle",
|
||||
|
|
@ -545,7 +563,7 @@ export default function CableEstimator() {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -554,7 +572,7 @@ export default function CableEstimator() {
|
|||
onChange={e => {
|
||||
setDiameterFormEntry(e.target.value);
|
||||
let val = isNaN(parseFloat(e.target.value)) ? 0 : parseFloat(e.target.value);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
val = val * 3.281;
|
||||
}
|
||||
//when the diameter is changed use the current peak height to adjust the roof angle
|
||||
|
|
@ -577,7 +595,7 @@ export default function CableEstimator() {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -589,7 +607,7 @@ export default function CableEstimator() {
|
|||
onChange={e => {
|
||||
setPeakFormEntry(e.target.value);
|
||||
let val = isNaN(parseFloat(e.target.value)) ? 0 : parseFloat(e.target.value);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
val = val * 3.281;
|
||||
}
|
||||
//when the peak height is changed use the diameter to calculate the roof angle
|
||||
|
|
@ -621,7 +639,7 @@ export default function CableEstimator() {
|
|||
//use the new number of rings and ring height to get the sidewall height
|
||||
let sidewallFt = val * ringHeightFt;
|
||||
bin.Sidewall = sidewallFt;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
setSidewallFormEntry((sidewallFt / 3.281).toString());
|
||||
} else {
|
||||
setSidewallFormEntry(sidewallFt.toString());
|
||||
|
|
@ -650,7 +668,7 @@ export default function CableEstimator() {
|
|||
onChange={e => {
|
||||
setRingHeightFormEntry(e.target.value);
|
||||
let inVal = isNaN(parseFloat(e.target.value)) ? 0 : parseFloat(e.target.value);
|
||||
// if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
// if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
// val = val * 3.281;
|
||||
// }
|
||||
let ringFt = inVal / 12;
|
||||
|
|
@ -659,7 +677,7 @@ export default function CableEstimator() {
|
|||
let bin = cloneDeep(customBin);
|
||||
let sidewallFt = bin.Rings * ringFt;
|
||||
bin.Sidewall = sidewallFt;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
setSidewallFormEntry((sidewallFt / 3.281).toString());
|
||||
} else {
|
||||
setSidewallFormEntry(sidewallFt.toString());
|
||||
|
|
@ -683,7 +701,7 @@ export default function CableEstimator() {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -694,7 +712,7 @@ export default function CableEstimator() {
|
|||
setSidewallFormEntry(e.target.value);
|
||||
let val = isNaN(parseFloat(e.target.value)) ? 0 : parseFloat(e.target.value);
|
||||
//if the value entered is meters convert it to feet for the bin
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
val = val * 3.281;
|
||||
}
|
||||
let bin = cloneDeep(customBin);
|
||||
|
|
@ -733,7 +751,7 @@ export default function CableEstimator() {
|
|||
let coneHeight = calcConeHeight(bin.Diameter / 2, bin.RoofAngle);
|
||||
bin.Peak = bin.Sidewall + coneHeight; //assign it as feet
|
||||
let peakHeightDisplay = bin.Sidewall + coneHeight;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
peakHeightDisplay = peakHeightDisplay / 3.281;
|
||||
}
|
||||
setPeakFormEntry(peakHeightDisplay.toFixed(1));
|
||||
|
|
@ -762,7 +780,7 @@ export default function CableEstimator() {
|
|||
let coneHeight = calcConeHeight(bin.Diameter / 2, bin.RoofAngle);
|
||||
bin.Peak = bin.Sidewall + coneHeight;
|
||||
let peakHeightDisplay = bin.Sidewall + coneHeight;
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
peakHeightDisplay = peakHeightDisplay / 3.281;
|
||||
}
|
||||
setPeakFormEntry(peakHeightDisplay.toFixed(1));
|
||||
|
|
@ -887,7 +905,7 @@ export default function CableEstimator() {
|
|||
setEaveToPeakFormEntry(e.target.value);
|
||||
let val = isNaN(parseFloat(e.target.value)) ? 0 : parseFloat(e.target.value);
|
||||
//if the value entered is meters convert it to feet for the bin
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
val = val * 3.281;
|
||||
}
|
||||
let bin = cloneDeep(customBin);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import ResponsiveTable, { Column } from "common/ResponsiveTable";
|
|||
//import { getTableIcons } from "common/ResponsiveTable";
|
||||
//import MaterialTable from "material-table";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useEffect } from "react";
|
||||
import { distanceConversion, getDistanceUnit } from "utils";
|
||||
import { distanceConversion } from "utils";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
|
|
@ -13,6 +13,7 @@ interface Props {
|
|||
|
||||
export default function CableMounting(props: Props) {
|
||||
const { bin } = props;
|
||||
const [{ user }] = useGlobalState();
|
||||
// const [tablePage, setTablePage] = useState(0)
|
||||
// const [pageSize, setPageSize] = useState(10)
|
||||
|
||||
|
|
@ -26,15 +27,19 @@ export default function CableMounting(props: Props) {
|
|||
render: (row: CableSum) => <Box padding={2}>{row.Orbit === 0 ? "Center" : row.Orbit}</Box>
|
||||
},
|
||||
{
|
||||
title: "From Center " + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "From Center " + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
render: (row: CableSum) => (
|
||||
<Box padding={2}>{distanceConversion(row.DistanceFromCenter).toFixed(2)}</Box>
|
||||
<Box padding={2}>
|
||||
{distanceConversion(row.DistanceFromCenter, user.distanceUnit()).toFixed(2)}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "Along Roof" + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "Along Roof" + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
render: (row: CableSum) => (
|
||||
<Box padding={2}>{distanceConversion(roofDist(row.DistanceFromCenter)).toFixed(2)}</Box>
|
||||
<Box padding={2}>
|
||||
{distanceConversion(roofDist(row.DistanceFromCenter), user.distanceUnit()).toFixed(2)}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import ResponsiveDialog from "common/ResponsiveDialog";
|
|||
import { useMobile } from "hooks";
|
||||
import { jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import PdfContent from "./pdfComponents/pdfContent";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
|
|
@ -14,6 +15,7 @@ interface Props {
|
|||
|
||||
export default function CableQuote(props: Props) {
|
||||
const { open, close, bin } = props;
|
||||
const [{user}] = useGlobalState();
|
||||
const isMobil = useMobile();
|
||||
const pdfStyle = StyleSheet.create({
|
||||
viewerDesktop: {
|
||||
|
|
@ -27,7 +29,11 @@ export default function CableQuote(props: Props) {
|
|||
});
|
||||
|
||||
const pdfDoc = () => {
|
||||
return <AgPDFTemplate content={<PdfContent bin={bin} />} />;
|
||||
return (
|
||||
<AgPDFTemplate
|
||||
content={<PdfContent bin={bin} distanceUnit={user.distanceUnit()} />}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import { Box, Typography } from "@mui/material";
|
|||
//import MaterialTable from "material-table";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useEffect, useState } from "react";
|
||||
import { distanceConversion, getDistanceUnit } from "utils";
|
||||
import { distanceConversion } from "utils";
|
||||
import { useGlobalState } from "providers";
|
||||
import { Cable, jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import { cloneDeep } from "lodash";
|
||||
import ResponsiveTable, { Column } from "common/ResponsiveTable";
|
||||
|
|
@ -15,17 +16,19 @@ interface Props {
|
|||
|
||||
export default function CableTable(props: Props) {
|
||||
const { bin, /*cablesChanged*/ } = props;
|
||||
const [{ user }] = useGlobalState();
|
||||
//const nodeSpacing = 4; //space between the nodes in feet
|
||||
|
||||
const [cableData, setCableData] = useState(bin.Cables);
|
||||
|
||||
useEffect(() => {
|
||||
let convertedCables: Cable[] = cloneDeep(bin.Cables);
|
||||
const du = user.distanceUnit();
|
||||
convertedCables.forEach(cable => {
|
||||
cable.Length = Math.round(distanceConversion(cable.Length) * 100) / 100;
|
||||
cable.Length = Math.round(distanceConversion(cable.Length, du) * 100) / 100;
|
||||
});
|
||||
setCableData(convertedCables);
|
||||
}, [bin]);
|
||||
}, [bin, user]);
|
||||
|
||||
// const table = () => {
|
||||
// return (
|
||||
|
|
@ -116,7 +119,7 @@ export default function CableTable(props: Props) {
|
|||
render: (row) => <Box padding={2}>{row.Count}</Box>
|
||||
},
|
||||
{
|
||||
title: "Length" + (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
title: "Length" + (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"),
|
||||
render: (row) => <Box padding={2}>{row.Length}</Box>
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { StyleSheet, Text, View } from "@react-pdf/renderer";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { getDistanceUnit } from "utils";
|
||||
|
||||
interface Props {
|
||||
borderColour: string;
|
||||
distanceUnit: pond.DistanceUnit;
|
||||
}
|
||||
|
||||
export default function CableTableHeader(props: Props) {
|
||||
|
|
@ -35,7 +35,8 @@ export default function CableTableHeader(props: Props) {
|
|||
<Text style={styles.cell}>Type</Text>
|
||||
<Text style={styles.cell}>Qty</Text>
|
||||
<Text style={styles.cell}>
|
||||
Length {getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"}
|
||||
Length{" "}
|
||||
{props.distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"}
|
||||
</Text>
|
||||
<Text style={styles.endCell}>Nodes</Text>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@ import { StyleSheet, Text, View } from "@react-pdf/renderer";
|
|||
import { jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import React from "react";
|
||||
import { distanceConversion } from "utils";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
borderColour: string;
|
||||
distanceUnit: pond.DistanceUnit;
|
||||
}
|
||||
|
||||
export default function CableTableRow(props: Props) {
|
||||
|
|
@ -48,7 +50,9 @@ export default function CableTableRow(props: Props) {
|
|||
<Text style={styles.cell}>{cable.Orbit === 0 ? "Center" : cable.Orbit}</Text>
|
||||
<Text style={styles.cell}>{cable.Type === 2 ? "Moisture" : "Temperature"}</Text>
|
||||
<Text style={styles.cell}>{cable.Count}</Text>
|
||||
<Text style={styles.cell}>{distanceConversion(cable.Length).toFixed(2)}</Text>
|
||||
<Text style={styles.cell}>
|
||||
{distanceConversion(cable.Length, props.distanceUnit).toFixed(2)}
|
||||
</Text>
|
||||
<Text style={styles.endCell}>{cable.Nodes}</Text>
|
||||
</View>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { StyleSheet, Text, View } from "@react-pdf/renderer";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { getDistanceUnit } from "utils";
|
||||
|
||||
interface Props {
|
||||
borderColour: string;
|
||||
distanceUnit: pond.DistanceUnit;
|
||||
}
|
||||
|
||||
export default function MountingTableHeader(props: Props) {
|
||||
|
|
@ -43,10 +43,12 @@ export default function MountingTableHeader(props: Props) {
|
|||
<View style={styles.view}>
|
||||
<Text style={styles.orbit}>Orbit</Text>
|
||||
<Text style={styles.centerDist}>
|
||||
Radius {getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"}
|
||||
Radius{" "}
|
||||
{props.distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"}
|
||||
</Text>
|
||||
<Text style={styles.roofDist}>
|
||||
Along Roof {getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"}
|
||||
Along Roof{" "}
|
||||
{props.distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_FEET ? "(ft)" : "(m)"}
|
||||
</Text>
|
||||
<Text style={styles.bracket}>Bracket</Text>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@ import { StyleSheet, Text, View } from "@react-pdf/renderer";
|
|||
import { getBracket, jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import React from "react";
|
||||
import { distanceConversion } from "utils";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
borderColour: string;
|
||||
distanceUnit: pond.DistanceUnit;
|
||||
}
|
||||
|
||||
export default function MountingTableRow(props: Props) {
|
||||
|
|
@ -65,10 +67,10 @@ export default function MountingTableRow(props: Props) {
|
|||
key={i}>
|
||||
<Text style={styles.orbit}>{orbit.Orbit === 0 ? "C" : orbit.Orbit}</Text>
|
||||
<Text style={styles.centerDist}>
|
||||
{distanceConversion(orbit.DistanceFromCenter).toFixed(2)}
|
||||
{distanceConversion(orbit.DistanceFromCenter, props.distanceUnit).toFixed(2)}
|
||||
</Text>
|
||||
<Text style={styles.roofDist}>
|
||||
{distanceConversion(roofDist(orbit.DistanceFromCenter)).toFixed(2)}
|
||||
{distanceConversion(roofDist(orbit.DistanceFromCenter), props.distanceUnit).toFixed(2)}
|
||||
</Text>
|
||||
<Text style={styles.bracket}>
|
||||
{bracketType}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { StyleSheet, Text, View } from "@react-pdf/renderer";
|
||||
import { colors } from "@mui/material";
|
||||
import { jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import CableTableHeader from "./cableTable/cableTableHeader";
|
||||
import CableTableRow from "./cableTable/cableTableRow";
|
||||
import PDFSideView from "./pdfSVG/pdfSideView";
|
||||
|
|
@ -10,9 +11,11 @@ import MountingTableRow from "./mountingTable/mountingTableRows";
|
|||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
distanceUnit: pond.DistanceUnit;
|
||||
}
|
||||
|
||||
export default function PdfContent(props: Props) {
|
||||
const { distanceUnit } = props;
|
||||
const tableBorderColour = colors.grey[800];
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
|
@ -53,7 +56,7 @@ export default function PdfContent(props: Props) {
|
|||
</View>
|
||||
<View style={{ height: 280, flexDirection: "row" }}>
|
||||
<View style={{ width: 260 }}>
|
||||
<PDFSideView bin={props.bin} />
|
||||
<PDFSideView bin={props.bin} distanceUnit={distanceUnit} />
|
||||
</View>
|
||||
<View style={{ width: 260 }}>
|
||||
<View style={{ height: 195 }}>
|
||||
|
|
@ -63,8 +66,12 @@ export default function PdfContent(props: Props) {
|
|||
<Text style={{ fontFamily: "Helvetica-Bold", marginBottom: 5 }}>Install Guide</Text>
|
||||
<View
|
||||
style={{ borderColor: tableBorderColour, borderWidth: 1, flexDirection: "column" }}>
|
||||
<MountingTableHeader borderColour={tableBorderColour} />
|
||||
<MountingTableRow borderColour={tableBorderColour} bin={props.bin} />
|
||||
<MountingTableHeader borderColour={tableBorderColour} distanceUnit={distanceUnit} />
|
||||
<MountingTableRow
|
||||
borderColour={tableBorderColour}
|
||||
bin={props.bin}
|
||||
distanceUnit={distanceUnit}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
|
@ -73,8 +80,12 @@ export default function PdfContent(props: Props) {
|
|||
Recommended Cables
|
||||
</Text>
|
||||
<View style={styles.cableTable}>
|
||||
<CableTableHeader borderColour={tableBorderColour} />
|
||||
<CableTableRow bin={props.bin} borderColour={tableBorderColour} />
|
||||
<CableTableHeader borderColour={tableBorderColour} distanceUnit={distanceUnit} />
|
||||
<CableTableRow
|
||||
bin={props.bin}
|
||||
borderColour={tableBorderColour}
|
||||
distanceUnit={distanceUnit}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { colors } from "@mui/material";
|
||||
import { Circle, Line, Path, Svg, Text } from "@react-pdf/renderer";
|
||||
import { jsonBin } from "common/DataImports/BinCables/BinCableImporter";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useEffect, useState } from "react";
|
||||
import { distanceConversion } from "utils";
|
||||
|
||||
interface Props {
|
||||
bin: jsonBin;
|
||||
distanceUnit: pond.DistanceUnit;
|
||||
}
|
||||
|
||||
interface svgPoint {
|
||||
|
|
@ -22,7 +24,7 @@ export default function PDFSideView(props: Props) {
|
|||
const nodeSpacing = 4; //space in feet between the nodes
|
||||
const dimensionFontSize = 18;
|
||||
const gapSize = svgViewBoxSize * 0.05;
|
||||
const { bin } = props;
|
||||
const { bin, distanceUnit } = props;
|
||||
const [scale, setScale] = useState(0); //the scale to multiply the bin dimension by in order to determine how long to draw the line
|
||||
const [hopperHeight, setHopperHeight] = useState(0);
|
||||
const [roofHeight, setRoofHeight] = useState(0);
|
||||
|
|
@ -194,7 +196,7 @@ export default function PDFSideView(props: Props) {
|
|||
"bottomText",
|
||||
svgViewBoxSize / 2,
|
||||
y2,
|
||||
distanceConversion(bin.Diameter).toFixed(1)
|
||||
distanceConversion(bin.Diameter, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -231,7 +233,12 @@ export default function PDFSideView(props: Props) {
|
|||
let y2 = (roofHeight + bin.Sidewall) * scale;
|
||||
|
||||
d.push(
|
||||
dimensionText("sidewallText", x2, midpoint, distanceConversion(bin.Sidewall).toFixed(1))
|
||||
dimensionText(
|
||||
"sidewallText",
|
||||
x2,
|
||||
midpoint,
|
||||
distanceConversion(bin.Sidewall, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
d.push(
|
||||
dimensionPath(
|
||||
|
|
@ -270,7 +277,7 @@ export default function PDFSideView(props: Props) {
|
|||
"peakText",
|
||||
xText,
|
||||
midpoint,
|
||||
distanceConversion(bin.Sidewall + roofHeight).toFixed(1)
|
||||
distanceConversion(bin.Sidewall + roofHeight, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
d.push(
|
||||
|
|
@ -313,7 +320,7 @@ export default function PDFSideView(props: Props) {
|
|||
"totalText",
|
||||
x2,
|
||||
midpoint,
|
||||
distanceConversion(roofHeight + bin.Sidewall + hopperHeight).toFixed(1)
|
||||
distanceConversion(roofHeight + bin.Sidewall + hopperHeight, distanceUnit).toFixed(1)
|
||||
)
|
||||
);
|
||||
d.push(
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ import { bestUnit, milliToX } from "common/time/duration";
|
|||
import { useGlobalState } from "providers";
|
||||
import { green, red } from "@mui/material/colors";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import { getDistanceUnit } from "utils";
|
||||
import { GrainOptions } from "grain";
|
||||
import CompModes from "component/ComponentMode.json";
|
||||
import FanPicker from "fans/fanPicker";
|
||||
|
|
@ -177,11 +176,11 @@ export default function ComponentForm(props: Props) {
|
|||
let width = formComponent.settings.containerDimensions?.widthCm ?? 0;
|
||||
let height = formComponent.settings.containerDimensions?.heightCm ?? 0;
|
||||
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
length = length / 100;
|
||||
width = width / 100;
|
||||
height = height / 100;
|
||||
} else if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
} else if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
length = length / 30.48;
|
||||
width = width / 30.48;
|
||||
height = height / 30.48;
|
||||
|
|
@ -189,9 +188,9 @@ export default function ComponentForm(props: Props) {
|
|||
|
||||
let sensorDistance = formComponent.settings.sensorDistanceCm ?? 0;
|
||||
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
sensorDistance = sensorDistance / 100;
|
||||
} else if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
} else if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
sensorDistance = sensorDistance / 30.48;
|
||||
}
|
||||
|
||||
|
|
@ -520,9 +519,9 @@ export default function ComponentForm(props: Props) {
|
|||
if (!isNaN(Number(event.target.value))) {
|
||||
let dimensions = f.component.settings.containerDimensions;
|
||||
let value = Number(event.target.value);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
value = value * 100;
|
||||
} else if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
} else if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
value = value * 30.48;
|
||||
}
|
||||
if (dimensions !== undefined && dimensions !== null) {
|
||||
|
|
@ -549,9 +548,9 @@ export default function ComponentForm(props: Props) {
|
|||
if (!isNaN(Number(event.target.value))) {
|
||||
let dimensions = f.component.settings.containerDimensions;
|
||||
let value = Number(event.target.value);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
value = value * 100;
|
||||
} else if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
} else if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
value = value * 30.48;
|
||||
}
|
||||
if (dimensions !== undefined && dimensions !== null) {
|
||||
|
|
@ -578,9 +577,9 @@ export default function ComponentForm(props: Props) {
|
|||
if (!isNaN(Number(event.target.value))) {
|
||||
let dimensions = f.component.settings.containerDimensions;
|
||||
let value = Number(event.target.value);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
value = value * 100;
|
||||
} else if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
} else if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
value = value * 30.48;
|
||||
}
|
||||
if (dimensions !== undefined && dimensions !== null) {
|
||||
|
|
@ -606,9 +605,9 @@ export default function ComponentForm(props: Props) {
|
|||
f.sensorDistance = event.target.value;
|
||||
if (!isNaN(Number(event.target.value))) {
|
||||
let value = Number(event.target.value);
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
value = value * 100;
|
||||
} else if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
} else if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
value = value * 30.48;
|
||||
}
|
||||
f.component.settings.sensorDistanceCm = value;
|
||||
|
|
@ -1252,7 +1251,7 @@ export default function ComponentForm(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
? "m"
|
||||
: "ft"}
|
||||
</InputAdornment>
|
||||
|
|
@ -1276,7 +1275,7 @@ export default function ComponentForm(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
? "m"
|
||||
: "ft"}
|
||||
</InputAdornment>
|
||||
|
|
@ -1300,7 +1299,7 @@ export default function ComponentForm(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
? "m"
|
||||
: "ft"}
|
||||
</InputAdornment>
|
||||
|
|
@ -1328,7 +1327,7 @@ export default function ComponentForm(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
{user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import { FeatureCollection, Feature } from "geojson";
|
|||
import DrawController from "./mapControllers/drawController";
|
||||
//import { Geometry } from "geojson";
|
||||
import Map, { MapRef, Marker, MarkerDragEvent } from "react-map-gl/mapbox";
|
||||
import { getDistanceUnit } from "utils";
|
||||
import { MapMouseEvent } from "mapbox-gl";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import { Result } from "@mapbox/mapbox-gl-geocoder";
|
||||
|
|
@ -499,7 +498,7 @@ export default function MapBase(props: Props) {
|
|||
lineWidth: 5,
|
||||
origin: pond.DataOrigin.DATA_ORIGIN_ADAPTIVE,
|
||||
totalDist:
|
||||
getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
? (data.totalDistanceKm * 1000).toFixed(2)
|
||||
: (data.totalDistanceKm * 3280.8398950131).toFixed(2)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import { Bin, BinYard, Field, User } from "models";
|
|||
import { GrainBag } from "models/GrainBag";
|
||||
//import { ObjectHeater } from "models/ObjectHeater";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { getDistanceUnit } from "utils";
|
||||
|
||||
interface Sort {
|
||||
order: string; //what to send to the backend list to sort by
|
||||
numerical: boolean; //whether to use a numerical or text sort
|
||||
|
|
@ -62,7 +60,10 @@ const binColumns = (user?: User): Column<any>[] => {
|
|||
render: row => {
|
||||
let d = row.settings.specs?.heightCm;
|
||||
if (d) {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (
|
||||
(user?.distanceUnit() ?? pond.DistanceUnit.DISTANCE_UNIT_FEET) ===
|
||||
pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
) {
|
||||
return (d / 100).toFixed(2) + " m";
|
||||
} else {
|
||||
return (d / 30.48).toFixed(2) + " ft";
|
||||
|
|
@ -76,7 +77,10 @@ const binColumns = (user?: User): Column<any>[] => {
|
|||
render: row => {
|
||||
let d = row.settings.specs?.diameterCm;
|
||||
if (d) {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (
|
||||
(user?.distanceUnit() ?? pond.DistanceUnit.DISTANCE_UNIT_FEET) ===
|
||||
pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
) {
|
||||
return (d / 100).toFixed(2) + " m";
|
||||
} else {
|
||||
return (d / 30.48).toFixed(2) + " ft";
|
||||
|
|
@ -141,6 +145,89 @@ const binColumns = (user?: User): Column<any>[] => {
|
|||
] as Column<Bin>[];
|
||||
};
|
||||
|
||||
const grainBagColumns = (user?: User): Column<GrainBag>[] => {
|
||||
const distanceUnit =
|
||||
user?.distanceUnit() ?? pond.DistanceUnit.DISTANCE_UNIT_FEET;
|
||||
return [
|
||||
{
|
||||
title: "Name",
|
||||
render: row => {
|
||||
if (row.title) {
|
||||
return (<div>{row.title.toString()}</div>);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Length",
|
||||
render: row => {
|
||||
if (row.settings.length) {
|
||||
if (distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
return row.settings.length.toFixed(2) + " m";
|
||||
} else {
|
||||
return (row.settings.length * 3.281).toFixed(2) + " ft";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Diameter",
|
||||
render: row => {
|
||||
if (row.settings.diameter) {
|
||||
if (distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
return row.settings.diameter.toFixed(2) + " m";
|
||||
} else {
|
||||
return (row.settings.diameter * 3.281).toFixed(2) + " ft";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Grain",
|
||||
render: row => {
|
||||
if (row.settings.supportedGrain) {
|
||||
return GrainDescriber(row.settings.supportedGrain).name;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Custom Grain",
|
||||
render: row => {
|
||||
return row.settings.customGrain;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Grain Variant",
|
||||
render: row => {
|
||||
return row.settings.grainSubtype;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Capacity",
|
||||
render: row => {
|
||||
return row.settings.bushelCapacity + " bu";
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Bushels",
|
||||
render: row => {
|
||||
return row.settings.currentBushels + " bu";
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Fill Date",
|
||||
render: row => {
|
||||
return row.settings.fillDate;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Initial Moisture",
|
||||
render: row => {
|
||||
return row.settings.initialMoisture + "%";
|
||||
}
|
||||
}
|
||||
] as Column<GrainBag>[];
|
||||
};
|
||||
|
||||
export const ObjectExtensions: Map<pond.ObjectType, ObjectExtension> = new Map([
|
||||
[pond.ObjectType.OBJECT_TYPE_UNKNOWN, defaultObject],
|
||||
[
|
||||
|
|
@ -403,84 +490,8 @@ export const ObjectExtensions: Map<pond.ObjectType, ObjectExtension> = new Map([
|
|||
name: "Grainbag",
|
||||
inventoryGroup: "grain",
|
||||
isTransactionObject: true,
|
||||
tableColumns: [
|
||||
{
|
||||
title: "Name",
|
||||
render: row => {
|
||||
if (row.title) {
|
||||
return (<div>{row.title.toString()}</div>);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Length",
|
||||
render: row => {
|
||||
if (row.settings.length) {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
return row.settings.length.toFixed(2) + " m";
|
||||
} else {
|
||||
return (row.settings.length * 3.281).toFixed(2) + " ft";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Diameter",
|
||||
render: row => {
|
||||
if (row.settings.diameter) {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
return row.settings.diameter.toFixed(2) + " m";
|
||||
} else {
|
||||
return (row.settings.diameter * 3.281).toFixed(2) + " ft";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Grain",
|
||||
render: row => {
|
||||
if (row.settings.supportedGrain) {
|
||||
return GrainDescriber(row.settings.supportedGrain).name;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Custom Grain",
|
||||
render: row => {
|
||||
return row.settings.customGrain;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Grain Variant",
|
||||
render: row => {
|
||||
return row.settings.grainSubtype;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Capacity",
|
||||
render: row => {
|
||||
return row.settings.bushelCapacity + " bu";
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Bushels",
|
||||
render: row => {
|
||||
return row.settings.currentBushels + " bu";
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Fill Date",
|
||||
render: row => {
|
||||
return row.settings.fillDate;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Initial Moisture",
|
||||
render: row => {
|
||||
return row.settings.initialMoisture + "%";
|
||||
}
|
||||
}
|
||||
] as Column<GrainBag>[],
|
||||
tableColumns: grainBagColumns(),
|
||||
getTableColumns: (user?: User) => grainBagColumns(user),
|
||||
tableSort: new Map([
|
||||
["Name", { order: "name", numerical: false }],
|
||||
["Length", { order: "length", numerical: true }],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { GrainOptions } from "grain";
|
|||
import { pond } from "protobuf-ts/pond";
|
||||
import { useBinAPI, useGlobalState, useSnackbar } from "providers";
|
||||
import React, { useState } from "react";
|
||||
import { fahrenheitToCelsius, getDistanceUnit } from "utils";
|
||||
import { fahrenheitToCelsius } from "utils";
|
||||
|
||||
interface Props {
|
||||
selectedBins: pond.Bin[];
|
||||
|
|
@ -32,10 +32,10 @@ export default function BulkBinSettings(props: Props) {
|
|||
const [lowTemp, setLowTemp] = useState<number | undefined>();
|
||||
|
||||
const convertedDistance = (enteredDistance: number) => {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
return enteredDistance * 100;
|
||||
}
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
return enteredDistance * 30.48;
|
||||
}
|
||||
return enteredDistance;
|
||||
|
|
@ -168,7 +168,7 @@ export default function BulkBinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
@ -186,7 +186,7 @@ export default function BulkBinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getDistanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
{user.distanceUnit() !== pond.DistanceUnit.DISTANCE_UNIT_FEET ? "m" : "ft"}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { GrainBag } from "models/GrainBag";
|
|||
import { pond } from "protobuf-ts/pond";
|
||||
import { useGlobalState, useGrainBagAPI, useSnackbar } from "providers";
|
||||
import React, { useState } from "react";
|
||||
import { getDistanceUnit } from "utils";
|
||||
|
||||
interface Props {
|
||||
selectedBags: GrainBag[];
|
||||
|
|
@ -28,10 +27,10 @@ export default function BulkGrainBagSettings(props: Props) {
|
|||
const [bushels, setBushels] = useState<number | undefined>();
|
||||
const [fillDate, setFillDate] = useState<string | undefined>();
|
||||
const [initialMoisture, setInitialMoisture] = useState<number | undefined>();
|
||||
const [{as}] = useGlobalState();
|
||||
const [{ as, user }] = useGlobalState();
|
||||
|
||||
const convertedDistance = (enteredDistance: number) => {
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
if (user.distanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
return enteredDistance / 3.281;
|
||||
}
|
||||
return enteredDistance;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { pond } from "protobuf-ts/pond";
|
|||
import { quack } from "protobuf-ts/quack";
|
||||
import { getTextSecondary } from "theme/text";
|
||||
// import { getTextSecondary } from "theme";
|
||||
import { getDistanceUnit, roundTo } from "utils";
|
||||
import { roundTo } from "utils";
|
||||
import { extract } from "utils/types";
|
||||
|
||||
interface Enumeration {
|
||||
|
|
@ -440,7 +440,8 @@ export class MeasurementDescriber {
|
|||
this.details.max = 100000;
|
||||
break;
|
||||
case quack.MeasurementType.MEASUREMENT_TYPE_DISTANCE_CM:
|
||||
let distanceUnit = getDistanceUnit();
|
||||
let distanceUnit =
|
||||
user?.distanceUnit() ?? pond.DistanceUnit.DISTANCE_UNIT_FEET;
|
||||
this.details.label = "Distance";
|
||||
this.details.unit = "cm";
|
||||
if (distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
|
|
@ -454,7 +455,8 @@ export class MeasurementDescriber {
|
|||
this.details.max = 100000;
|
||||
break;
|
||||
case quack.MeasurementType.MEASUREMENT_TYPE_SPEED:
|
||||
let speedUnit = getDistanceUnit()
|
||||
let speedUnit =
|
||||
user?.distanceUnit() ?? pond.DistanceUnit.DISTANCE_UNIT_FEET;
|
||||
this.details.label = "Speed";
|
||||
this.details.unit = speedUnit === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m/s" : "ft/m"; //yes this is meters per second and feet per minute
|
||||
this.details.colour = green["500"];
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ export function setPressureUnit(unit: pond.PressureUnit) {
|
|||
);
|
||||
}
|
||||
|
||||
// function is deprecated, use User.distanceUnit() instead
|
||||
export function getDistanceUnit(): pond.DistanceUnit {
|
||||
return localStorage.getItem("distance") === "m"
|
||||
? pond.DistanceUnit.DISTANCE_UNIT_METERS
|
||||
|
|
@ -86,10 +87,10 @@ export function setGrainUnit(unit: pond.GrainUnit) {
|
|||
// localStorage.setItem("grainUnit", unit === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? "mT" : "bu");
|
||||
}
|
||||
|
||||
export const distanceConversion = (val: number) => {
|
||||
export const distanceConversion = (val: number, distanceUnit: pond.DistanceUnit) => {
|
||||
let converted = val;
|
||||
|
||||
if (getDistanceUnit() === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
if (distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_METERS) {
|
||||
converted = val / 3.281;
|
||||
}
|
||||
return converted;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue