Merge branch 'dev_environment' of gitlab.com:brandx/bxt-app into dev_environment

This commit is contained in:
csawatzky 2025-03-18 15:57:10 -06:00
commit 28c4a6d54a
50 changed files with 803 additions and 192 deletions

View file

@ -12,7 +12,6 @@ import RemoveSelfIcon from "@mui/icons-material/ExitToApp";
import MoreIcon from "@mui/icons-material/MoreVert";
import GroupSettingsIcon from "@mui/icons-material/Settings";
import ShareObjectIcon from "@mui/icons-material/Share";
//import SensorIcon from "@material-ui/icons/Sensor";
import SensorIcon from "@mui/icons-material/SettingsInputAntenna";
import ObjectUsersIcon from "@mui/icons-material/AccountCircle";
import ObjectTeamsIcon from "@mui/icons-material/SupervisedUserCircle";

View file

@ -30,7 +30,6 @@ import { Component, Device } from "models";
import { pond } from "protobuf-ts/pond";
import React, { useCallback, useEffect, useState } from "react";
import { useComponentAPI, useDeviceAPI, useSnackbar } from "hooks";
// import { Autocomplete } from "@material-ui/lab";
import { useBinAPI } from "providers";
import { GetComponentIcon } from "pbHelpers/ComponentType";
import { CheckBox as CheckBoxIcon, CheckBoxOutlineBlank, Remove } from "@mui/icons-material";

View file

