updated as in the terminal and gate api's
This commit is contained in:
parent
76744c1b6f
commit
74c8ed661c
13 changed files with 109 additions and 75 deletions
|
|
@ -32,6 +32,7 @@ interface Props {
|
|||
|
||||
export default function GateDevice(props: Props) {
|
||||
const { gate, comprehensiveDevice, linkedCompList, drawerView } = props;
|
||||
const [{as}] = useGlobalState();
|
||||
const [device, setDevice] = useState<Device>(Device.create());
|
||||
const [componentOptions, setComponentOptions] = useState<Map<string, Component>>(
|
||||
new Map<string, Component>()
|
||||
|
|
@ -159,7 +160,8 @@ export default function GateDevice(props: Props) {
|
|||
device.id() + ":" + componentKey,
|
||||
gateCompType,
|
||||
[gate.key],
|
||||
["gate"]
|
||||
["gate"],
|
||||
as
|
||||
)
|
||||
.then(resp => {
|
||||
openSnack("Component Prefence Updated");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import SingleSetAreaChart, { SSAreaDataPoint } from "charts/SingleSetAreaChart";
|
|||
import { Gate } from "models/Gate";
|
||||
import moment, { Moment } from "moment";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useGateAPI } from "providers";
|
||||
import { useGateAPI, useGlobalState } from "providers";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
interface Props {
|
||||
|
|
@ -61,6 +61,7 @@ export default function GateFlowGraph(props: Props) {
|
|||
newXDomain,
|
||||
multiGraphZoom
|
||||
} = props;
|
||||
const [{as}] = useGlobalState();
|
||||
const gateAPI = useGateAPI();
|
||||
const [flowData, setFlowData] = useState<SSAreaDataPoint[]>([]);
|
||||
const [loadingChartData, setLoadingChartData] = useState(false);
|
||||
|
|
@ -84,7 +85,10 @@ export default function GateFlowGraph(props: Props) {
|
|||
ambient,
|
||||
pressureComponent,
|
||||
start.toISOString(),
|
||||
end.toISOString()
|
||||
end.toISOString(),
|
||||
undefined,
|
||||
undefined,
|
||||
as
|
||||
)
|
||||
.then(resp => {
|
||||
let data: SSAreaDataPoint[] = [];
|
||||
|
|
@ -135,7 +139,7 @@ export default function GateFlowGraph(props: Props) {
|
|||
setRecent(recent);
|
||||
});
|
||||
}
|
||||
}, [gateAPI, gate, ambient, pressureComponent, start, end, device, setPCAState]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [gateAPI, gate, ambient, pressureComponent, start, end, device, setPCAState, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const loadFlowEvents = () => {
|
||||
if (ambient && pressureComponent) {
|
||||
|
|
@ -149,7 +153,10 @@ export default function GateFlowGraph(props: Props) {
|
|||
start.toISOString(),
|
||||
end.toISOString(),
|
||||
idleFlow,
|
||||
eventThreshold
|
||||
eventThreshold,
|
||||
undefined,
|
||||
undefined,
|
||||
as
|
||||
)
|
||||
.then(resp => {
|
||||
console.log(resp);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||
|
||||
export default function GateGraphs(props: Props) {
|
||||
const { gate, display, compMap, device, pressure, ambient, setPCAState } = props;
|
||||
const [{ as }] = useGlobalState();
|
||||
const [xDomain, setXDomain] = useState<string[] | number[]>(["dataMin", "dataMax"]);
|
||||
const [zoomed, setZoomed] = useState(false);
|
||||
const defaultDateRange = GetDefaultDateRange();
|
||||
|
|
@ -79,7 +80,7 @@ export default function GateGraphs(props: Props) {
|
|||
setLoading(true);
|
||||
let measurementMap: Map<string, UnitMeasurement[]> = new Map<string, UnitMeasurement[]>();
|
||||
gateAPI
|
||||
.listGateMeasurements(gate.key, startDate.toISOString(), endDate.toISOString())
|
||||
.listGateMeasurements(gate.key, startDate.toISOString(), endDate.toISOString(), as)
|
||||
.then(resp => {
|
||||
resp.data.measurements.forEach(um => {
|
||||
let unitMeasurement = UnitMeasurement.any(um, user);
|
||||
|
|
@ -93,7 +94,7 @@ export default function GateGraphs(props: Props) {
|
|||
setLoading(false);
|
||||
setCompMeasurements(measurementMap);
|
||||
});
|
||||
}, [gate, endDate, gateAPI, startDate]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [gate, endDate, gateAPI, startDate, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const updateDateRange = (newStartDate: any, newEndDate: any) => {
|
||||
let range = GetDefaultDateRange();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { makeStyles } from "@mui/styles";
|
|||
import ResponsiveTable, { Column } from "common/ResponsiveTable";
|
||||
import AddGateFab from "./AddGateFab";
|
||||
import GateSettings from "./GateSettings";
|
||||
import { useGateAPI } from "providers";
|
||||
import { useGateAPI, useGlobalState } from "providers";
|
||||
import { Settings } from "@mui/icons-material";
|
||||
|
||||
interface Props {
|
||||
|
|
@ -38,7 +38,8 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||
}));
|
||||
|
||||
export default function GateList(props: Props) {
|
||||
const {terminals, currentTerminal } = props;
|
||||
const {terminals, currentTerminal } = props;
|
||||
const [{as}] = useGlobalState();
|
||||
// const history = useHistory();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useMobile();
|
||||
|
|
@ -73,11 +74,11 @@ const {terminals, currentTerminal } = props;
|
|||
keys = [currentTerminal]
|
||||
types = ["terminal"]
|
||||
}
|
||||
gateAPI.listGates(pageSize, pageSize * tablePage, "asc", "name", search, undefined, keys, types).then(resp => {
|
||||
gateAPI.listGates(pageSize, pageSize * tablePage, "asc", "name", search, undefined, keys, types, undefined, undefined, as).then(resp => {
|
||||
setGates(resp.data.gates.map(gate => Gate.create(gate)))
|
||||
setTotal(resp.data.total)
|
||||
})
|
||||
},[currentTerminal, search, pageSize, tablePage])
|
||||
},[currentTerminal, search, pageSize, tablePage, as])
|
||||
|
||||
useEffect(() => {
|
||||
loadGates()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import ResponsiveDialog from "common/ResponsiveDialog";
|
|||
import { Terminal } from "models/Terminal";
|
||||
import { Gate } from "models/Gate";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useTerminalAPI, useGateAPI } from "providers";
|
||||
import { useTerminalAPI, useGateAPI, useGlobalState } from "providers";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useSnackbar } from "hooks";
|
||||
//import { useHistory } from "react-router";
|
||||
|
|
@ -48,6 +48,7 @@ const steps = ["Gate", "Duct"];
|
|||
|
||||
export default function GateSettings(props: Props) {
|
||||
const { open, close, terminals, gate, long, lat } = props;
|
||||
const [{as}] = useGlobalState();
|
||||
const [gateName, setGateName] = useState("");
|
||||
const [lowerFlowBound, setLowerFlowBound] = useState(0);
|
||||
const [upperFlowBound, setUpperFlowBound] = useState(0);
|
||||
|
|
@ -83,7 +84,7 @@ export default function GateSettings(props: Props) {
|
|||
if (loadingTerminals) return;
|
||||
setLoadingTerminals(true);
|
||||
terminalAPI
|
||||
.listTerminals(500, 0)
|
||||
.listTerminals(500, 0, undefined, undefined, undefined, as)
|
||||
.then(resp => {
|
||||
setTerminalOptions(resp.data.terminals.map(a => Terminal.any(a)));
|
||||
})
|
||||
|
|
@ -95,7 +96,7 @@ export default function GateSettings(props: Props) {
|
|||
setTerminalOptions(terminals);
|
||||
}
|
||||
//eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [terminals, terminalAPI]);
|
||||
}, [terminals, terminalAPI, as]);
|
||||
|
||||
useEffect(() => {
|
||||
if (gate) {
|
||||
|
|
@ -146,7 +147,7 @@ export default function GateSettings(props: Props) {
|
|||
settings.hourlyApuCost = hourlyAPU;
|
||||
settings.hourlyPcaCost = hourlyPCA;
|
||||
gateAPI
|
||||
.updateGate(gate.key, gateName, settings)
|
||||
.updateGate(gate.key, gateName, settings, as)
|
||||
.then(resp => {
|
||||
openSnack("Gate update");
|
||||
close();
|
||||
|
|
@ -174,7 +175,7 @@ export default function GateSettings(props: Props) {
|
|||
hourlyPcaCost: hourlyPCA
|
||||
});
|
||||
gateAPI
|
||||
.addGate(gateName, settings)
|
||||
.addGate(gateName, settings, as)
|
||||
.then(resp => {
|
||||
openSnack("New gate added");
|
||||
let newGate = Gate.create(
|
||||
|
|
@ -191,7 +192,7 @@ export default function GateSettings(props: Props) {
|
|||
const remove = () => {
|
||||
if (gate) {
|
||||
gateAPI
|
||||
.removeGate(gate.key)
|
||||
.removeGate(gate.key, as)
|
||||
.then(resp => {
|
||||
openSnack("Gate Deleted");
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue