temp commit so i can change branches

This commit is contained in:
csawatzky 2025-10-21 10:40:14 -06:00
parent bced311508
commit 6dbb7c3432
7 changed files with 160 additions and 87 deletions

4
package-lock.json generated
View file

@ -42,7 +42,7 @@
"mui-tel-input": "^7.0.0",
"notistack": "^3.0.1",
"openweathermap-ts": "^1.2.10",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#mipca_reports",
"query-string": "^9.2.1",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",
@ -10911,7 +10911,7 @@
},
"node_modules/protobuf-ts": {
"version": "1.0.0",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#d0ac088df3822c10c0497f49173d1679b4e107b0",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#4aa7c4efefa38e86c21ec08cddcbd7f789b38464",
"dependencies": {
"protobufjs": "^6.8.8"
}

View file

@ -54,7 +54,7 @@
"mui-tel-input": "^7.0.0",
"notistack": "^3.0.1",
"openweathermap-ts": "^1.2.10",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#mipca_reports",
"query-string": "^9.2.1",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",

View file

@ -1,5 +1,5 @@
import { Gate } from "models/Gate";
import { Box, Card, IconButton, List, ListItem, ListItemText, Theme, Typography } from "@mui/material";
import { Box, Button, Card, IconButton, List, ListItem, ListItemText, Theme, Typography } from "@mui/material";
import React, { useCallback, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useMobile } from "hooks";
@ -13,6 +13,7 @@ import GateSettings from "./GateSettings";
import { useGateAPI, useGlobalState } from "providers";
import { Settings } from "@mui/icons-material";
import { cloneDeep } from "lodash";
import GateReports from "reports/MiPCA/GateReports";
interface Props {
//gates: Gate[];
@ -54,6 +55,7 @@ export default function GateList(props: Props) {
const [gates, setGates] = useState<Gate[]>([])
const [selectedGate, setSelectedGate] = useState<Gate | undefined>()
const [search, setSearch] = useState("")
const [openReports, setOpenReports] = useState(false)
const goToGate = (gate: Gate) => {
let path = "/terminals/" + gate.key;
@ -208,6 +210,8 @@ export default function GateList(props: Props) {
const gateTable = () => {
return (
<ResponsiveTable<Gate>
actions={<Button onClick={()=>{setOpenReports(true)}}>Generate Reports</Button>}
title="Terminal Gates"
page={tablePage}
pageSize={pageSize}
columns={isMobile || props.useMobile ? mobileCols() : desktopCols()}
@ -237,7 +241,8 @@ export default function GateList(props: Props) {
)
};
return <Box>
return (
<React.Fragment>
<GateSettings
open={gateDialog}
gate={selectedGate}
@ -256,5 +261,7 @@ export default function GateList(props: Props) {
pulse={gates.length < 1}
/>
{gateTable()}
</Box>
<GateReports open={openReports} onClose={()=>{setOpenReports(false)}}/>
</React.Fragment>
)
}

View file

@ -241,7 +241,7 @@ export default function MapBase(props: Props) {
homeMarkerAPI
.listHomeMarkers(1, 0, undefined, undefined, undefined, undefined, as)
.then(resp => {
if (resp.data.homeMarker.length < 1) {
if (resp.data.homeMarker === undefined) {
setHomePin(undefined);
setHaveHome(false);
setStartingView(props.currentView);
@ -271,6 +271,7 @@ export default function MapBase(props: Props) {
}
})
.catch(err => {
console.log(err)
openSnack("Could not load Home Pin");
});
}, [as, homeMarkerAPI, openSnack, props.ignoreHomeLoad, user]); // eslint-disable-line react-hooks/exhaustive-deps

View file

@ -221,6 +221,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
.then(resp => {
let fields: Map<string, Field> = new Map();
let fieldEntries: Result[] = [];
if(resp.data.fields){
resp.data.fields.forEach(f => {
let field = Field.any(f);
fields.set(field.key(), field);
@ -239,6 +240,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
relevance: 0
});
});
}
setFields(fields);
setFieldSearchEntries(fieldEntries);
})
@ -314,6 +316,8 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
let bagOp: BagModel[] = [];
let bagMarkerData: Map<string, MarkerData> = new Map();
let bagEntries: Result[] = [];
if(resp.data.grainBags){
resp.data.grainBags.forEach(bag => {
let b = BagModel.create(bag);
bags.set(b.key(), b);
@ -361,6 +365,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
}
}
});
}
setBagOptions(bagOp);
setGrainBags(bags);
grainBagsRef.current = bags;
@ -382,6 +387,8 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
binYardAPI
.listBinYards(400, 0, "asc", undefined, undefined, undefined, as)
.then(resp => {
if(resp.data.yard){
resp.data.yard.forEach(yard => {
if (yard.settings) {
yardMap.set(yard.settings.key, yard.settings);
@ -429,6 +436,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
}
}
});
}
setYardMarkerData(newYardMarkers);
setYardSearchEntries(yardEntries);
setBinYards(yardMap);
@ -447,6 +455,9 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
let markerData: Map<string, MarkerData> = new Map();
let searchEntries: Result[] = [];
let binOp: IBin[] = [];
if(resp.data.bins){
resp.data.bins.forEach(bin => {
let b = IBin.create(bin);
binMap.set(b.key(), b);
@ -495,6 +506,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
}
}
});
}
setBinMarkerData(markerData);
setBinSearchEntries(searchEntries);
setBins(binMap);
@ -514,6 +526,9 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
let searchEntries: Result[] = [];
let options: DeviceModel[] = [];
if(resp.data.devices){
resp.data.devices.forEach((device, i) => {
//add device to the main map
let d = DeviceModel.any(device);
@ -553,6 +568,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
}
}
});
}
setDevices(map);
setDeviceOptions(options);
setDeviceMarkerData(newDevMarkers);
@ -725,6 +741,9 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
let fmMap: Map<string, FieldMarker> = new Map();
let markerData: Map<string, MarkerData> = new Map();
let searchEntries: Result[] = [];
if(resp.data.fieldMarker){
resp.data.fieldMarker.forEach(fieldMarker => {
let fm = FieldMarker.create(fieldMarker);
fmMap.set(fm.key(), fm);
@ -760,6 +779,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
place_type: ["fieldMarker"]
} as Result);
});
}
setFieldMarkers(fmMap);
setFieldMarkerData(markerData);
setFieldMarkerSearchEntries(searchEntries);