@ -310,10 +310,10 @@ export default function BinStorageConditions(props: Props) {
binAPI
.updateBin(bin.key(), settings)
.then(resp => {
.then(_resp => {
openSnack("Updated bin thresholds");
})
.catch(err => {
.catch(_err => {
openSnack("Failed to update bin thresholds");
});
};
@ -369,6 +369,7 @@ export default function BinStorageConditions(props: Props) {
//this will display at all times
const tempDisplay = () => {
// console.log(tempTargets)
let sliderEdge = 40;
let mark: Mark[] = [];

View file

@ -26,7 +26,6 @@ import {
import FullscreenIcon from "@mui/icons-material/Fullscreen";
import FullscreenExitIcon from "@mui/icons-material/FullscreenExit";
import RefreshIcon from "@mui/icons-material/Refresh";
// import { Skeleton, ToggleButton, ToggleButtonGroup } from "@material-ui/lab";
import HumidityIcon from "component/HumidityIcon";
import TemperatureIcon from "component/TemperatureIcon";
import GrainDescriber, { GrainOptions, ToGrainOption } from "grain/GrainDescriber";

View file

@ -1,5 +1,4 @@
import React, { useState, useEffect } from "react";
// import { createStyles, Theme, makeStyles, fade } from "@material-ui/core/styles";
import { detailedDiff } from "deep-object-diff";
import {
List,
@ -13,9 +12,7 @@ import {
} from "@mui/material";
import { Add, ChangeHistory, Remove, Face, Sync } from "@mui/icons-material";
import { amber, red, blue, green } from "@mui/material/colors";
// import MaterialTable from "material-table";
import moment from "moment";
// import { getTableIcons } from "common/ResponsiveTable";
import { pond } from "protobuf-ts/pond";
import { useUserAPI } from "hooks";
import { useMobile } from "hooks";
@ -28,7 +25,7 @@ const addedColour = alpha(green[600], 0.25);
const deletedColour = alpha(red[600], 0.25);
const updatedColour = alpha(blue[600], 0.25);
const resyncedColour = alpha(amber[600], 0.25);
const useStyles = makeStyles((theme: Theme) => {
const useStyles = makeStyles((_theme: Theme) => {
return ({
added: {
backgroundColor: addedColour
@ -270,15 +267,15 @@ export default function DiffHistory(props: Props) {
const {
kind,
name,
headerStyle,
// headerStyle,
cellStyle,
list,
translateKey,
translateValue,
showTitle,
noPaging,
sortingEnabled,
filteringEnabled,
// noPaging,
// sortingEnabled,
// filteringEnabled,
drawer
} = props;
const userAPI = useUserAPI();
@ -365,7 +362,7 @@ export default function DiffHistory(props: Props) {
resolve({ data: data, page: page, totalCount: res.total });
});
})
.catch((err: any) => {
.catch((_err: any) => {
setData([]);
resolve({ data: [], page: 0, totalCount: 0 });
});
@ -487,7 +484,7 @@ export default function DiffHistory(props: Props) {
/>
))}
columns={columns()}
total={0}
total={total}
pageSize={0}
page={0}
setPage={setPage}

View file

@ -1,9 +1,6 @@
import React from "react";
// import { darken, withTheme, WithTheme } from "@material-ui/core/styles";
// import withWidth, { WithWidth } from "@material-ui/core/withWidth";
import { Range } from "common/RangeInput";
import moment from "moment";
// import { RouteComponentProps, withRouter } from "react-router";
import AutoSizer from "react-virtualized-auto-sizer";
import { abbreviateNum } from "utils/numbers";
import { or } from "utils/types";
@ -12,14 +9,12 @@ import {
ScalePropType,
VictoryArea,
VictoryAxis,
VictoryBar,
VictoryChart,
VictoryLabel,
VictoryLegend,
VictoryLine,
VictoryPie,
VictoryScatter,
VictoryStringOrNumberCallback,
VictoryTheme,
VictoryTooltip,
VictoryTooltipProps
@ -34,9 +29,8 @@ import {
Legend
} from "recharts";
import { pond } from "protobuf-ts/pond";
import { styled, WithTheme } from "@mui/styles";
import { getTextPrimary, getTextSecondary } from "theme/text";
import { darken, useMediaQuery, useTheme, withTheme } from "@mui/material";
import { darken, useTheme } from "@mui/material";
import { useWidth } from "hooks";
import { useNavigate } from "react-router-dom";
const VictoryCursorVoronoiContainer: any = createContainer("cursor", "voronoi");
@ -686,7 +680,6 @@ class Graph extends React.Component<Props, State> {
render() {
const theme = useTheme()
const width = useWidth()
const { graphComponent } = this.props;
const { interactionComponents, overlayComponents, dataComponent, updateCounter } = this.state;

View file

@ -1,17 +1,20 @@
import { Icon } from "@mui/material";
import { makeStyles } from "@mui/styles";
// import Image from "material-ui-image";
import { Img as Image } from 'react-image';
const useStyles = makeStyles(() => ({
icon: {
textAlign: "center",
display: "flex", // Ensure flexbox for centering
justifyContent: "center", // Center horizontally
alignItems: "center", // Center vertically
margin: "1px",
overflow: "hidden", // Prevent image overflow
},
img: {
height: "100%",
width: "auto !important"
}
maxHeight: "100%", // Fit within container height
maxWidth: "100%", // Fit within container width
width: "auto", // Maintain aspect ratio
height: "auto", // Maintain aspect ratio
},
}));
interface Props {
@ -29,8 +32,11 @@ export function ImgIcon(props: Props) {
if (!src) return null;
return (
<Icon className={classes.icon} style={{height: iconHeight, width: iconWidth}}>
<Image
<Icon
className={classes.icon}
style={{ height: iconHeight, width: iconWidth }}
>
<img
alt={alt}
className={classes.img}
src={src}
@ -39,4 +45,4 @@ export function ImgIcon(props: Props) {
/>
</Icon>
);
}
}

103
src/common/MapGL.tsx Normal file
View file

@ -0,0 +1,103 @@
import { Tooltip } from "@mui/material";
import { Beenhere } from "@mui/icons-material";
import { useThemeType } from "hooks";
import moment from "moment";
import React, { useEffect, useState } from "react";
import ReactMapGL, { Marker } from "react-map-gl";
export interface Coordinate {
latitude: number;
longitude: number;
timestamp: string;
}
interface Props {
paths: Map<string, Coordinate[]>;
}
export default function MapGL(props: Props) {
const themeType = useThemeType();
const { paths } = props;
const [viewport, setViewport] = useState({
latitude: 52.8118612,
longitude: -106.2459731,
zoom: 12
});
useEffect(() => {
let lat = 52.8118612;
let long = -106.2459731;
if (paths.size > 0) {
let first = Array.from(paths.values())[0][0];
if (first) {
lat = first.latitude;
long = first.longitude;
}
}
setViewport({
latitude: lat,
longitude: long,
zoom: 8
});
}, [paths]);
/*
const changeViewport = (vp: typeof viewport) => {
let transition: any = vp;
if (!transition || transition.width === 0 || transition.height === 0) return;
setViewport(vp);
};
*/
const markers = (): any[] => {
let elems: any[] = [];
paths.forEach((path: Coordinate[], name: string) => {
let num = path.length;
let step = 1;
if (num > 0) {
step = 1.0 / (num * 1.0);
}
path
.sort((a: Coordinate, b: Coordinate) => {
if (a.timestamp < b.timestamp) return 1;
else if (b.timestamp < a.timestamp) return -1;
return 0;
})
.forEach((coord: Coordinate, i: number) => {
let ts = moment(coord.timestamp);
let title = coord.latitude + ", " + coord.longitude;
if (ts.isValid()) {
title += " @ " + ts.format("lll");
}
elems.push(
<Marker key={name + i} latitude={coord.latitude} longitude={coord.longitude}>
<React.Fragment>
<Tooltip title={title}>
<Beenhere style={{ opacity: step * (num - i) }} />
</Tooltip>
</React.Fragment>
</Marker>
);
});
});
return elems;
};
let style =
themeType === "dark" ? "mapbox://styles/mapbox/dark-v10" : "mapbox://styles/mapbox/light-v10";
return (
<ReactMapGL
mapStyle={style}
width="100%"
height="100%"
{...viewport}
onViewStateChange={(e) => {
setViewport({
longitude: e.viewState.longitude,
latitude: e.viewState.latitude,
zoom: e.viewState.zoom,
});
}}>
{markers()}
</ReactMapGL>
);
}

View file

@ -1,6 +1,4 @@
import { IconButton, Tooltip } from "@mui/material";
// import { Theme } from "@/styles/createMuiTheme";
// import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles";
import NotificationsEnabledIcon from "@mui/icons-material/NotificationsActive";
import NotificationsDisabledIcon from "@mui/icons-material/NotificationsOff";
interface Props {

View file

@ -1,6 +1,5 @@
import { Box, BoxProps, Theme, InputLabel } from "@mui/material";
import { makeStyles } from "@mui/styles";
// import NotchedOutline from "@material-ui/core/OutlinedInput/NotchedOutline";
import React, { PropsWithChildren } from "react";
const useStyles = makeStyles((theme: Theme) => {

View file

@ -4,8 +4,6 @@ import {
Grid2 as Grid,
TextField
} from "@mui/material";
// import { Theme } from "@material-ui/core/styles/createMuiTheme";
// import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles";
import { Theme } from "@mui/material";
import { withStyles, WithStyles } from "@mui/styles";
import React from "react";

View file

@ -1,7 +1,6 @@
import { Autocomplete, Avatar, Box, CircularProgress, createFilterOptions } from "@mui/material";
import TextField from "@mui/material/TextField";
import { makeStyles } from "@mui/styles";
// import Autocomplete, { createFilterOptions } from "@material-ui/lab/Autocomplete";
import { isArray } from "lodash";
import React, { CSSProperties } from "react";

View file

@ -10,10 +10,7 @@ import {
useTheme
} from "@mui/material";
import { Replay } from "@mui/icons-material";
// import Link, { LinkProps } from "@material-ui/core/Link";
// import { Skeleton } from "@mui/l";
import { useMobile } from "hooks";
// import { MatchParams } from "navigation/Routes";
import { ReactNode } from "react";
import { useLocation } from "react-router";
import { Link as RouterLink } from "react-router-dom";

View file

@ -1,4 +1,3 @@
// import { useTheme, makeStyles, createStyles, Theme } from "@material-ui/core/styles";
import Joyride, { Step, CallBackProps, STATUS, TooltipRenderProps, Locale } from "react-joyride";
import {
Button,

View file

@ -10,7 +10,6 @@ import {
Select,
Theme
} from "@mui/material";
// import { DateRange, StaticDateRangePicker, DateRangeDelimiter } from "@material-ui/pickers";
import moment, { Moment } from "moment";
import React from "react";
import ReactDOM from "react-dom";

View file

@ -3,7 +3,6 @@ import {
DialogActions,
DialogContent,
Grid,
TextField,
Theme,
Typography
} from "@mui/material";
@ -11,11 +10,9 @@ import moment, { Moment } from "moment";
import { DateRange as DateIcon } from "@mui/icons-material";
import React, { useEffect, useState } from "react";
import ResponsiveDialog from "common/ResponsiveDialog";
// import { DateRange, DateRangeDelimiter, StaticDateRangePicker } from "@material-ui/pickers";
import { DateRangePreset, GetDefaultDateRange, SetDefaultPreset } from "./DateRange";
import { useThemeType } from "hooks";
import { makeStyles } from "@mui/styles";
import dayjs from "dayjs";
interface Props {
startDate: Moment;

View file

@ -22,17 +22,14 @@ import {
ExpandMore,
Close as CloseIcon
} from "@mui/icons-material";
// import { Alert, AlertTitle } from "@material-ui/lab";
import PeriodSelect from "common/time/PeriodSelect";
import SearchSelect, { Option } from "common/SearchSelect";
// import { GrainOptions } from "grain/GrainDescriber";
import { cloneDeep } from "lodash";
import { Component, Device } from "models";
import {
extension,
getMeasurements,
hasDimensions,
hasFan,
isController,
isMultiSensor,
primaryMeasurement
@ -42,16 +39,12 @@ import { pond } from "protobuf-ts/pond";
import { quack } from "protobuf-ts/quack";
import React, { useEffect, useState } from "react";
import { bestUnit, milliToX } from "common/time/duration";
// import CompModes from "component/ComponentMode.json";
// import green from "@material-ui/core/colors/green";
// import red from "@material-ui/core/colors/red";
// import FanPicker from "fans/fanPicker";
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 { getDistanceUnit } from "utils";
import CompModes from "component/ComponentMode.json";
const useStyles = makeStyles((theme: Theme) => {
return ({
@ -168,11 +161,11 @@ export default function ComponentForm(props: Props) {
formComponent.settings.measurementPeriodMs !== formComponent.settings.reportPeriodMs
);
setDataUsageWarningDismissed(localStorage.getItem("dataUsageWarningDismissed") !== null);
// CompModes.forEach((mode: any) => {
// if (formComponent.type() === mode.type && formComponent.subType() === mode.subtype) {
// setCompMode(mode);
// }
// });
CompModes.forEach((mode: any) => {
if (formComponent.type() === mode.type && formComponent.subType() === mode.subtype) {
setCompMode(mode);
}
});
//get the dimension values for the form and convert them to the form display values (m or ft)
let length = formComponent.settings.containerDimensions?.lengthCm ?? 0;

View file

@ -15,7 +15,6 @@ import {
Theme
} from "@mui/material";
import { makeStyles } from "@mui/styles";
//import DragIcon from "@material-ui/icons/DragHandle";
import { DragHandle as DragIcon } from "@mui/icons-material";
import ResponsiveDialog from "common/ResponsiveDialog";
import { useDeviceAPI, usePrevious, useSnackbar } from "hooks";
@ -23,11 +22,11 @@ import { cloneDeep } from "lodash";
import { Component, Device } from "models";
import { sortComponents } from "pbHelpers/Component";
import { pond, quack } from "protobuf-ts/pond";
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { DragDropContext, Draggable, Droppable, DropResult } from "react-beautiful-dnd";
import { useThemeType } from "../hooks/useThemeType";
const useStyles = makeStyles((theme: Theme) => {
const useStyles = makeStyles((_theme: Theme) => {
const themeType = useThemeType()
return ({
item: {

View file

@ -54,10 +54,6 @@ import { or } from "utils/types";
import { ConfigurablePin } from "pbHelpers/AddressTypes";
import ColourPicker from "common/ColourPicker";
import classNames from "classnames";
// import green from "@material-ui/core/colors/green";
// import AddIcon from "@material-ui/icons/AddCircle";
// import RemoveIcon from "@material-ui/icons/RemoveCircle";
// import red from "@material-ui/core/colors/red";
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
import ComponentForm from "./ComponentForm";
import { green, red } from "@mui/material/colors";

View file

@ -13,8 +13,6 @@ import {
Typography,
Theme
} from "@mui/material"
//import { Theme } from "@material-ui/core/styles/createMuiTheme";
//import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles";
import { withStyles, WithStyles } from "@mui/styles";
import DateSelect from "common/time/DateSelect";
@ -93,7 +91,7 @@ class ExportDataSettings extends React.Component<Props, State> {
};
submit = () => {
const { device, component, newMeasurements, user } = this.props;
const { device, component, user } = this.props;
const { startDate, endDate } = this.state;
const { sampleMeasurements, listUnitMeasurements } = this.context;

View file

@ -1,4 +1,3 @@
//import { withStyles, Theme, WithTheme, createStyles, WithStyles } from "@material-ui/core/styles";
import { Theme } from "@mui/material"
import { withStyles, createStyles, WithTheme, WithStyles } from "@mui/styles";
import React from "react";

View file

@ -1,11 +1,10 @@
//import { Box, createStyles, makeStyles, Theme } from "@material-ui/core";
import { Box, Theme } from "@mui/material";
import { makeStyles } from "@mui/styles";
import { Component } from "models";
import { getMeasurementSummary } from "pbHelpers/ComponentType";
import { pond } from "protobuf-ts/pond";
import { quack } from "protobuf-ts/quack";
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { or } from "utils";
interface Props {

View file

@ -5,7 +5,6 @@ import { convertedUnitMeasurement } from "models/UnitMeasurement";
import moment from "moment";
import { pond } from "protobuf-ts/pond";
import React, { useEffect, useState } from "react";
// import Divider from "@material-ui/core/Divider";
import { Plenum } from "models/Plenum";
import { Pressure } from "models/Pressure";
import { GrainCable } from "models/GrainCable";

View file

@ -1,6 +1,4 @@
import { Chip, Theme, Tooltip } from "@mui/material";
// import { Theme } from "@material-ui/core/styles/createMuiTheme";
// import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles";
import React from "react";
import { getFirmwareVersionHelper } from "pbHelpers/FirmwareVersion";
import { withStyles, WithStyles } from "@mui/styles";

View file

@ -13,7 +13,6 @@ import {
Radio,
Box
} from "@mui/material";
//import { blue } from "@material-ui/core/colors";
import { blue } from "@mui/material/colors";
import ResponsiveDialog from "common/ResponsiveDialog";
import React, { useState, useEffect } from "react";

View file

@ -19,7 +19,6 @@ import {
Theme,
Typography
} from "@mui/material";
// import { Alert, AlertTitle, Skeleton } from "@material-ui/lab";
import { GrainOptions, MoistureToHumidity } from "grain";
import GrainDryingChart, { GrainDryingPoint } from "charts/GrainDryingChart";
import SearchSelect, { Option } from "common/SearchSelect";

View file

@ -1,32 +1,31 @@
import {
createStyles,
IconButton,
ListItemIcon,
ListItemText,
makeStyles,
Menu,
MenuItem,
Tooltip
} from "@material-ui/core";
import SettingsIcon from "@material-ui/icons/Settings";
import MoreIcon from "@material-ui/icons/MoreVert";
} from "@mui/material";
import SettingsIcon from "@mui/icons-material/Settings";
import MoreIcon from "@mui/icons-material/MoreVert";
import React, { useState } from "react";
import ObjectUsersIcon from "@material-ui/icons/AccountCircle";
import ObjectTeamsIcon from "@material-ui/icons/SupervisedUserCircle";
import ObjectUsersIcon from "@mui/icons-material/AccountCircle";
import ObjectTeamsIcon from "@mui/icons-material/SupervisedUserCircle";
import ObjectUsers from "user/ObjectUsers";
import { pond } from "protobuf-ts/pond";
import { Scope } from "models";
import ObjectTeams from "teams/ObjectTeams";
import RemoveSelfFromObject from "user/RemoveSelfFromObject";
import ShareObject from "user/ShareObject";
import { blue } from "@material-ui/core/colors";
import RemoveSelfIcon from "@material-ui/icons/ExitToApp";
import { Share } from "@material-ui/icons";
import { blue } from "@mui/material/colors";
import RemoveSelfIcon from "@mui/icons-material/ExitToApp";
import { Share } from "@mui/icons-material";
import { GrainBag } from "models/GrainBag";
import GrainBagSettings from "./grainBagSettings";
import { makeStyles } from "@mui/styles";
const useStyles = makeStyles(() => {
return createStyles({
return ({
shareIcon: {
color: blue["500"],
"&:hover": {
@ -87,7 +86,6 @@ export default function GrainBagActions(props: Props) {
setOpenState({ ...openState, share: true });
setAnchorEl(null);
}}
button
dense>
<ListItemIcon>
<Share className={classes.blueIcon} />
@ -99,8 +97,7 @@ export default function GrainBagActions(props: Props) {
onClick={() => {
setOpenState({ ...openState, users: true });
setAnchorEl(null);
}}
button>
}}>
<ListItemIcon>
<ObjectUsersIcon />
</ListItemIcon>
@ -111,8 +108,7 @@ export default function GrainBagActions(props: Props) {
onClick={() => {
setOpenState({ ...openState, teams: true });
setAnchorEl(null);
}}
button>
}}>
<ListItemIcon>
<ObjectTeamsIcon />
</ListItemIcon>
@ -123,8 +119,7 @@ export default function GrainBagActions(props: Props) {
onClick={() => {
setOpenState({ ...openState, removeSelf: true });
setAnchorEl(null);
}}
button>
}}>
<ListItemIcon>
<RemoveSelfIcon className={classes.red} />
</ListItemIcon>

View file

@ -1,11 +1,11 @@
import { Box, Card, CircularProgress, Typography } from "@material-ui/core";
import { Box, Card, CircularProgress, Typography } from "@mui/material";
import BarGraph, { BarData } from "charts/BarGraph";
import GrainDescriber from "grain/GrainDescriber";
import { GrainBag } from "models/GrainBag";
import moment, { Moment } from "moment";
import { pond } from "protobuf-ts/pond";
import { useGrainBagAPI, useSnackbar } from "providers";
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { getGrainUnit } from "utils";
interface Props {
@ -61,7 +61,7 @@ export default function GrainBagInventoryGraph(props: Props) {
}
setData(barData);
})
.catch(err => {
.catch(_err => {
openSnack("There was a problem retrieving inventory information");
})
.finally(() => {

View file

@ -1,16 +1,14 @@
import {
Box,
Card,
Grid,
Grid2 as Grid,
Slider,
makeStyles,
createStyles,
Typography,
IconButton,
Theme,
useTheme,
darken
} from "@material-ui/core";
} from "@mui/material";
import GrainDescriber from "grain/GrainDescriber";
import GrainTransaction from "grain/GrainTransaction";
import { useMobile } from "hooks";
@ -19,10 +17,11 @@ import { round } from "lodash";
import { GrainBag } from "models/GrainBag";
import moment from "moment";
import { pond } from "protobuf-ts/pond";
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { getThemeType } from "theme";
import { getGrainUnit } from "utils";
import GrainBagSVG from "./grainBagSVG";
import { makeStyles } from "@mui/styles";
interface Props {
grainBag: GrainBag;
@ -36,7 +35,7 @@ enum zIndexPriority {
}
const useStyles = makeStyles((theme: Theme) => {
return createStyles({
return ({
grainOVerlay: {
position: "absolute",
height: "10%",
@ -293,14 +292,14 @@ export default function GrainBagVisualizer(props: Props) {
return (
<Card raised className={classes.cardContent}>
<Grid container justify="flex-start" alignItems="stretch">
<Grid item xs sm md style={{ position: "relative" }}>
<Grid container justifyContent="flex-start" alignItems="stretch">
<Grid style={{ position: "relative" }}>
{overview()}
</Grid>
<Grid item style={{ position: "relative" }}>
<Grid style={{ position: "relative" }}>
{visual()}
</Grid>
<Grid item>{controls()}</Grid>
<Grid>{controls()}</Grid>
</Grid>
{/* dialog for grain inventory transactions */}
<GrainTransaction

View file

@ -24,14 +24,10 @@ import {
} from "@mui/material";
import { makeStyles } from "@mui/styles";
import CancelSubmit from "common/CancelSubmit";
// import { darken, lighten } from "@material-ui/core/styles/colorManipulator";
// import { Theme } from "@material-ui/core/styles/createMuiTheme";
import DeleteButton from "common/DeleteButton";
import Loader from "common/Loader";
import ResponsiveDialog from "common/ResponsiveDialog";
import SearchBar from "common/SearchBar";
// import SearchBar from "common/SearchBar";
// import RemoveGroup from "group/RemoveGroup";
import { useDeviceAPI, useGroupAPI, usePrevious, useSnackbar } from "hooks";
import { Device, Group } from "models";
import { filterDevices } from "pbHelpers/Device";

View file

@ -1,5 +1,3 @@
// import { useTheme, Theme } from "@material-ui/core";
import { Theme, useTheme } from "@mui/material";
export function useThemeType() {

View file

@ -22,7 +22,6 @@ import {
} from "@mui/material";
import AddIcon from "@mui/icons-material/AddCircle";
import RemoveIcon from "@mui/icons-material/RemoveCircle";
// import { TimePicker } from "@material-ui/pickers";
import classNames from "classnames";
import DeleteButton from "common/DeleteButton";
import ResponsiveDialog from "common/ResponsiveDialog";
@ -557,7 +556,7 @@ export default function InteractionSettings(props: Props) {
setInteraction(updatedInteraction);
};
const toggleReport = (event: any) => {
const toggleReport = (_event: any) => {
let updatedInteraction = Interaction.clone(interaction);
let notifications = or(
interaction.settings.notifications,
@ -568,7 +567,7 @@ export default function InteractionSettings(props: Props) {
setInteraction(updatedInteraction);
};
const toggleNotify = (event: any) => {
const toggleNotify = (_event: any) => {
let updatedInteraction = Interaction.clone(interaction);
let notifications = or(
updatedInteraction.settings.notifications,

View file

@ -15,7 +15,6 @@ import {
Typography
} from "@mui/material";
import { Settings } from "@mui/icons-material";
// import { ToggleButton, ToggleButtonGroup } from "@material-ui/lab";
import { useInteractionsAPI, usePrevious, useSnackbar } from "hooks";
import { cloneDeep } from "lodash";
import { Component, Device, Interaction } from "models";
@ -156,7 +155,7 @@ export default function InteractionsOverview(props: Props) {
step={measurement.step()}
track={false}
value={measurement.toDisplay(condition.value ? condition.value : 0)}
onChange={(event, value) =>
onChange={(_event, value) =>
updateConditionValue(source, interactionIndex, conditionIndex, value)
}
/>
@ -202,14 +201,14 @@ export default function InteractionsOverview(props: Props) {
) => {
interactionsAPI
.updateInteraction(Number(deviceID), settings)
.then((response: any) => {
.then((_response: any) => {
let updatedDirtyInteractions = cloneDeep(dirtyInteractions);
updatedDirtyInteractions.set(index, false);
setDirtyInteractions(updatedDirtyInteractions);
success("Successfully updated the interaction for " + component.name());
refreshCallback();
})
.catch((err: any) => {
.catch((_err: any) => {
error("Error occurred while updating the interaction for " + component.name());
});
};

View file

@ -24,14 +24,15 @@ import { Link, useLocation } from "react-router-dom";
import BinsIcon from "products/Bindapt/BinsIcon";
import { useGlobalState } from "providers";
import {
hasTutorialPlaylist,
IsAdaptiveAgriculture,
IsAdCon,
isBXT,
// hasTutorialPlaylist,
// IsAdaptiveAgriculture,
// IsAdCon,
// isBXT,
IsMiVent,
IsOmniAir
// IsOmniAir
} from "services/whiteLabel";
import MiningIcon from "products/ventilation/MiningIcon";
import { useAuth0 } from "@auth0/auth0-react";
const drawerWidth = 230;
@ -101,6 +102,7 @@ interface Props {
export default function SideNavigator(props: Props) {
const { open, onOpen, onClose } = props;
const { isAuthenticated } = useAuth0()
const theme = useTheme();
const width = useWidth();
const classes = useStyles();
@ -233,7 +235,7 @@ export default function SideNavigator(props: Props) {
</Toolbar>
<Divider />
{/* {isAuthenticated || isOffline() ? authenticatedSideMenu() : unauthenticatedSideMenu()} */}
{authenticatedSideMenu()}
{isAuthenticated && authenticatedSideMenu()}
</SwipeableDrawer>
);
}

View file

@ -29,9 +29,6 @@ import {
Typography
} from "@mui/material";
import { ExpandMore, RemoveCircle as RemoveIcon, AddCircle as AddIcon } from "@mui/icons-material";
//import RemoveIcon from "@material-ui/icons/RemoveCircle";
//import { ExpandMore } from "@material-ui/icons";
//import AddIcon from "@material-ui/icons/AddCircle";
import ResponsiveDialog from "common/ResponsiveDialog";
import { Option } from "common/SearchSelect";
import classNames from "classnames";
@ -47,11 +44,8 @@ import { useNotificationAPI } from "providers/pond/notificationAPI";
import React, { useEffect, useState } from "react";
import { capitalize, cloneDeep } from "lodash";
import { timeOfDayDescriptor } from "pbHelpers/Interaction";
//import { TimePicker } from "@material-ui/pickers";
import { TimePicker } from "@mui/x-date-pickers";
//import { getThemeType } from "theme";
import { getThemeType } from "theme/themeType";
//import { green, red } from "@material-ui/core/colors";
import { green, red } from "@mui/material/colors";
import { makeStyles } from "@mui/styles";
@ -251,7 +245,7 @@ export default function ObjectAlerts(props: Props) {
setRecentNotifications(resp.data.notifications);
setTotalNotifications(resp.data.total);
})
.catch(err => {})
.catch(_err => {})
.finally(() => {
setNotificationsLoading(false);
});
@ -303,7 +297,7 @@ export default function ObjectAlerts(props: Props) {
setRecentNotifications([...c]);
}
})
.catch(err => {})
.catch(_err => {})
.finally(() => {
setNotificationsLoading(false);
});
@ -373,10 +367,10 @@ export default function ObjectAlerts(props: Props) {
});
interactionsAPI
.addInteractionToComponents(compIds, newAlert)
.then(resp => {
.then(_resp => {
openSnack("interaction added to selected components");
})
.catch(err => {
.catch(_err => {
openSnack("there was a problem adding the interaction to the selected components");
});
setNewAlertOpen(false);

View file

@ -1,5 +1,4 @@
//import { Button, Grid, InputAdornment, TextField } from "@material-ui/core";
import { Button, Grid, InputAdornment, TextField } from "@mui/material";
import { Button, Grid2 as Grid, InputAdornment, TextField } from "@mui/material";
import SearchSelect, { Option } from "common/SearchSelect";
import { GrainOptions } from "grain";
import { pond } from "protobuf-ts/pond";
@ -77,7 +76,7 @@ export default function BulkBinSettings(props: Props) {
openSnack("Successfully updated " + resp.data.successfull + " bins");
}
})
.catch(err => {
.catch(_err => {
openSnack("Failed to update bins");
});
};
@ -86,7 +85,7 @@ export default function BulkBinSettings(props: Props) {
<React.Fragment>
<Grid container direction="row" spacing={2} alignContent="center" alignItems="center">
{/* first row */}
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Bin Name"
@ -96,7 +95,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<SearchSelect
label="Grain Type"
selected={grainOption}
@ -111,7 +110,7 @@ export default function BulkBinSettings(props: Props) {
options={GrainOptions()}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Grain Variant"
@ -122,7 +121,7 @@ export default function BulkBinSettings(props: Props) {
/>
</Grid>
{/* second row */}
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Custom Grain"
@ -132,7 +131,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Bushels"
@ -143,7 +142,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Capacity"
@ -155,7 +154,7 @@ export default function BulkBinSettings(props: Props) {
/>
</Grid>
{/* last row */}
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Bin Height"
@ -173,7 +172,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Bin Diameter"
@ -191,7 +190,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="High Temp Warning"
@ -211,7 +210,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<TextField
fullWidth
label="Low Temp Warning"
@ -231,7 +230,7 @@ export default function BulkBinSettings(props: Props) {
}}
/>
</Grid>
<Grid item xs={gridItemWidth}>
<Grid size={{ xs: gridItemWidth }}>
<Button
variant="contained"
color="primary"

View file

@ -1,4 +1,3 @@
//import { Button, Grid, TextField } from "@material-ui/core";
import { Button, Grid2 as Grid, TextField } from "@mui/material";
import SearchSelect, { Option } from "common/SearchSelect";
import { GrainOptions } from "grain";
@ -68,7 +67,7 @@ export default function BulkGrainBagSettings(props: Props) {
openSnack("Successfully updated " + resp.data.successfull + " bins");
}
})
.catch(err => {
.catch(_err => {
openSnack("Failed to update bins");
});
};

View file

@ -28,16 +28,12 @@ import {
import BinActions from "bin/BinActions";
import BinHistory from "bin/BinHistory";
import { useComponentAPI, useMobile } from "hooks";
// import { useHistory } from "react-router";
import { Bin as IBin, binScope } from "models";
// import { MatchParams } from "navigation/Routes";
import { pond, quack } from "protobuf-ts/pond";
import { useBinAPI, useGlobalState } from "providers";
import React, { useCallback, useEffect, useRef, useState } from "react";
// import { useRouteMatch } from "react-router";
import PageContainer from "./PageContainer";
import { Component, Device, Interaction } from "models";
// import { ToggleButton, ToggleButtonGroup } from "@material-ui/lab";
import BinLightIcon from "assets/products/bindapt/binLight.png";
import BinDarkIcon from "assets/products/bindapt/binDark.png";
import NotesIcon from "@mui/icons-material/Notes";
@ -214,7 +210,7 @@ export default function Bin(props: Props) {
const [binPresets, setBinPresets] = useState<DevicePreset[]>([]);
const [missedCableReadings, setMissedCableReadings] = useState(0);
const handleChange = (event: React.ChangeEvent<{}>, newValue: number) => {
const handleChange = (_event: React.ChangeEvent<{}>, newValue: number) => {
setValue(newValue);
};
@ -482,7 +478,7 @@ export default function Bin(props: Props) {
// return true;
// };
const refresh = (showSnack?: boolean) => {
const refresh = (_showSnack?: boolean) => {
// binAPI.getBin(bin.key()).then(resp => {
// let bin = IBin.any(resp.data);
// setBin(bin);

View file

@ -51,7 +51,6 @@ import BinUtilizationChart from "charts/BinUtilizationChart";
import GrainDescriber, { grainName } from "grain/GrainDescriber";
// import GrainBagList from "grainBag/grainBagList";
// import GrainBagSettings from "grainBag/grainBagSettings";
// import { ToggleButton, ToggleButtonGroup } from "@material-ui/lab";
import { useMobile, useWidth } from "hooks";
import { Dictionary } from "lodash";
// import { Bin, Interaction, BinYard as BinYardModel } from "models";

View file

@ -1,5 +1,4 @@
// import Grid2 from "@material-ui/core/Grid2";
import Graph, {
import {
GraphComponent,
GraphOrientation,
GraphPoint,
@ -8,7 +7,6 @@ import Graph, {
} from "common/Graph";
import { Range } from "common/RangeInput";
import { Option } from "common/SearchSelect";
import GPSMap from "component/GPS";
import { Interaction } from "models";
import {
AirQuality,
@ -48,7 +46,6 @@ import { multilineCapCableData } from "./ComponentTypes/CapacitorCable";
import { findInteractionsAsSource } from "pbHelpers/Interaction";
import { pond } from "protobuf-ts/pond";
import { quack } from "protobuf-ts/quack";
import React from "react";
import { notNull, or } from "utils/types";
import { emptyComponentId } from "./Component";
@ -63,7 +60,6 @@ import { LineData, Point } from "charts/measurementCharts/MultiLineGraph";
import moment, { Moment } from "moment";
import { avg } from "utils";
import { Airflow } from "./ComponentTypes/Airflow";
import { Grid2 } from "@mui/material";
const COMPONENT_TYPE_MAP = new Map<quack.ComponentType, Function>([
[quack.ComponentType.COMPONENT_TYPE_INVALID, Invalid],
@ -240,7 +236,7 @@ export function unitMeasurementSummary(
});
//if nodes are excluded splice them out of the val array so they are not displayed in the summary
if (excludedNodes) {
vals.forEach((val, i) => {
vals.forEach((_val, i) => {
if (excludedNodes.includes(i)) {
vals.splice(i, 1);
}

110
src/pbHelpers/Fan.ts Normal file
View file

@ -0,0 +1,110 @@
import { pond } from "protobuf-ts/pond";
import { getThemeType } from "theme";
import inLineDarkIcon from "assets/components/inLineAerationDark.png";
import inLineLightIcon from "assets/components/inLineAerationLight.png";
import lowSpeedDark from "assets/components/lowSpeedCentrifugalFanDark.png";
import lowSpeedLight from "assets/components/lowSpeedCentrifugalFanLight.png";
import highSpeedDark from "assets/components/fullCentrifugalFanDark.png";
import highSpeedLight from "assets/components/fullCentrifugalFanLight.png";
interface FanSizeDescriber {
key: pond.FanHp;
label: string;
numerical: number;
}
const getFanSizeDescribers = (): FanSizeDescriber[] => {
return [
{ key: pond.FanHp.FAN_HP_UNKNOWN, label: "Unknown", numerical: 0 },
{ key: pond.FanHp.FAN_HP_THREE, label: "3HP", numerical: 3 },
{ key: pond.FanHp.FAN_HP_FIVE, label: "5HP", numerical: 5 },
{ key: pond.FanHp.FAN_HP_SEVENPOINTFIVE, label: "7HP", numerical: 7 },
{ key: pond.FanHp.FAN_HP_SEVEN, label: "7.5HP", numerical: 7.5 },
{ key: pond.FanHp.FAN_HP_TEN, label: "10HP", numerical: 10 },
{ key: pond.FanHp.FAN_HP_FIFTEEN, label: "15HP", numerical: 15 },
{ key: pond.FanHp.FAN_HP_TWENTY, label: "20HP", numerical: 20 },
{ key: pond.FanHp.FAN_HP_TWENTYFIVE, label: "25HP", numerical: 25 },
{ key: pond.FanHp.FAN_HP_THIRTY, label: "30HP", numerical: 30 }
];
};
interface FanTypeDescriber {
key: pond.FanType;
label: string;
sizes: pond.FanHp[];
}
const getFanTypeDescribers = (): FanTypeDescriber[] => {
return [
{ key: pond.FanType.FAN_TYPE_UNKNOWN, label: "Unknown", sizes: [] },
{
key: pond.FanType.FAN_TYPE_CENTRIFUGAL_INLINE,
label: "In-line Aeration",
sizes: [
pond.FanHp.FAN_HP_THREE,
pond.FanHp.FAN_HP_FIVE,
pond.FanHp.FAN_HP_SEVEN,
pond.FanHp.FAN_HP_TEN
]
},
{
key: pond.FanType.FAN_TYPE_CENTRIFUGAL_HIGH_SPEED,
label: "High Speed Centrifugal",
sizes: [
pond.FanHp.FAN_HP_THREE,
pond.FanHp.FAN_HP_FIVE,
pond.FanHp.FAN_HP_SEVENPOINTFIVE,
pond.FanHp.FAN_HP_TEN
]
},
{
key: pond.FanType.FAN_TYPE_CENTRIFUGAL_LOW_SPEED,
label: "Low Speed Centrifugal",
sizes: [
pond.FanHp.FAN_HP_FIVE,
pond.FanHp.FAN_HP_SEVENPOINTFIVE,
pond.FanHp.FAN_HP_TEN,
pond.FanHp.FAN_HP_FIFTEEN,
pond.FanHp.FAN_HP_TWENTY,
pond.FanHp.FAN_HP_TWENTYFIVE,
pond.FanHp.FAN_HP_THIRTY
]
}
];
};
export function GetFanTypes(): FanTypeDescriber[] {
return getFanTypeDescribers();
}
function getFanTypeDescriber(type: pond.FanType): FanTypeDescriber | undefined {
const fanTypes = getFanTypeDescribers();
return fanTypes.find(t => t.key === type);
}
export function GetFanTypeSizes(type: pond.FanType): FanSizeDescriber[] {
let options: FanSizeDescriber[] = [];
let typeDesc = getFanTypeDescriber(type);
if (typeDesc) {
let matches = typeDesc.sizes;
options = getFanSizeDescribers().filter(s => matches.includes(s.key));
}
return options;
}
export function getFanIcon(type: pond.FanType): string {
switch (type) {
case pond.FanType.FAN_TYPE_CENTRIFUGAL_INLINE:
if (getThemeType() === "light") return inLineLightIcon;
return inLineDarkIcon;
case pond.FanType.FAN_TYPE_CENTRIFUGAL_HIGH_SPEED:
if (getThemeType() === "light") return highSpeedLight;
return highSpeedDark;
case pond.FanType.FAN_TYPE_CENTRIFUGAL_LOW_SPEED:
if (getThemeType() === "light") return lowSpeedLight;
return lowSpeedDark;
}
return "";
}

View file

@ -1,5 +1,3 @@
//import { Avatar, ButtonBase, createStyles, makeStyles, Theme, Tooltip } from "@material-ui/core";
//import { Tune as PresetsIcon, ViewList as ComponentsIcon } from "@material-ui/icons";
import { Avatar, ButtonBase, Theme, Tooltip } from "@mui/material";
import { Tune as PresetsIcon, ViewList as ComponentsIcon } from "@mui/icons-material";
import { makeStyles } from "@mui/styles";

View file

@ -2,7 +2,6 @@ import MineDarkIcon from "assets/components/mineIconDark.png";
import MineLightIcon from "assets/components/mineIconLight.png";
import { ImgIcon } from "common/ImgIcon";
import { useThemeType } from "hooks";
import React from "react";
interface Props {
type?: "light" | "dark";

View file

@ -2,7 +2,6 @@ import VentilationDarkIcon from "assets/products/ventilation/ventIconDark.png";
import VentilationLightIcon from "assets/products/ventilation/ventIconLight.png";
import { ImgIcon } from "common/ImgIcon";
import { useThemeType } from "hooks";
import React from "react";
interface Props {
type?: "light" | "dark";

View file

@ -1,3 +1,4 @@
import { quack } from "protobuf-ts/quack";
import { or } from "utils/types";
function decode(encoded: string) {
@ -10,16 +11,16 @@ function decode(encoded: string) {
return res;
}
export function parseGPS(gps: { location: any; latitude: number; longitude: number; uncertainty: number; wifiAccessPoints: any[]; cellTower: any; }) {
export function parseGPS(gps: { location: any; latitude: number; longitude: number; uncertainty: number; wifiAccessPoints: any[]; cellTower: any; } | quack.GPS | null | undefined) {
gps = or(gps, {});
let lat = 0;
let lng = 0;
let accuracy = 0;
let request: { wifiAccessPoints?: any; cellTowers?: any; } | undefined = undefined;
if (gps.location) {
lat = gps.latitude;
lng = gps.longitude;
accuracy = gps.uncertainty;
lat = gps.location.latitude;
lng = gps.location.latitude;
accuracy = gps.location.uncertainty;
} else if (gps.wifiAccessPoints) {
request = { wifiAccessPoints: [] };
gps.wifiAccessPoints.forEach(function(ap) {

View file

@ -18,7 +18,6 @@ import {
ListItemText,
Tab,
Tabs,
TextField,
Theme,
Tooltip,
Typography
@ -29,7 +28,6 @@ import {
LinkOff,
RemoveCircle as RemoveCircleIcon
} from "@mui/icons-material";
// import { MobileDateTimePicker } from "@material-ui/pickers";
import ResponsiveDialog from "common/ResponsiveDialog";
import { usePermissionAPI, usePrevious, useSnackbar } from "hooks";
import { cloneDeep } from "lodash";

View file

@ -12,7 +12,6 @@ import {
FormControlLabel,
FormGroup,
FormLabel,
Grid,
Grid2,
IconButton,
List,
@ -27,8 +26,6 @@ import {
Typography,
useTheme
} from "@mui/material";
// import { Theme } from "@material-ui/core/styles/createMuiTheme";
// import { PaletteColor } from "@material-ui/core/styles/createPalette";
import RemoveUserIcon from "@mui/icons-material/RemoveCircle";
import EditIcon from "@mui/icons-material/EditOutlined";
import ShareIcon from "@mui/icons-material/Share";
@ -220,7 +217,7 @@ export default function ObjectUsers(props: Props) {
console.log(users);
permissionAPI
.updatePermissions(scope, users)
.then((response: any) => {
.then((_response: any) => {
success("Users were sucessfully updated for " + label);
close();
refreshCallback();

View file

@ -23,7 +23,6 @@ import CounterclockwiseIcon from "@mui/icons-material/RotateLeft";
import { useGlobalState, useMineAPI } from "providers";
import { Component, Device } from "models";
import { Sensor } from "./drawable/Sensor";
// import { ToggleButton } from "@material-ui/lab";
import { VentTBreak } from "./drawable/VentTBreak";
import InteractionSettings from "interactions/InteractionSettings";
import { UnitMeasurement } from "models/UnitMeasurement";