CEC-3898 Update ecu table (#297)

* CEC-3898 Update ecu table

* smells

* smells

* smells

* smells

* Fix test

* Clean up Car status tests
This commit is contained in:
John Wu
2023-03-20 16:04:27 -07:00
committed by GitHub
parent a9b040f345
commit 70255d40e4
12 changed files with 298 additions and 60 deletions

View File

@@ -1,13 +1,11 @@
import React from "react";
import { useParams } from "react-router";
import clsx from "clsx";
import { Typography } from "@material-ui/core"; import { Typography } from "@material-ui/core";
import clsx from "clsx";
import React from "react";
import CANFiltersTable from "../../CANFilter/Table"; import CANFiltersTable from "../../CANFilter/Table";
import useStyles from "../../useStyles"; import useStyles from "../../useStyles";
const CANFiltersTab = () => { const CANFiltersTab = ({vin}) => {
const { vin } = useParams();
const classes = useStyles(); const classes = useStyles();
return ( return (

View File

@@ -8,10 +8,10 @@ jest.mock("@material-ui/core/utils/unstable_useId", () =>
import { render, waitFor } from "@testing-library/react"; import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import { setToken } from "../../Contexts/UserContext";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import CANFiltersTab from "./CANFiltersTab";
import addSnapshotSerializer from "../../../utils/snapshot"; import addSnapshotSerializer from "../../../utils/snapshot";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import { setToken } from "../../Contexts/UserContext";
import CANFiltersTab from "./CANFiltersTab";
const renderCANFiltersTab = async () => { const renderCANFiltersTab = async () => {
const { container } = render( const { container } = render(

View File

@@ -1,11 +1,11 @@
import React from "react";
import clsx from "clsx";
import { Typography } from "@material-ui/core"; import { Typography } from "@material-ui/core";
import clsx from "clsx";
import React from "react";
import useStyles from "../../useStyles";
import { useUserContext } from "../../Contexts/UserContext"; import { useUserContext } from "../../Contexts/UserContext";
import CANSignals from "../CANSignals";
import { VehicleProvider } from "../../Contexts/VehicleContext"; import { VehicleProvider } from "../../Contexts/VehicleContext";
import useStyles from "../../useStyles";
import CANSignals from "../CANSignals";
const Main = (props) => { const Main = (props) => {
const { const {

View File

@@ -9,14 +9,14 @@ jest.mock("@material-ui/core/utils/unstable_useId", () =>
import { render, waitFor } from "@testing-library/react"; import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import CANSignalsTab from "./CANSignalsTab";
import {setToken} from "../../Contexts/UserContext";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing"; import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import { setToken } from "../../Contexts/UserContext";
import CANSignalsTab from "./CANSignalsTab";
const renderCANSignalsTab = async () => { const renderCANSignalsTab = async () => {
const { container } = render( const { container } = render(
<BrowserRouter> <BrowserRouter>
<CANSignalsTab vin="TESTVIN1234567890" token="token"/> <CANSignalsTab vin="TESTVIN1234567890" />
</BrowserRouter> </BrowserRouter>
); );
await waitFor(() => { await waitFor(() => {

View File

@@ -1,7 +1,6 @@
import { Typography } from "@material-ui/core"; import { Typography } from "@material-ui/core";
import clsx from "clsx"; import clsx from "clsx";
import React from "react"; import React from "react";
import { useParams } from "react-router";
import { useUserContext } from "../../Contexts/UserContext"; import { useUserContext } from "../../Contexts/UserContext";
import { VehicleProvider } from "../../Contexts/VehicleContext"; import { VehicleProvider } from "../../Contexts/VehicleContext";
@@ -9,8 +8,7 @@ import CarUpdatesTable from "../../Controls/CarUpdatesTable";
import CarVersionLogTable from "../../Controls/CarVersionLogTable"; import CarVersionLogTable from "../../Controls/CarVersionLogTable";
import useStyles from "../../useStyles"; import useStyles from "../../useStyles";
const MainForm = () => { const MainForm = ({vin}) => {
const { vin } = useParams();
const classes = useStyles(); const classes = useStyles();
const { const {
token: { token: {
@@ -28,9 +26,9 @@ const MainForm = () => {
); );
}; };
const CarUpdatesTab = () => ( const CarUpdatesTab = ({vin}) => (
<VehicleProvider> <VehicleProvider>
<MainForm /> <MainForm vin={vin} />
</VehicleProvider> </VehicleProvider>
); );

View File

@@ -1,13 +1,11 @@
import React from "react";
import { useParams } from "react-router";
import clsx from "clsx";
import { Typography } from "@material-ui/core"; import { Typography } from "@material-ui/core";
import clsx from "clsx";
import React from "react";
import CarDetails from "./Details";
import useStyles from "../../useStyles"; import useStyles from "../../useStyles";
import CarDetails from "./Details";
const CarDetailsTab = () => { const CarDetailsTab = ({vin}) => {
const { vin } = useParams();
const classes = useStyles(); const classes = useStyles();
return ( return (

View File

@@ -1,15 +1,13 @@
import { Typography } from "@material-ui/core"; import { Typography } from "@material-ui/core";
import clsx from "clsx"; import clsx from "clsx";
import React from "react"; import React from "react";
import { useParams } from "react-router";
import { useUserContext } from "../../Contexts/UserContext"; import { useUserContext } from "../../Contexts/UserContext";
import { VehicleProvider } from "../../Contexts/VehicleContext"; import { VehicleProvider } from "../../Contexts/VehicleContext";
import CarECUsTable from "../../Controls/CarECUsTable"; import CarECUsTable from "../../Controls/CarECUsTable";
import useStyles from "../../useStyles"; import useStyles from "../../useStyles";
const MainForm = () => { const MainForm = ({ vin }) => {
const { vin } = useParams();
const classes = useStyles(); const classes = useStyles();
const { const {
token: { token: {
@@ -27,9 +25,9 @@ const MainForm = () => {
); );
}; };
const CarUpdatesTab = () => ( const CarUpdatesTab = ({vin}) => (
<VehicleProvider> <VehicleProvider>
<MainForm /> <MainForm vin={vin}/>
</VehicleProvider> </VehicleProvider>
); );

View File

@@ -24,7 +24,7 @@ exports[`CANFiltersTab Render 1`] = `
> >
<a <a
class="makeStyles-labelInline-0" class="makeStyles-labelInline-0"
href="/filter-add?vin=undefined" href="/filter-add?vin=TESTVIN1234567890"
> >
<svg <svg
aria-hidden="true" aria-hidden="true"
@@ -233,7 +233,7 @@ exports[`CANFiltersTab Render 1`] = `
> >
<a <a
class="" class=""
href="/filter-update?vin=undefined&can_id=123&interval=1000" href="/filter-update?vin=TESTVIN1234567890&can_id=123&interval=1000"
style="margin: 5px;" style="margin: 5px;"
title="Update \\"123\\"" title="Update \\"123\\""
> >
@@ -279,7 +279,7 @@ exports[`CANFiltersTab Render 1`] = `
> >
<a <a
class="" class=""
href="/filter-update?vin=undefined&can_id=456-789&interval=2000" href="/filter-update?vin=TESTVIN1234567890&can_id=456-789&interval=2000"
style="margin: 5px;" style="margin: 5px;"
title="Update \\"456-789\\"" title="Update \\"456-789\\""
> >
@@ -325,7 +325,7 @@ exports[`CANFiltersTab Render 1`] = `
> >
<a <a
class="" class=""
href="/filter-update?vin=undefined&can_id=1&interval=0" href="/filter-update?vin=TESTVIN1234567890&can_id=1&interval=0"
style="margin: 5px;" style="margin: 5px;"
title="Update \\"1\\"" title="Update \\"1\\""
> >

View File

@@ -298,7 +298,46 @@ exports[`CarUpdatesTab Render 1`] = `
</thead> </thead>
<tbody <tbody
class="MuiTableBody-root" class="MuiTableBody-root"
/> >
<tr
class="MuiTableRow-root"
>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
TREX
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
0.9.56
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
1/13/2023 2:11:33 AM
</td>
</tr>
<tr
class="MuiTableRow-root"
>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
DBC
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
386c18977a1be3cda60c953e5902c680dbe82b89523f2527e80cd9db863db991
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
1/13/2023 2:11:33 AM
</td>
</tr>
</tbody>
<tfoot <tfoot
class="MuiTableFooter-root" class="MuiTableFooter-root"
> >
@@ -366,7 +405,7 @@ exports[`CarUpdatesTab Render 1`] = `
<p <p
class="MuiTypography-root MuiTablePagination-caption MuiTypography-body2 MuiTypography-colorInherit" class="MuiTypography-root MuiTablePagination-caption MuiTypography-body2 MuiTypography-colorInherit"
> >
0-0 of 0 1-2 of 2
</p> </p>
<div <div
class="MuiTablePagination-actions" class="MuiTablePagination-actions"

View File

@@ -103,6 +103,98 @@ exports[`ECUsTab Render 1`] = `
</svg> </svg>
</span> </span>
</th> </th>
<th
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col"
>
<span
aria-disabled="false"
class="MuiButtonBase-root MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Vendor
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
/>
</svg>
</span>
</th>
<th
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col"
>
<span
aria-disabled="false"
class="MuiButtonBase-root MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Supplier Version
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
/>
</svg>
</span>
</th>
<th
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col"
>
<span
aria-disabled="false"
class="MuiButtonBase-root MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Serial
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
/>
</svg>
</span>
</th>
<th
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col"
>
<span
aria-disabled="false"
class="MuiButtonBase-root MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Boot Loader
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
/>
</svg>
</span>
</th>
<th <th
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter" class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col" scope="col"
@@ -136,7 +228,7 @@ exports[`ECUsTab Render 1`] = `
role="button" role="button"
tabindex="0" tabindex="0"
> >
Created Fingerprint
<svg <svg
aria-hidden="true" aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc" class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
@@ -176,7 +268,106 @@ exports[`ECUsTab Render 1`] = `
</thead> </thead>
<tbody <tbody
class="MuiTableBody-root" class="MuiTableBody-root"
/> >
<tr
class="MuiTableRow-root"
>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
ECUA
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
SWVERSION
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
HWVERSION
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
VENDOR
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
SUPPLIER_SW_VERSION
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
SERIAL_NUMBER
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
BOOT_LOADER
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
CONFIG
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
FINGERPRINT
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
7/14/2021 8:09:40 PM
</td>
</tr>
<tr
class="MuiTableRow-root"
>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
ECUB
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
SWVERSION
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
HWVERSION
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
/>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
/>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
/>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
/>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
CONFIG
</td>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
/>
<td
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
>
7/14/2021 8:09:40 PM
</td>
</tr>
</tbody>
<tfoot <tfoot
class="MuiTableFooter-root" class="MuiTableFooter-root"
> >
@@ -244,7 +435,7 @@ exports[`ECUsTab Render 1`] = `
<p <p
class="MuiTypography-root MuiTablePagination-caption MuiTypography-body2 MuiTypography-colorInherit" class="MuiTypography-root MuiTablePagination-caption MuiTypography-body2 MuiTypography-colorInherit"
> >
0-0 of 0 1-2 of 2
</p> </p>
<div <div
class="MuiTablePagination-actions" class="MuiTablePagination-actions"

View File

@@ -1,20 +1,20 @@
import React, { useEffect, useState } from "react";
import { import {
Table, Table,
TableBody, TableBody,
TableCell, TableCell,
TableFooter, TableFooter,
TablePagination, TablePagination,
TableRow, TableRow
} from "@material-ui/core"; } from "@material-ui/core";
import clsx from "clsx"; import clsx from "clsx";
import React, { useEffect, useState } from "react";
import { LocalDateTimeString } from "../../../utils/dates";
import TableHeaderSortable from "../../Table/HeaderSortable";
import { useVehicleContext } from "../../Contexts/VehicleContext";
import { useStatusContext } from "../../Contexts/StatusContext";
import { logger } from "../../../services/monitoring"; import { logger } from "../../../services/monitoring";
import {useLocalStorage} from "../../useLocalStorage"; import { LocalDateTimeString } from "../../../utils/dates";
import { useStatusContext } from "../../Contexts/StatusContext";
import { useVehicleContext } from "../../Contexts/VehicleContext";
import TableHeaderSortable from "../../Table/HeaderSortable";
import { useLocalStorage } from "../../useLocalStorage";
const tableColumns = [ const tableColumns = [
{ {
@@ -29,13 +29,29 @@ const tableColumns = [
id: "hw_version", id: "hw_version",
label: "HW Version", label: "HW Version",
}, },
{
id: "vendor",
label: "Vendor",
},
{
id: "supplier_sw_version",
label: "Supplier Version",
},
{
id: "serial_number",
label: "Serial",
},
{
id: "boot_loader_version",
label: "Boot Loader",
},
{ {
id: "config", id: "config",
label: "Config", label: "Config",
}, },
{ {
id: "created_at", id: "fingerprint",
label: "Created", label: "Fingerprint",
}, },
{ {
id: "updated_at", id: "updated_at",
@@ -117,16 +133,11 @@ const CarECUsTable = ({ vin, token, classes }) => {
<TableBody> <TableBody>
{ecus.map((row, i) => ( {ecus.map((row, i) => (
<TableRow key={row.ecu + i}> <TableRow key={row.ecu + i}>
<TableCell align="center">{row.ecu}</TableCell> {tableColumns.map((column, j) => {
<TableCell align="center">{row.sw_version}</TableCell> const key = `${row.ecu + i}${column.id}`
<TableCell align="center">{row.hw_version}</TableCell> if (column.id === "updated_at") return (<TableCell key={key} align="center">{LocalDateTimeString(row.updated)}</TableCell>);
<TableCell align="center">{row.config}</TableCell> return (<TableCell key={key} align="center">{row[column.id]}</TableCell>);
<TableCell align="center"> })}
{LocalDateTimeString(row.created)}
</TableCell>
<TableCell align="center">
{LocalDateTimeString(row.updated)}
</TableCell>
</TableRow> </TableRow>
))} ))}
</TableBody> </TableBody>

View File

@@ -33,11 +33,16 @@ const data = [
const ecusData = [ const ecusData = [
{ {
config: "CONFIG",
created: "2021-07-14T20:09:40.98187Z", created: "2021-07-14T20:09:40.98187Z",
ecu: "ECUA", ecu: "ECUA",
hw_version: "HWVERSION", hw_version: "HWVERSION",
sw_version: "SWVERSION", sw_version: "SWVERSION",
vendor: "VENDOR",
supplier_sw_version: "SUPPLIER_SW_VERSION",
serial_number: "SERIAL_NUMBER",
boot_loader_version: "BOOT_LOADER",
config: "CONFIG",
fingerprint: "FINGERPRINT",
updated: "2021-07-14T20:09:40.98187Z", updated: "2021-07-14T20:09:40.98187Z",
}, },
{ {