Merge branch 'main' into CEC-5542

This commit is contained in:
Paul Adamsen
2024-05-02 22:20:29 -04:00
committed by GitHub
3 changed files with 56 additions and 57 deletions

12
package-lock.json generated
View File

@@ -7362,9 +7362,9 @@
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
}, },
"node_modules/ejs": { "node_modules/ejs": {
"version": "3.1.9", "version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
"dependencies": { "dependencies": {
"jake": "^10.8.5" "jake": "^10.8.5"
}, },
@@ -22471,9 +22471,9 @@
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
}, },
"ejs": { "ejs": {
"version": "3.1.9", "version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
"requires": { "requires": {
"jake": "^10.8.5" "jake": "^10.8.5"
} }

View File

@@ -214,53 +214,51 @@ const MainForm = ({ name }) => {
selectCount={selected.length} selectCount={selected.length}
rowCount={fleetVehicles.length} rowCount={fleetVehicles.length}
/> />
<VehicleProvider> <TableBody>
<TableBody> {fleetVehicles && fleetVehicles.map((car) => {
{fleetVehicles && fleetVehicles.map((car) => { const isSelected = selected.includes(car.vin);
const isSelected = selected.includes(car.vin); return (car.vin && <TableRow key={"row" + car.vin}>
return (car.vin && <TableRow key={"row" + car.vin}> <TableCell padding="checkbox">
<TableCell padding="checkbox"> <Checkbox
<Checkbox checked={isSelected}
checked={isSelected} onChange={() => handleSelect(car.vin, !isSelected)}
onChange={() => handleSelect(car.vin, !isSelected)} />
/> </TableCell>
</TableCell> <TableCell key={"cell" + car.vin} align="center">
<TableCell key={"cell" + car.vin} align="center"> <VehicleTeaser
<VehicleTeaser vin={car.vin}
vin={car.vin} icc={car.connectedHMI}
icc={car.connectedHMI} trex={car.connected}
trex={car.connected} token={token}
token={token} />
/> </TableCell>
</TableCell> <TableCell key={"cell2" + car.vin} align="center">{car.trex_version}</TableCell>
<TableCell key={"cell2" + car.vin} align="center">{car.trex_version}</TableCell> <TableCell key={"cell3" + car.car_update_name}>
<TableCell key={"cell3" + car.car_update_name}> <Tooltip key={"cell3tooltip"} title={`${car.car_update_id} / ${car.car_update_type}`}>
<Tooltip key={"cell3tooltip"} title={`${car.car_update_id} / ${car.car_update_type}`}> <Link to={`/vehicle-status/${car.vin}/${car.car_update_id}`} className={classes.truncateCell}>
<Link to={`/vehicle-status/${car.vin}/${car.car_update_id}`} className={classes.truncateCell}> {car.car_update_name}
{car.car_update_name} </Link>
</Link> </Tooltip>
</Tooltip> </TableCell>
</TableCell> <TableCell key={"cell4" + car.vin}>
<TableCell key={"cell4" + car.vin}> {car.car_update_status}
{car.car_update_status} {car.car_update_progress > -1 && (
{car.car_update_progress > -1 && ( <LinearProgress variant="determinate" value={car.car_update_progress} />
<LinearProgress variant="determinate" value={car.car_update_progress} /> )}
)} </TableCell>
</TableCell> <TableCell key={"cell5" + car.vin} align="left">
<TableCell key={"cell5" + car.vin} align="left"> <Battery percent={car.charge} charge={car.charge_type} />
<Battery percent={car.charge} charge={car.charge_type} /> </TableCell>
</TableCell> <TableCell key={"cell6" + car.vin}>
<TableCell key={"cell6" + car.vin}> {car.voltage > 0 && `${car.voltage}V`}
{car.voltage > 0 && `${car.voltage}V`} </TableCell>
</TableCell> <TableCell key={"cell7" + car.vin}>
<TableCell key={"cell7" + car.vin}> {car.park ? "Yes" : "No"}
{car.park ? "Yes" : "No"} </TableCell>
</TableCell> </TableRow>
</TableRow> )
) })}
})} </TableBody>
</TableBody>
</VehicleProvider>
<TableFooter> <TableFooter>
<TableRow> <TableRow>
<TablePagination <TablePagination

View File

@@ -3,9 +3,9 @@ import { Link } from "react-router-dom";
import Chip from '@mui/material/Chip'; import Chip from '@mui/material/Chip';
import Stack from '@mui/material/Stack'; import Stack from '@mui/material/Stack';
import ConnectedIcon from "../Controls/ConnectedIcon"; import ConnectedIcon from "../Controls/ConnectedIcon";
import { useVehicleContext } from "../Contexts/VehicleContext";
import useStyles from "../useStyles"; import useStyles from "../useStyles";
import { useIntersectObserver } from "../../hooks"; import { useIntersectObserver } from "../../hooks";
import api from "../../services/vehiclesAPI";
// Prevent fetching missing data by not including `token` prop // Prevent fetching missing data by not including `token` prop
@@ -13,8 +13,7 @@ export function VehicleTeaserController(props) {
const el = useRef(null); const el = useRef(null);
const isVisible = useIntersectObserver(el, "0px", true); const isVisible = useIntersectObserver(el, "0px", true);
const [isMissingData, setIsMissingData] = useState(false); const [isMissingData, setIsMissingData] = useState(false);
const [vehicle, setVehicle] = useState({});
const { getVehicle, vehicle } = useVehicleContext();
const classes = useStyles(); const classes = useStyles();
@@ -26,7 +25,9 @@ export function VehicleTeaserController(props) {
useEffect(() => { useEffect(() => {
if (isVisible && props.token) { if (isVisible && props.token) {
getVehicle(props.vin, props.token) api.getVehicle(props.vin, props.token)
.then(setVehicle)
.catch(() => setVehicle({}));
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isMissingData, isVisible, props.vin, props.token]); }, [isMissingData, isVisible, props.vin, props.token]);