diff --git a/src/bin/BinComponents.tsx b/src/bin/BinComponents.tsx index aa501a1..33a912a 100644 --- a/src/bin/BinComponents.tsx +++ b/src/bin/BinComponents.tsx @@ -108,7 +108,7 @@ export default function BinComponents(props: Props) { let mounted = true; setDevicesLoading(true); deviceAPI - .list(100000, 0, "asc", "name") + .list(100000, 0, "asc", "name",undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,as) .then(response => { if (mounted) { let data = response.data.devices ? response.data.devices : []; @@ -135,7 +135,7 @@ export default function BinComponents(props: Props) { return () => { mounted = false; }; - }, [deviceAPI]); + }, [deviceAPI, as]); useEffect(() => { loadDevices(); @@ -149,7 +149,7 @@ export default function BinComponents(props: Props) { comps = []; setComponentsLoading(true); componentAPI - .list(selectedDevice, false, [selectedDevice.toString()], ["device"], true) + .list(selectedDevice, false, [selectedDevice.toString()], ["device"], true, as) .then(resp => { let d = pond.ListComponentsResponse.fromObject(resp.data); d.components.forEach(comp => { @@ -171,7 +171,7 @@ export default function BinComponents(props: Props) { }); } }, - [selectedDevice, componentAPI, deviceComponents, snackbar] + [selectedDevice, componentAPI, deviceComponents, snackbar, as] ); useEffect(() => { @@ -326,7 +326,7 @@ export default function BinComponents(props: Props) { settings.grainType = binGrain; settings.defaultMutations = [pond.Mutator.MUTATOR_EMC]; componentAPI - .update(device, settings) + .update(device, settings, undefined, undefined, as) .then(resp => { snackbar.info("Component added to bin, and updated cables grain type"); }) diff --git a/src/bin/BinVisualizerV2.tsx b/src/bin/BinVisualizerV2.tsx index 5236ebf..854c733 100644 --- a/src/bin/BinVisualizerV2.tsx +++ b/src/bin/BinVisualizerV2.tsx @@ -150,29 +150,12 @@ const useStyles = makeStyles((theme: Theme) => { bottomSpacing: { marginBottom: theme.spacing(1) }, - sliderRoot: {}, - sliderThumb: { - left: 23 - }, - mobileSliderThumb: { - left: 28 - }, - sliderTrack: { - height: "100%", - }, - sliderRail: { - height: "100%", - }, sliderValLabel: { - // left: -20, height: 30, width: 30, - top: -15, + //top: -15, background: "transparent" }, - sliderLabel: { - background: "gold" - } }); }); @@ -1483,10 +1466,10 @@ export default function BinVisualizer(props: Props) { orientation="vertical" value={fillPercentage} classes={{ - root: classes.sliderRoot, - rail: classes.sliderRail, - track: classes.sliderTrack, - thumb: isMobile ? classes.mobileSliderThumb : classes.sliderThumb, + // root: classes.sliderRoot, + // rail: classes.sliderRail, + // track: classes.sliderTrack, + // thumb: isMobile ? classes.mobileSliderThumb : classes.sliderThumb, valueLabel: classes.sliderValLabel, }} style={{ height: "100%", color: sliderColour }} diff --git a/src/bin/GrainNodeInteractions.tsx b/src/bin/GrainNodeInteractions.tsx index 83f9350..36af290 100644 --- a/src/bin/GrainNodeInteractions.tsx +++ b/src/bin/GrainNodeInteractions.tsx @@ -147,7 +147,7 @@ export default function GrainNodeInteractions(props: Props) { settings.defaultMutations = [pond.Mutator.MUTATOR_EMC]; settings.grainType = grain; componentAPI - .update(device.id(), settings, [binKey], ["bin"]) + .update(device.id(), settings, [binKey], ["bin"], as) .then(resp => { openSnack("EMC set on cable " + cable.name()); updateComponentCallback(cable.key()); @@ -157,7 +157,7 @@ export default function GrainNodeInteractions(props: Props) { const submit = () => { componentAPI - .update(device.id(), cable.settings, [binKey], ["bin"]) + .update(device.id(), cable.settings, [binKey], ["bin"], as) .then(resp => { //after updating the component update the interactions with the new subtypes //TODO-CS: make function to update multiple interactions at once to avoid this loop if it becomes a problem diff --git a/src/charts/GraphSettings.tsx b/src/charts/GraphSettings.tsx index 0b2b095..faf4496 100644 --- a/src/charts/GraphSettings.tsx +++ b/src/charts/GraphSettings.tsx @@ -11,6 +11,7 @@ import ResponsiveDialog from "common/ResponsiveDialog"; import { useComponentAPI, useSnackbar } from "hooks"; import { Component } from "models"; import { pond } from "protobuf-ts/pond"; +import { useGlobalState } from "providers"; // import { MatchParams } from "navigation/Routes"; // import { useRouteMatch } from "react-router"; import { useEffect, useState } from "react"; @@ -40,6 +41,7 @@ export default function GraphSettings(props: Props) { currentMax, newChart } = props; + const [{as}] = useGlobalState(); const [newMutation, setNewMutation] = useState(0); const componentAPI = useComponentAPI(); const deviceID = useParams<{ deviceID: string }>()?.deviceID ?? ""; @@ -58,7 +60,7 @@ export default function GraphSettings(props: Props) { defaultMutations.push(newMutation); } componentAPI - .update(parseInt(deviceID), comp.settings) + .update(parseInt(deviceID), comp.settings, undefined, undefined, as) .then(() => openSnack("Mutations Updated")); closeDialog(); }; @@ -70,7 +72,7 @@ export default function GraphSettings(props: Props) { defaultMuts.splice(defaultMuts.indexOf(mutation)); } componentAPI - .update(parseInt(deviceID), comp.settings) + .update(parseInt(deviceID), comp.settings, undefined, undefined, as) .then(() => openSnack("Mutations Updated")); closeDialog(); }; diff --git a/src/common/DeviceLinkDrawer.tsx b/src/common/DeviceLinkDrawer.tsx index b337791..b01113c 100644 --- a/src/common/DeviceLinkDrawer.tsx +++ b/src/common/DeviceLinkDrawer.tsx @@ -20,6 +20,7 @@ import { Component, Device } from "models"; import { pond } from "protobuf-ts/pond"; import React, { useEffect, useState } from "react"; import { makeStyles } from "@mui/styles"; +import { useGlobalState } from "providers"; interface TabPanelProps { children?: React.ReactNode; @@ -83,6 +84,7 @@ export default function DeviceLinkDrawer(props: Props) { devicePrefChanged } = props; const [value, setValue] = useState(0); + const [{as}] = useGlobalState(); const deviceAPI = useDeviceAPI(); const classes = useStyles(); const isMobile = useMobile(); @@ -114,7 +116,13 @@ export default function DeviceLinkDrawer(props: Props) { undefined, undefined, undefined, - true + true, + undefined, + undefined, + undefined, + undefined, + undefined, + as ) .then(resp => { let devMap = new Map(); @@ -131,7 +139,7 @@ export default function DeviceLinkDrawer(props: Props) { setLoadingDevices(false); }); //eslint-disable-next-line react-hooks/exhaustive-deps - }, [deviceAPI]); + }, [deviceAPI, as]); useEffect(() => { let searchedDevices: Map = new Map(); diff --git a/src/component/AddComponentManualDialog.tsx b/src/component/AddComponentManualDialog.tsx index 53ad4a7..062cfbf 100644 --- a/src/component/AddComponentManualDialog.tsx +++ b/src/component/AddComponentManualDialog.tsx @@ -2,6 +2,7 @@ import { Dialog, DialogActions, DialogContent, DialogTitle, Grid2, TextField } f import CancelSubmit from "common/CancelSubmit"; import { useComponentAPI, useSnackbar } from "hooks"; import { pond } from "protobuf-ts/pond"; +import { useGlobalState } from "providers"; import { useState } from "react"; import { or } from "utils"; @@ -13,12 +14,13 @@ interface Props { export default function AddComponentManualDialog (props: Props) { const { open, onClose, device } = props; + const [{as}] = useGlobalState(); const componentAPI = useComponentAPI(); const snackbar = useSnackbar(); const [component, setComponent] = useState(pond.ComponentSettings.create()) const onSubmit = () => { - componentAPI.add(device, component).then(() => { + componentAPI.add(device, component, as).then(() => { snackbar.success("Component added") }) } diff --git a/src/component/AddCompsFromDiag.tsx b/src/component/AddCompsFromDiag.tsx index fcd1457..fb3a80f 100644 --- a/src/component/AddCompsFromDiag.tsx +++ b/src/component/AddCompsFromDiag.tsx @@ -22,7 +22,7 @@ import { import ResponsiveDialog from "common/ResponsiveDialog"; import { Component, Device } from "models"; import { pond, quack } from "protobuf-ts/pond"; -import { useComponentAPI, useSnackbar } from "providers"; +import { useComponentAPI, useGlobalState, useSnackbar } from "providers"; import React, { useEffect, useState } from "react"; import { CableInfo } from "./ComponentDiagnostics"; import ComponentForm from "./ComponentForm"; @@ -67,6 +67,7 @@ interface CompStep { export default function AddCompsFromDiag(props: Props) { const { diagComponent, port, cableInfo, open, closeDialog, device, refreshCallback } = props; const [steps, setSteps] = useState([]); + const [{as}] = useGlobalState(); const classes = useStyles(); const [currentStep, setCurrentStep] = useState(0); const [components, setComponents] = useState([]); @@ -125,7 +126,7 @@ export default function AddCompsFromDiag(props: Props) { c.components.push(component.settings); }); compAPI - .addMultiComponents(device.id(), c) + .addMultiComponents(device.id(), c, as) .then(resp => { success("Components added to Device"); }) diff --git a/src/component/ComponentActions.tsx b/src/component/ComponentActions.tsx index 9e3ac32..8c778cb 100644 --- a/src/component/ComponentActions.tsx +++ b/src/component/ComponentActions.tsx @@ -82,7 +82,7 @@ export default function ComponentActions(props: Props) { const [anchorEl, setAnchorEl] = useState(null); const [componentSettingsMode, setComponentSettingsMode] = useState(""); const [isJSON, setIsJSON] = useState(false); - const [{ user }] = useGlobalState(); + const [{ user, as }] = useGlobalState(); const openMoreMenu = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); @@ -182,6 +182,7 @@ export default function ComponentActions(props: Props) { isJSON={isJSON} // newMeasurements={newStructure} user={user} + as={as} /> ); diff --git a/src/component/ComponentCard.tsx b/src/component/ComponentCard.tsx index 00d4ebe..19482bc 100644 --- a/src/component/ComponentCard.tsx +++ b/src/component/ComponentCard.tsx @@ -120,7 +120,7 @@ export default function ComponentCard(props: Props) { const navigate = useNavigate() const location = useLocation() const [sensors, setSensors] = useState([]); - const [{ user, showErrors }] = useGlobalState(); + const [{ user, showErrors, as }] = useGlobalState(); const updateControllerState = (checked: boolean) => { let updatedComponent = cloneDeep(component); @@ -130,7 +130,7 @@ export default function ComponentCard(props: Props) { let describe = controllerModeLabel(newMode); componentAPI - .update(device.id(), updatedComponent.settings) + .update(device.id(), updatedComponent.settings, undefined, undefined, as) .then(() => { success(component.name() + "'s mode was set to " + describe); refreshCallback(updatedComponent); diff --git a/src/component/ComponentDiagnostics.tsx b/src/component/ComponentDiagnostics.tsx index 902b768..1fa0d05 100644 --- a/src/component/ComponentDiagnostics.tsx +++ b/src/component/ComponentDiagnostics.tsx @@ -16,7 +16,7 @@ import moment from "moment"; import { getHumanReadableAddress } from "pbHelpers/AddressType"; import { pond } from "protobuf-ts/pond"; import { quack } from "protobuf-ts/quack"; -import { useComponentAPI } from "providers"; +import { useComponentAPI, useGlobalState } from "providers"; import React, { useEffect, useState } from "react"; // import { getThemeType } from "theme"; import AddCompsFromDiag from "./AddCompsFromDiag"; @@ -60,6 +60,7 @@ const useStyles = makeStyles((theme: Theme) => { export default function ComponentDiagnostics(props: Props) { const { component, device, refreshCallback } = props; + const [{as}] = useGlobalState(); const [portNumber, setPortNumber] = useState(""); const compAPI = useComponentAPI(); const classes = useStyles(); @@ -91,7 +92,12 @@ export default function ComponentDiagnostics(props: Props) { moment().toISOString(), 2, 0, - "desc" + "desc", + undefined, + undefined, + undefined, + undefined, + as ) .then(resp => { setMeasurements(resp.data.measurements); @@ -100,7 +106,7 @@ export default function ComponentDiagnostics(props: Props) { setLoadingMeasurements(false); }); } - }, [component, device, compAPI]); //eslint-disable-line react-hooks/exhaustive-deps + }, [component, device, compAPI, as]); //eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { let cableIDs: number[] = []; diff --git a/src/component/ComponentOrder.tsx b/src/component/ComponentOrder.tsx index 2ca19cf..1e8d0b0 100644 --- a/src/component/ComponentOrder.tsx +++ b/src/component/ComponentOrder.tsx @@ -25,6 +25,7 @@ import { pond, quack } from "protobuf-ts/pond"; import { useEffect, useState } from "react"; import { DragDropContext, Draggable, Droppable, DropResult } from "react-beautiful-dnd"; import { useThemeType } from "../hooks/useThemeType"; +import { useGlobalState } from "providers"; const useStyles = makeStyles((_theme: Theme) => { const themeType = useThemeType() @@ -87,6 +88,7 @@ const filteredComponents = (components: Component[]) => { export default function ComponentOrder(props: ListProps) { const { open, close, device, devicePreferences } = props; + const [{as}] = useGlobalState(); const deviceAPI = useDeviceAPI(); const { error, success } = useSnackbar(); const prevDisplayOrder = usePrevious(devicePreferences.childDisplayOrder); @@ -113,7 +115,7 @@ export default function ComponentOrder(props: ListProps) { let updatedPreferences = cloneDeep(devicePreferences); updatedPreferences.childDisplayOrder = componentOrder.map(c => c.locationString()); deviceAPI - .updatePreferences(device.id(), updatedPreferences) + .updatePreferences(device.id(), updatedPreferences, undefined, undefined, as) .then(() => success("Successfully update the component display order")) .catch(() => { error("Error occured while updating the component display order"); diff --git a/src/component/ComponentSettings.tsx b/src/component/ComponentSettings.tsx index 3431a33..ac68259 100644 --- a/src/component/ComponentSettings.tsx +++ b/src/component/ComponentSettings.tsx @@ -64,6 +64,7 @@ import { } from "@mui/icons-material" import CancelSubmit from "common/CancelSubmit"; +import { useGlobalState } from "providers"; const useStyles = makeStyles((theme: Theme) => { return ({ @@ -158,6 +159,7 @@ export default function ComponentSettings(props: Props) { addressTypeRestriction, deviceComponentPrefs } = props; + const [{as}] = useGlobalState(); const prevComponent = usePrevious(props.component); const prevIsDialogOpen = usePrevious(isDialogOpen); const steps = [0, 1]; @@ -304,7 +306,7 @@ export default function ComponentSettings(props: Props) { //component.settings.calibrationCoefficient = Number(form.coefficient); if (cableID > 0) component.settings.addressType = cableID + 8; componentAPI - .add(device.id(), component.settings) + .add(device.id(), component.settings, as) .then((response: any) => { success(component.name() + " was successfully added!"); refresh(); @@ -318,13 +320,13 @@ export default function ComponentSettings(props: Props) { const updateComponent = () => { const component = formComponent; componentAPI - .update(device.id(), component.settings, getContextKeys(), getContextTypes()) + .update(device.id(), component.settings, getContextKeys(), getContextTypes(), as) .then((response: any) => { success(component.name() + " was successfully updated!"); let updatedPrefs = pond.DeviceComponentPreferences.create(); updatedPrefs.excludedNodes = excludedNodes; deviceAPI - .updateComponentPreferences(device.id(), component.key(), updatedPrefs) + .updateComponentPreferences(device.id(), component.key(), updatedPrefs, undefined, undefined, as) .then(resp => { console.log("Preferences updated"); }) @@ -343,7 +345,7 @@ export default function ComponentSettings(props: Props) { const removeComponent = () => { componentAPI - .remove(device.id(), formComponent.key(), getContextKeys(), getContextTypes()) + .remove(device.id(), formComponent.key(), getContextKeys(), getContextTypes(), as) .then((response: any) => { success(formComponent.name() + " was successfully removed!"); refresh(); diff --git a/src/component/ExportDataSettings.tsx b/src/component/ExportDataSettings.tsx index cbfc8c5..c50e375 100644 --- a/src/component/ExportDataSettings.tsx +++ b/src/component/ExportDataSettings.tsx @@ -43,6 +43,7 @@ interface Props extends WithStyles { isJSON?: boolean; newMeasurements?: boolean; user?: User; + as?: string } interface State { @@ -91,9 +92,9 @@ class ExportDataSettings extends React.Component { }; submit = () => { - const { device, component, user } = this.props; + const { device, component, user, as } = this.props; const { startDate, endDate } = this.state; - const { sampleMeasurements, listUnitMeasurements } = this.context; + const { /*sampleMeasurements*/ listUnitMeasurements } = this.context; this.setState({ isLoading: true }); // if (newMeasurements) { @@ -107,7 +108,9 @@ class ExportDataSettings extends React.Component { "desc", undefined, [device.id().toString()], - ["device"] + ["device"], + undefined, + as ) .then(resp => { let measurements = resp.data.measurements.map(um => UnitMeasurement.any(um, user)); diff --git a/src/device/ArcGISDeviceData.tsx b/src/device/ArcGISDeviceData.tsx index d049740..c12c53b 100644 --- a/src/device/ArcGISDeviceData.tsx +++ b/src/device/ArcGISDeviceData.tsx @@ -15,6 +15,7 @@ import DateSelect from "common/time/DateSelect"; import { useDeviceAPI } from "hooks"; import { Component, Device } from "models"; import { Moment } from "moment"; +import { useGlobalState } from "providers"; import React, { useState } from "react"; import { downloadJSON } from "utils"; @@ -27,6 +28,7 @@ interface Props { export default function ArcGISDeviceData(props: Props) { const { open, close, device, components } = props; + const [{as}] = useGlobalState(); const [startDate, setStartDate] = useState(GetDefaultDateRange().start); const [endDate, setEndDate] = useState(GetDefaultDateRange().end); const [includedComponents, setIncludedComponents] = useState([]); @@ -89,7 +91,8 @@ export default function ArcGISDeviceData(props: Props) { limit, 0, "asc", - "timestamp" + "timestamp", + as ) .then(resp => { downloadJSON(resp.data, filename + ".json"); diff --git a/src/device/Connection.tsx b/src/device/Connection.tsx index a65c5b1..b017019 100644 --- a/src/device/Connection.tsx +++ b/src/device/Connection.tsx @@ -15,6 +15,7 @@ import { useDeviceAPI, useSnackbar } from "hooks"; import { getContextKeys, getContextTypes } from "pbHelpers/Context"; import { useState } from "react"; import { makeStyles } from "@mui/styles"; +import { useGlobalState } from "providers"; const useStyles = makeStyles((theme: Theme) => { return ({ @@ -36,6 +37,7 @@ export default function Connection(props: Props) { const deviceAPI = useDeviceAPI(); const { success, error } = useSnackbar(); const { deviceID, deviceName, open, close } = props; + const [{as}] = useGlobalState(); const [gateway, setGateway] = useState(""); const [password, setPassword] = useState(""); const [passwordVisible, setPasswordVisible] = useState(false); @@ -71,7 +73,7 @@ export default function Connection(props: Props) { let keys = getContextKeys(); let types = getContextTypes(); deviceAPI - .setWifi(deviceID, gateway, password, keys, types) + .setWifi(deviceID, gateway, password, keys, types, as) .then(() => success("Connection settings sent to " + deviceName)) .catch(() => error("Failed to send connection settings to " + deviceName)) .finally(() => handleClose()); diff --git a/src/device/DevicePresetsFromPicker.tsx b/src/device/DevicePresetsFromPicker.tsx index 768e7a0..900df87 100644 --- a/src/device/DevicePresetsFromPicker.tsx +++ b/src/device/DevicePresetsFromPicker.tsx @@ -193,7 +193,7 @@ export default function DevicePresets(props: DevicePresetsProps) { comps = []; setLoading(true); let interactionPromise = interactionAPI.listInteractionsByDevice(deviceIndex, undefined, as); - let componentPromise = componentAPI.list(deviceIndex, undefined, [binKey], ["bin"], true); + let componentPromise = componentAPI.list(deviceIndex, undefined, [binKey], ["bin"], true, as); let dComponents = new Map(); Promise.all([componentPromise, interactionPromise]) .then(([compResp, interactionResp]) => { @@ -367,13 +367,13 @@ export default function DevicePresets(props: DevicePresetsProps) { //if the device id was passed in the mode was set to storage and we need to set them to off heaters.forEach(heater => { componentAPI - .update(deviceIndex, heater.settings) + .update(deviceIndex, heater.settings, undefined, undefined, as) .then() .catch(); }); fans.forEach(fan => { componentAPI - .update(deviceIndex, fan.settings) + .update(deviceIndex, fan.settings, undefined, undefined, as) .then() .catch(); }); diff --git a/src/device/DeviceSettings.tsx b/src/device/DeviceSettings.tsx index cf7b576..dea3cc7 100644 --- a/src/device/DeviceSettings.tsx +++ b/src/device/DeviceSettings.tsx @@ -89,7 +89,7 @@ const deviceFromForm = (device: Device): Device => { export default function DeviceSettings(props: Props) { const classes = useStyles(); - const [{ user }] = useGlobalState(); + const [{ user, as }] = useGlobalState(); const navigate = useNavigate(); const { success, error } = useSnackbar(); const deviceAPI = useDeviceAPI(); @@ -254,7 +254,7 @@ export default function DeviceSettings(props: Props) { deviceForm.settings.extensionComponents = [compExtOne, compExtTwo, compExtThree]; deviceForm.settings.mutations = linearMutations; deviceAPI - .update(deviceID, deviceForm.settings) + .update(deviceID, deviceForm.settings, as) .then((_response: any) => { success(deviceName + " was successfully updated!"); close(); @@ -277,7 +277,7 @@ export default function DeviceSettings(props: Props) { const removeDevice = () => { const deviceName = deviceForm.name(); deviceAPI - .remove(device.id()) + .remove(device.id(), as) .then((_response: any) => { success(deviceName + " was successfully deleted!"); navigate("/"); diff --git a/src/device/DeviceViewer.tsx b/src/device/DeviceViewer.tsx index e228968..b366f4d 100644 --- a/src/device/DeviceViewer.tsx +++ b/src/device/DeviceViewer.tsx @@ -104,7 +104,8 @@ export default function Device(props: Props) { undefined, [deviceID.toString()], ["device"], - true + true, + as ); let interactionsPromise = interactionsAPI.listInteractionsByDevice(deviceID, undefined, as); let groupPromise: Promise = Promise.resolve(undefined); @@ -343,7 +344,7 @@ export default function Device(props: Props) { let updatedPreferences = cloneDeep(preferences); updatedPreferences.notify = !preferences.notify; deviceAPI - .updatePreferences(deviceID, updatedPreferences) + .updatePreferences(deviceID, updatedPreferences, undefined, undefined, as) .then(() => setPreferences(updatedPreferences)) .catch(() => { error( diff --git a/src/device/DeviceWizard.tsx b/src/device/DeviceWizard.tsx index 33da9bf..5a944f1 100644 --- a/src/device/DeviceWizard.tsx +++ b/src/device/DeviceWizard.tsx @@ -26,7 +26,7 @@ import { import { GetDeviceProductIcon, GetDeviceProductLabel } from "products/DeviceProduct"; import { pond } from "protobuf-ts/pond"; import { quack } from "protobuf-ts/quack"; -import { useComponentAPI, useSnackbar } from "providers"; +import { useComponentAPI, useGlobalState, useSnackbar } from "providers"; import React, { useState } from "react"; import DeviceSVG, { PortInformation } from "./deviceSVG"; import { makeStyles } from "@mui/styles"; @@ -69,6 +69,7 @@ const useStyles = makeStyles((theme: Theme) => { export default function DeviceWizard(props: Props) { const { device, components, refreshCallback } = props; + const [{as}] = useGlobalState(); const [componentDialogOpen, setComponentDialogOpen] = useState(false); const [availableOffsets, setAvailableOffsets] = useState(new Map()); const [availablePositions, setAvailablePositions] = useState(new Map()); @@ -159,7 +160,7 @@ export default function DeviceWizard(props: Props) { componentSettings.reportPeriodMs = 600000; componentSettings.name = "Port " + selectedPort.label + " Auto Detect"; compAPI - .add(device.id(), componentSettings) + .add(device.id(), componentSettings, as) .then(resp => { success("Added Auto Detect Component to Port"); }) diff --git a/src/device/ProvisionDevice.tsx b/src/device/ProvisionDevice.tsx index 820ddf3..8ef7f44 100644 --- a/src/device/ProvisionDevice.tsx +++ b/src/device/ProvisionDevice.tsx @@ -23,6 +23,7 @@ import { Backpack, Device } from "models"; import { backpackOptions, genericBackpacks } from "pbHelpers/Backpack"; import { pond } from "protobuf-ts/pond"; import React, { useEffect, useState } from "react"; +import { useGlobalState } from "providers"; interface Props { isOpen: boolean; @@ -34,6 +35,7 @@ export default function ProvisionDevice(props: Props) { const deviceAPI = useDeviceAPI(); const backpackAPI = useBackpackAPI(); const { error, success, warning, info } = useSnackbar(); + const [{as}] = useGlobalState(); const { isOpen, closeDialogCallback, refreshCallback } = props; const [provisioned, setProvisioned] = useState(false); const [idHex, setIdHex] = useState(""); @@ -98,7 +100,7 @@ export default function ProvisionDevice(props: Props) { setDeviceLoading(true); const deviceID = parseInt(idHex, 16); deviceAPI - .get(deviceID) + .get(deviceID, undefined, undefined, undefined, as) .then(response => { let rDevice = Device.any(response.data); setDevice(rDevice); @@ -149,7 +151,7 @@ export default function ProvisionDevice(props: Props) { const submitProvision = () => { setProvisioned(false); deviceAPI - .add("", "", assembleBackpack()) + .add("", "", assembleBackpack(), as) .then((response: any) => { let updatedIdHex = response.data.idHex; let updatedKeyHex = response.data.keyHex; @@ -173,7 +175,7 @@ export default function ProvisionDevice(props: Props) { settings.name = name; settings.description = description; deviceAPI - .update(deviceID, settings) + .update(deviceID, settings, as) .then(() => { success("Device " + deviceID.toString() + " was successfully updated"); }) diff --git a/src/grain/GrainDryingCalculator.tsx b/src/grain/GrainDryingCalculator.tsx deleted file mode 100644 index e5d5a33..0000000 --- a/src/grain/GrainDryingCalculator.tsx +++ /dev/null @@ -1,388 +0,0 @@ -import { - Alert, - AlertTitle, - Box, - Button, - Card, - CardActions, - CardContent, - CardHeader, - darken, - Divider, - Grid2 as Grid, - InputAdornment, - Skeleton, - Step, - StepLabel, - Stepper, - TextField, - Theme, - Typography -} from "@mui/material"; -import { GrainOptions, MoistureToHumidity } from "grain"; -import GrainDryingChart, { GrainDryingPoint } from "charts/GrainDryingChart"; -import SearchSelect, { Option } from "common/SearchSelect"; -import { DateRange, GetDefaultDateRange } from "common/time/DateRange"; -import DateSelect from "common/time/DateSelect"; -import { useComponentAPI } from "hooks"; -import { cloneDeep } from "lodash"; -import { Component, Device } from "models"; -import moment, { Moment } from "moment"; -import { extension } from "pbHelpers/ComponentType"; -import { pond } from "protobuf-ts/pond"; -import { quack } from "protobuf-ts/quack"; -import { useEffect, useState } from "react"; -import { FindPlenumSensors } from "./GrainUtils"; -import { makeStyles } from "@mui/styles"; - -const useStyles = makeStyles((theme: Theme) => { - const bg = darken(theme.palette.background.paper, theme.palette.mode === "light" ? 0.1 : 0.15); - - return ({ - card: { - backgroundColor: bg - }, - stepper: { - padding: 0 - }, - header: { - paddingBottom: theme.spacing(1) - }, - actions: { - paddingTop: theme.spacing(1) - }, - gutter: { - padding: `${theme.spacing(1)}px ${theme.spacing(2)}px` - } - }); -}); - -interface Props { - devices: Device[]; - loading: boolean; -} - -const devicesToOptions = (devices: Device[]): Option[] => { - return devices.map(d => { - return { value: d.id().toString(), label: d.name() } as Option; - }); -}; - -//NOREF: has no references in codebase, is this not used anywhere? -export default function GrainDryingCalculator(props: Props) { - const classes = useStyles(); - const componentAPI = useComponentAPI(); - const grainOptions = GrainOptions(); - const { devices, loading } = props; - const [device, setDevice] = useState