updated the component and device api's to have as be a parameter for the function

This commit is contained in:
csawatzky 2025-04-22 14:33:19 -06:00
parent c617ebf868
commit b62c7dbe5c
39 changed files with 346 additions and 651 deletions

View file

@ -4,7 +4,7 @@ import DeviceViewer from "device/DeviceViewer";
import MapMarkerSettings from "maps/MapMarkerSettings";
import { Device } from "models";
import { pond } from "protobuf-ts/pond";
import { useDeviceAPI, useSnackbar } from "providers";
import { useDeviceAPI, useGlobalState, useSnackbar } from "providers";
import React, { useEffect, useState } from "react";
interface Props {
@ -19,6 +19,7 @@ interface Props {
export default function DeviceDrawer(props: Props) {
const { open, onClose, selectedDevice, devices, removeMarker, updateMarker, moveMap } = props;
const [{as}] = useGlobalState();
const [device, setDevice] = useState<Device>(Device.create());
const [openMarkerSettings, setOpenMarkerSettings] = useState(false);
const deviceAPI = useDeviceAPI();
@ -96,7 +97,7 @@ export default function DeviceDrawer(props: Props) {
settings.longitude = 0;
settings.latitude = 0;
deviceAPI
.update(device.id(), settings)
.update(device.id(), settings, as)
.then(resp => {
openSnack("Marker Removed");
//then use the removeMarker prop function to update the markers in the parent map
@ -138,7 +139,7 @@ export default function DeviceDrawer(props: Props) {
let settings = device.settings;
settings.theme = newTheme;
deviceAPI
.update(device.id(), settings)
.update(device.id(), settings, as)
.then(resp => {
openSnack("marker settings updated");
updateMarker(device.id().toString(), settings);

View file

@ -503,7 +503,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
const loadDevices = useCallback(() => {
deviceAPI
.list(500, 0, "asc", "name")
.list(500, 0, "asc", "name", undefined, undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,as)
.then(resp => {
let map = new Map<string, DeviceModel>();
let newDevMarkers: Map<string, MarkerData> = new Map();
@ -557,7 +557,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
.catch(() => {
openSnack("Failed to load Devices");
});
}, [deviceAPI, openSnack]); // eslint-disable-line react-hooks/exhaustive-deps
}, [deviceAPI, openSnack, as]); // eslint-disable-line react-hooks/exhaustive-deps
const fmIcon = (type: pond.FieldMarkerType, size: number) => {
switch (type) {
@ -1042,7 +1042,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
device.settings.longitude = long;
device.settings.latitude = lat;
deviceAPI
.update(device.id(), device.settings)
.update(device.id(), device.settings, as)
.then(resp => {
openSnack("Device location Updated");
if (deviceOptions.includes(device)) {

View file

@ -194,7 +194,7 @@ export default function ConstructionMapController(props: Props) {
if (loadingDevices) return;
setLoadingDevices(true);
deviceAPI
.list(500, 0, "asc", "name", undefined, undefined, undefined, undefined, undefined, true)
.list(500, 0, "asc", "name", undefined, undefined, undefined, undefined, undefined, true, undefined, undefined,undefined,undefined,undefined,as)
.then(resp => {
let devOps: Device[] = []; //only devices that are not mapped
let deviceMap: Map<string, Device> = new Map<string, Device>(); // all devices
@ -252,7 +252,7 @@ export default function ConstructionMapController(props: Props) {
.catch(err => {
openSnack("Failed to Load Devices");
});
}, [deviceAPI, openSnack]); // eslint-disable-line react-hooks/exhaustive-deps
}, [deviceAPI, openSnack, as]); // eslint-disable-line react-hooks/exhaustive-deps
const loadGroups = useCallback(() => {
groupAPI
@ -527,7 +527,7 @@ export default function ConstructionMapController(props: Props) {
device.settings.longitude = long;
device.settings.latitude = lat;
deviceAPI
.update(device.id(), device.settings)
.update(device.id(), device.settings, as)
.then(resp => {
openSnack("Device location Updated");
if (devOps.includes(device)) {