diff --git a/src/app/App.css b/src/app/App.css index 3d829d9..3b20b88 100644 --- a/src/app/App.css +++ b/src/app/App.css @@ -39,4 +39,8 @@ html, body, #root { .MuiPopper-root { z-index: 1501 !important; +} + +.MuiPopover-root { + z-index: 1501 !important; } \ No newline at end of file diff --git a/src/app/Header.tsx b/src/app/Header.tsx index 4bb8e1f..6e4dbaf 100644 --- a/src/app/Header.tsx +++ b/src/app/Header.tsx @@ -125,7 +125,7 @@ export default function Header() { {setNavOpen(true)}} onClose={() => {setNavOpen(false)}} /> - {isMobile && {setNavOpen(true)}} sideIsOpen={navOpen} />} + {isMobile && {setNavOpen(isOpen)}} sideIsOpen={navOpen} />} ) } \ No newline at end of file diff --git a/src/bin/BinSettings.tsx b/src/bin/BinSettings.tsx index 3a9f15d..e280917 100644 --- a/src/bin/BinSettings.tsx +++ b/src/bin/BinSettings.tsx @@ -2255,7 +2255,7 @@ export default function BinSettings(props: Props) { } return ( - + {mode === "add" ? ( - + {drawerBody} diff --git a/src/device/DeviceViewer.tsx b/src/device/DeviceViewer.tsx index b366f4d..52c9693 100644 --- a/src/device/DeviceViewer.tsx +++ b/src/device/DeviceViewer.tsx @@ -12,7 +12,7 @@ import { useDeviceAPI, useInteractionsAPI, useSnackbar, - //useUsageAPI, + useUsageAPI, useUserAPI } from "hooks"; import { cloneDeep } from "lodash"; @@ -74,7 +74,7 @@ export default function Device(props: Props) { const deviceAPI = useDeviceAPI(); const componentAPI = useComponentAPI(); const interactionsAPI = useInteractionsAPI(); - //const usageAPI = useUsageAPI(); + const usageAPI = useUsageAPI(); const userAPI = useUserAPI(); const [isLoading, setIsLoading] = useState(false); const [device, setDevice] = useState(DeviceModel.create()); @@ -147,25 +147,25 @@ export default function Device(props: Props) { error(err); }) .finally(() => setIsLoading(false)); - // usageAPI - // .getUsage(deviceID, moment().subtract(1, "days")) - // .then((res: any) => { - // let usage = res.data; - // if (usage) { - // let rCellularStatus = "active"; - // let rCellularUsage = 0; - // let sessions: any[] = []; - // if (usage.sessions) { - // sessions = usage.sessions.filter((session: any) => { - // return moment(session.begin).isAfter(moment().subtract(1, "days")); - // }); - // } - // sessions.forEach((session: any) => (rCellularUsage += Number(or(session.bytes, 0)))); - // setCellularStatus(rCellularStatus); - // setCellularUsage(rCellularUsage); - // } - // }) - // .catch(err => {}); + usageAPI + .getUsage(deviceID, moment().subtract(1, "days")) + .then((res: any) => { + let usage = res.data; + if (usage) { + let rCellularStatus = "active"; + let rCellularUsage = 0; + let sessions: any[] = []; + if (usage.sessions) { + sessions = usage.sessions.filter((session: any) => { + return moment(session.begin).isAfter(moment().subtract(1, "days")); + }); + } + sessions.forEach((session: any) => (rCellularUsage += Number(or(session.bytes, 0)))); + setCellularStatus(rCellularStatus); + setCellularUsage(rCellularUsage); + } + }) + .catch(err => {}); }, [componentAPI, props.device, deviceID, error, interactionsAPI, /*usageAPI*/, userAPI, user, as]); useEffect(() => { diff --git a/src/device/DeviceWizard.tsx b/src/device/DeviceWizard.tsx index 5a944f1..d426c21 100644 --- a/src/device/DeviceWizard.tsx +++ b/src/device/DeviceWizard.tsx @@ -210,13 +210,14 @@ export default function DeviceWizard(props: Props) { }; const setupCard = () => { + const deviceIcon = GetDeviceProductIcon(device) return ( diff --git a/src/grainBag/grainBagVisualizer.tsx b/src/grainBag/grainBagVisualizer.tsx index 794a1f3..3c76f1f 100644 --- a/src/grainBag/grainBagVisualizer.tsx +++ b/src/grainBag/grainBagVisualizer.tsx @@ -53,29 +53,6 @@ const useStyles = makeStyles((theme: Theme) => { position: "relative", width: "auto", marginRight: 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, - background: "transparent" - }, - sliderLabel: { - background: "gold" } }); }); @@ -279,13 +256,6 @@ export default function GrainBagVisualizer(props: Props) { - - + + Approximate Area: {field.acres()}ac - + Grain: {field.grain() === pond.Grain.GRAIN_CUSTOM @@ -243,11 +243,11 @@ export default function FieldDrawer(props: Props) { : GrainDescriber(field.crop()).name} - + Grain Variant: {field.settings.grainSubtype} - + Land Location: {field.landLoc()} diff --git a/src/pages/AviationMap.tsx b/src/pages/AviationMap.tsx index d0a3140..450f453 100644 --- a/src/pages/AviationMap.tsx +++ b/src/pages/AviationMap.tsx @@ -6,7 +6,7 @@ export default function AviationMap() { const location = useLocation(); return ( - + {location.state !== undefined && location.state !== null && location.state.long !== undefined && diff --git a/src/pages/Bin.tsx b/src/pages/Bin.tsx index 15ce8db..c6c84a8 100644 --- a/src/pages/Bin.tsx +++ b/src/pages/Bin.tsx @@ -43,7 +43,6 @@ import BindaptIcon from "products/Bindapt/BindaptIcon"; import Close from "@mui/icons-material/Close"; import Chat from "chat/Chat"; import TasksIcon from "products/Construction/TasksIcon"; -// import TaskViewer from "tasks/TaskViewer"; import FieldsIcon from "products/AgIcons/FieldsIcon"; import BinComponentTypes from "bin/BinComponentTypes"; import { Plenum } from "models/Plenum"; @@ -66,6 +65,7 @@ import BinConditioningCard from "bin/BinConditioningCard"; import { makeStyles, styled } from "@mui/styles"; import { useNavigate, useParams } from "react-router-dom"; import { Controller } from "models/Controller"; +import TaskViewer from "tasks/TaskViewer"; interface TabPanelProps { children?: React.ReactNode; @@ -547,10 +547,11 @@ export default function Bin(props: Props) { }; const tasks = () => { + console.log(showTasks()) if (showTasks()) { return ( - {/* */} + ); } @@ -1144,11 +1145,11 @@ export default function Bin(props: Props) { anchor="right" classes={{ paper: classes.drawerPaper }} onClose={() => setTaskDrawer(false)}> - + setTaskDrawer(false)}> - {/* */} + )} diff --git a/src/pages/ConstructionSiteMap.tsx b/src/pages/ConstructionSiteMap.tsx index 27eaf46..8f1b690 100644 --- a/src/pages/ConstructionSiteMap.tsx +++ b/src/pages/ConstructionSiteMap.tsx @@ -6,7 +6,7 @@ export default function ConstructionSiteMap() { const location = useLocation(); return ( - + {location.state !== undefined && location.state !== null && location.state.long !== undefined && diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index ab0a586..dd634f5 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -20,6 +20,7 @@ import { sameComponentID, sortComponents } from "pbHelpers/Component"; import { isController } from "pbHelpers/ComponentType"; import { or } from "utils"; import ComponentDiagnostics from "component/ComponentDiagnostics"; +import DeviceWizard from "device/DeviceWizard"; export default function DevicePage() { const deviceAPI = useDeviceAPI() @@ -358,16 +359,16 @@ export default function DevicePage() { - + {isMobile ? ( <> - {/* */} + refreshCallback={loadDevice} + /> {diagnosticComponents.map(comp => ( @@ -382,12 +383,12 @@ export default function DevicePage() { ) : ( <> - {/* */} + refreshCallback={loadDevice} + /> diff --git a/src/pages/FieldMap.tsx b/src/pages/FieldMap.tsx index 2fc42f4..9f8c112 100644 --- a/src/pages/FieldMap.tsx +++ b/src/pages/FieldMap.tsx @@ -5,7 +5,7 @@ import { useLocation } from "react-router"; export default function FieldMap() { const location = useLocation(); return ( - + {location.state !== undefined && location.state !== null && location.state.long !== undefined && diff --git a/src/pages/Gate.tsx b/src/pages/Gate.tsx index e45ffae..c873a76 100644 --- a/src/pages/Gate.tsx +++ b/src/pages/Gate.tsx @@ -87,7 +87,7 @@ export default function Gate(props: Props) { //const match = useRouteMatch(); //const gateID = props.gateID ?? match.params.gateID; const { gateKey } = props - const gateID = gateKey ?? useParams<{ gateID: string }>()?.gateID ?? ""; + const gateID = gateKey ?? useParams<{ gateKey: string }>()?.gateKey ?? ""; const classes = useStyles(); const gateAPI = useGateAPI(); const userAPI = useUserAPI(); @@ -115,13 +115,17 @@ export default function Gate(props: Props) { }; useEffect(() => { + console.log(gateID) let key = gateID; let kind = "gate"; if (as) { key = as; kind = "team"; } + console.log(key) + console.log(kind) userAPI.getUser(user.id(), { key: key, kind: kind } as Scope).then(resp => { + console.log(resp) setPermissions(resp.permissions); }); }, [as, gateID, userAPI, user]); diff --git a/src/providers/index.ts b/src/providers/index.ts index dafcf34..62f551b 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -30,7 +30,7 @@ export { useTeamAPI, useImagekitAPI, useTaskAPI, //TODO: update api with resolve, reject - // useUsageAPI, + useUsageAPI,//TODO: update api with resolve, reject useUserAPI, // useStripeAPI, useDataDogProxyAPI, diff --git a/src/providers/pond/pond.tsx b/src/providers/pond/pond.tsx index bcaeaa5..6f5f1f0 100644 --- a/src/providers/pond/pond.tsx +++ b/src/providers/pond/pond.tsx @@ -32,6 +32,7 @@ import PreferenceProvider, {usePreferenceAPI} from "./preferenceAPI"; import TaskProvider, { useTaskAPI } from "./taskAPI"; import DataDogProvider, { useDataDogProxyAPI } from "./datadogProxyAPI"; import ContractProvider, { useContractAPI } from "./contractAPI"; +import UsageProvider, { useUsageAPI } from "./usageAPI"; // import NoteProvider from "providers/noteAPI"; export const pondURL = (partial: string, demo: boolean = false): string => { @@ -80,7 +81,9 @@ export default function PondProvider(props: PropsWithChildren) { - {children} + + {children} + @@ -147,5 +150,6 @@ export { usePreferenceAPI, useTaskAPI, useDataDogProxyAPI, - useContractAPI + useContractAPI, + useUsageAPI }; diff --git a/src/providers/pond/usageAPI.tsx b/src/providers/pond/usageAPI.tsx new file mode 100644 index 0000000..92de655 --- /dev/null +++ b/src/providers/pond/usageAPI.tsx @@ -0,0 +1,99 @@ +import { useHTTP } from "hooks"; +import moment from "moment"; +import { useGlobalState } from "providers"; +import { createContext, PropsWithChildren, useContext } from "react"; +import { pondURL } from "./pond"; + +export interface IUsageAPIContext { + getUsage: ( + deviceID: number | string, + startDate?: any, + demo?: boolean, + keys?: string[], + types?: string[] + ) => Promise; + getUsages: (deviceIDs: number[], startDate?: any) => Promise; + listUsages: (startDate?: any) => Promise; +} + +export const UsageAPIContext = createContext({} as IUsageAPIContext); + +function usageQuery(deviceIDs?: number[], startDate?: any): string { + let query = ""; + let symbol: "?" | "&" = "?"; + if (deviceIDs && deviceIDs.length > 0) { + query = query.concat(symbol + "ids=" + deviceIDs.join(",")); + symbol = "&"; + } + if (startDate) { + let start = moment(startDate).toISOString(); + query = query.concat(symbol + "start=" + start); + symbol = "&"; + } + return query; +} + +interface Props {} + +export default function UsageProvider(props: PropsWithChildren) { + const { children } = props; + const { get } = useHTTP(); + const [{ as }] = useGlobalState(); + + const getUsage = ( + deviceID: number | string, + startDate?: any, + demo: boolean = false, + keys?: string[], + types?: string[] + ) => { + if (as && !(types && types.length > 0 && types[0] === "team")) + return get( + pondURL( + "/devices/" + + deviceID + + "/usage" + + usageQuery(undefined, startDate) + + "&as=" + + as + + (keys ? "&keys=" + keys.toString() : "") + + (types ? "&types=" + types.toString() : ""), + demo + ) + ); + return get( + pondURL( + "/devices/" + + deviceID + + "/usage" + + usageQuery(undefined, startDate) + + (keys ? "&keys=" + keys.toString() : "") + + (types ? "&types=" + types.toString() : ""), + demo + ) + ); + }; + + const getUsages = (deviceIDs: number[], startDate?: any) => { + if (as) return get(pondURL("/usage/devices" + usageQuery(deviceIDs, startDate) + "&as=" + as)); + return get(pondURL("/usage/devices" + usageQuery(deviceIDs, startDate))); + }; + + const listUsages = (startDate?: any) => { + if (as) return get(pondURL("/usage" + usageQuery(undefined, startDate) + "&as=" + as)); + return get(pondURL("/usage" + usageQuery(undefined, startDate))); + }; + + return ( + + {children} + + ); +} + +export const useUsageAPI = () => useContext(UsageAPIContext); diff --git a/src/tasks/TaskSettings.tsx b/src/tasks/TaskSettings.tsx index 63e800a..9f92548 100644 --- a/src/tasks/TaskSettings.tsx +++ b/src/tasks/TaskSettings.tsx @@ -19,6 +19,7 @@ import { useSnackbar, useUserAPI } from "hooks"; import { useEffect } from "react"; import { Task, teamScope, User } from "models"; import ColourPicker from "common/ColourPicker"; +import ResponsiveDialog from "common/ResponsiveDialog"; interface Props { open: boolean; @@ -159,7 +160,7 @@ export default function TaskSettings(props: Props) { }; return ( - + New Task )} - + ); } diff --git a/src/teams/ObjectTeams.tsx b/src/teams/ObjectTeams.tsx index 409b363..d327291 100644 --- a/src/teams/ObjectTeams.tsx +++ b/src/teams/ObjectTeams.tsx @@ -40,6 +40,7 @@ import { blue, red } from "@mui/material/colors"; import { useNavigate } from "react-router-dom"; import { makeStyles } from "@mui/styles"; import { Share, RemoveCircle as RemoveUserIcon } from "@mui/icons-material"; +import CancelSubmit from "common/CancelSubmit"; const useStyles = makeStyles((theme: Theme) => { const avatarBG = theme.palette.secondary["700" as keyof PaletteColor]; @@ -547,22 +548,29 @@ export default function ObjectTeams(props: Props) { const actions = () => { return ( - - - - {!cardMode && ( - - )} - {canManageUsers && ( - - )} - - - ); + + ) + // return ( + // + // + // + // {!cardMode && ( + // + // )} + // {canManageUsers && ( + // + // )} + // + // + // ); }; const dialogs = () => {