From 5403fe33922ca63c7ce1203484f30af4936c4f4c Mon Sep 17 00:00:00 2001 From: csawatzky Date: Wed, 14 May 2025 08:51:50 -0600 Subject: [PATCH 01/29] changing background colour of highlighted/toggled button --- src/common/ButtonGroup.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/ButtonGroup.tsx b/src/common/ButtonGroup.tsx index f23bc0a..f1d80f4 100644 --- a/src/common/ButtonGroup.tsx +++ b/src/common/ButtonGroup.tsx @@ -72,14 +72,14 @@ const useStyles = makeStyles((theme: Theme) => { marginLeft: theme.spacing(0.05), marginRight: theme.spacing(0.05), "&:hover": { - backgroundColor: getSecondaryColour(), //use the colour of the whitelabel - //backgroundColor: "gold", + //backgroundColor: getSecondaryColour(), //use the colour of the whitelabel + backgroundColor: "gold", //for now Dustin just wants it to be gold color: "black", } }, buttonToggled: { - backgroundColor: getSecondaryColour(), //use the colour of the whitelabel - //backgroundColor: "gold", + //backgroundColor: getSecondaryColour(), //use the colour of the whitelabel + backgroundColor: "gold", //for now Dustin just wants it to be gold color: "black", borderRadius: 24, fontWeight: "bold" From 3fd614479f85fb78296c56296eb3bd73a88a76b2 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Wed, 14 May 2025 12:36:31 -0600 Subject: [PATCH 02/29] fixed the gate page and svg --- src/gate/GateDevice.tsx | 8 +++++++- src/gate/GateSVG.tsx | 6 +++--- src/pages/Gate.tsx | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gate/GateDevice.tsx b/src/gate/GateDevice.tsx index 3deef9e..955aa50 100644 --- a/src/gate/GateDevice.tsx +++ b/src/gate/GateDevice.tsx @@ -31,6 +31,8 @@ interface Props { drawerView?: boolean; } + + export default function GateDevice(props: Props) { const { gate, comprehensiveDevice, linkedCompList, drawerView } = props; const [{as}] = useGlobalState(); @@ -234,6 +236,7 @@ export default function GateDevice(props: Props) { return ( { @@ -300,6 +304,7 @@ export default function GateDevice(props: Props) { return ( + + } ) @@ -426,9 +435,6 @@ export default function ResponsiveTable(props: Props) { {actions && actions} - - {endTitleElement} - {setSearchText && {searchBar()} diff --git a/src/pages/DeviceComponent.tsx b/src/pages/DeviceComponent.tsx index 424de58..c04a1b2 100644 --- a/src/pages/DeviceComponent.tsx +++ b/src/pages/DeviceComponent.tsx @@ -23,6 +23,7 @@ import { } from "hooks"; import InteractionChip from "interactions/InteractionChip"; import InteractionSettings from "interactions/InteractionSettings"; +import { cloneDeep } from "lodash"; // import MaterialTable from "material-table"; import { Component, Device, deviceScope, Group, Interaction } from "models"; import { convertedUnitMeasurement, MeasurementsFor, UnitMeasurement } from "models/UnitMeasurement"; @@ -450,7 +451,6 @@ export default function DeviceComponent() { // }); }) .catch((err: any) => { - // resolve({ // data: [], // page: 0, @@ -613,6 +613,32 @@ export default function DeviceComponent() { pageSize={pageSize} setPage={setPage} handleRowsPerPageChange={handleRowsPerPageChange} + loadMore={() => { + let currentRows = cloneDeep(rows) + let newOffset = rows.length + componentAPI.listUnitMeasurements( + deviceID, + componentID, + startDate, + endDate, + pageSize, + newOffset, + order, + undefined, + getContextKeys(), + getContextTypes(), + showErrors, + as) + .then(resp => { + let newRows = UnitMeasurement.convertMeasurements( + resp.data.measurements.map(um => UnitMeasurement.any(um, user)) + ) + setRows(currentRows.concat(newRows)) + }).catch(err => { + + }) + + }} /> ); From 159a0638e75f96a756bc582e9740772a3a024d8c Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 23 May 2025 15:23:19 -0600 Subject: [PATCH 27/29] merging issues resolved --- src/common/ResponsiveTable.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/ResponsiveTable.tsx b/src/common/ResponsiveTable.tsx index d371ebd..628836c 100644 --- a/src/common/ResponsiveTable.tsx +++ b/src/common/ResponsiveTable.tsx @@ -1,6 +1,6 @@ import { Box, Button, Card, Checkbox, CircularProgress, Collapse, darken, Divider, Grid2, IconButton, InputAdornment, ListItemButton, ListItemIcon, ListItemText, Menu, MenuItem, Paper, SxProps, Table, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TextField, Theme, Typography } from "@mui/material"; import { makeStyles } from "@mui/styles"; -import { ArrowDownward, ArrowLeft, ArrowRight, ArrowUpward, ChevronRight, Close, Search, ViewColumn } from "@mui/icons-material" +import { ArrowDownward, ArrowUpward, ChevronRight, Close, Search, ViewColumn } from "@mui/icons-material" import { useEffect, useState } from "react"; import React from "react"; import { useMobile } from "hooks"; @@ -98,6 +98,7 @@ interface Props { setOrderBy?: React.Dispatch>; order?: string; setOrder?: React.Dispatch>; + endTitleElement?: string | JSX.Element | (() => string | JSX.Element); loadMore?: () => void } @@ -139,6 +140,7 @@ export default function ResponsiveTable(props: Props) { const subtitle = typeof(props.subtitle) === "function" ? props.subtitle() : props.subtitle const title = typeof(props.title) === "function" ? props.title() : props.title // const order = props.order ? props.order : "asc" + const endTitleElement = typeof(props.endTitleElement) === "function" ? props.endTitleElement() : props.endTitleElement const isMobile = useMobile() @@ -447,6 +449,9 @@ export default function ResponsiveTable(props: Props) { {actions && actions} + + {endTitleElement} + {setSearchText && {searchBar()} From 3368a9112f3e358d8de90753b0988bc67331e3d2 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 23 May 2025 16:13:39 -0600 Subject: [PATCH 28/29] adding load more functionality to the devices and teams mobile tables --- src/pages/Devices.tsx | 36 ++++++++++++++++++++++++++++++++++++ src/teams/TeamList.tsx | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index faf2f6d..77fe11d 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -26,6 +26,7 @@ import StatusPlenum from "common/StatusPlenum"; import StatusSen5x from "common/StatusSen5x"; import StatusDust from "common/StatusDust"; import StatusGas from "common/StatusGas"; +import { cloneDeep } from "lodash"; const useStyles = makeStyles((theme: Theme) => { return ({ @@ -751,6 +752,41 @@ export default function Devices() { orderBy={orderBy} setOrderBy={setOrderBy} endTitleElement={preferencesButton} + loadMore={()=>{ + let currentRows = cloneDeep(devices) + deviceAPI.list( + limit, + currentRows.length, + order, + orderBy, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + getKeys(), + getTypes(), + fieldContains, + search, + as + ).then(resp => { + let newDevices: Device[] = [] + resp.data.devices.forEach(device => { + if (device.status?.plenum?.temperature) setHasPlenums(true) + if (device.status?.sen5x?.temperature) setHasSen5x(true) + if (device.status?.o2) setHasO2(true) + if (device.status?.co) setHasCo(true) + if (device.status?.co2) setHasCo2(true) + if (device.status?.no2) setHasNo2(true) + newDevices.push(Device.create(device)) + }) + setDevices(currentRows.concat(newDevices)) + }).catch(err => { + + }) + }} /> { + let current = cloneDeep(teams) + setLoading(true); + let newTeamPerms: Map = new Map(); + let newTeamPrefs: Map = new Map(); + let viewAs: string | undefined = as + if (as === team.key()) { + viewAs = undefined + } + teamAPI + .listTeams(limit, current.length, undefined, "name", undefined, undefined, " ", search) + .then(resp => { + setTotal(resp.data.total ? resp.data.total : 0); + let newTeams: Team[] = [] + resp.data.teams.forEach(team => { + let u = viewAs ? viewAs : user.id(); + let t = Team.create(team) + if (team.settings && u !== "") { + userAPI + .getUser(u, teamScope(team.settings.key)) + .then(resp => { + newTeamPerms.set(t.key(), resp.permissions) + newTeamPrefs.set(t.key(), resp.preferences) + t.preferences = cloneDeep(resp.preferences) + t.permissions = cloneDeep(resp.permissions) + }).catch(() => { + snackbar.error("Error loading teams.") + }) + .finally(() => { + setTeamPerms(newTeamPerms); + setTeamPrefs(newTeamPrefs); + }); + } + newTeams.push(t) + }); + setTeams(current.concat(newTeams)); + }) + .finally(() => { + setLoading(false); + }); + }} /> Date: Mon, 26 May 2025 09:42:39 -0600 Subject: [PATCH 29/29] fixed column sizing when all gas readings are visible --- src/pages/Devices.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index bc43773..334115d 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -59,14 +59,14 @@ const useStyles = makeStyles((theme: Theme) => { margin: theme.spacing(1), marginLeft: theme.spacing(2), display: "flex", - width: theme.spacing(32) + // width: theme.spacing(26) // justifyContent: "center", }, tagsCellContainer: { margin: theme.spacing(1), marginLeft: theme.spacing(2), display: "flex", - width: theme.spacing(24) + width: theme.spacing(18) // justifyContent: "center", }, green: { @@ -382,12 +382,13 @@ export default function Devices() { title: "Description", render: (device: Device) => { const description = device.settings?.description ?? "" + let size = (hasCo2 && !groupGas) ? 26 : 36 return ( - - + + - {description.length > 36 - ? description.substring(0, 36) + "..." + {description.length > size + ? description.substring(0, size) + "..." : description}