View file

@ -81,6 +81,7 @@ export interface IGateInterface {
otherTeam?: string
) => Promise<AxiosResponse<pond.ListGateMeasurementsResponse>>;
//new call for getting report data for gates
gateReportData: (gates: string[], start: string, end: string, otherTeam?: string) => Promise<AxiosResponse<pond.GateReportDataResponse>>
}
export const GateAPIcontext = createContext<IGateInterface>({} as IGateInterface);
@ -348,6 +349,24 @@ export default function GateProvider(props: PropsWithChildren<Props>) {
);
};
const gateReportData = (
gates: string[],
start: string,
end: string,
otherTeam?: string
) => {
const view = otherTeam ? otherTeam : as
let url = pondURL("reports/gates?keys=" + gates.toString() + "start=" + start + "&end=" + end + "&as=" + view)
return new Promise<AxiosResponse<pond.GateReportDataResponse>>((resolve, reject) => {
get<pond.GateReportDataResponse>(url).then(resp => {
resp.data = pond.GateReportDataResponse.fromObject(resp.data)
return resolve(resp)
}).catch(err => {
return reject(err)
})
})
}
return (
<GateAPIcontext.Provider
value={{
@ -361,7 +380,8 @@ export default function GateProvider(props: PropsWithChildren<Props>) {
updatePrefs,
listGateAirflow,
listGateMeasurements,
listGateFlowEvents
listGateFlowEvents,
gateReportData
}}>
{children}
</GateAPIcontext.Provider>

View file

@ -1,8 +1,27 @@
import React from "react"
import { DialogActions, DialogContent, DialogTitle } from "@mui/material"
import ResponsiveDialog from "common/ResponsiveDialog"
import { useGateAPI } from "providers"
import React, { useEffect } from "react"
export default function GateReports(){
interface Props {
open: boolean
onClose: () => void
gate?: string //if the gate key is passed in just generate for that gate, otherwise give the user a way of selecting which gates
}
export default function GateReports(props: Props){
const {gate, open, onClose} = props
const gateAPI = useGateAPI()
//load all of the gates for the user/team
useEffect(()=>{
if(gate) return //if there was a gate passed in we dont need to load them
gateAPI.listGates(0, 0).then(resp => {
console.log(resp.data)
}).catch(err => {
})
},[gate])
//selection table to select which gates to generate a report
@ -13,6 +32,12 @@ export default function GateReports(){
*/
return (
<React.Fragment></React.Fragment>
<ResponsiveDialog open={open} onClose={onClose}>
<DialogTitle>Gate Reports</DialogTitle>
<DialogContent>
</DialogContent>
<DialogActions></DialogActions>
</ResponsiveDialog>
)
}