CEC-287 Add connection status to vehicles page (#63)

* Add connection status to vehicles page

* ConnectedIcon control

* Handle Style
This commit is contained in:
John Wu
2021-06-25 10:17:03 -07:00
committed by GitHub
parent 8bb245a417
commit ab37cd598f
3 changed files with 31 additions and 9 deletions

View File

@@ -10,13 +10,13 @@ import {
TablePagination, TablePagination,
TableRow, TableRow,
} from "@material-ui/core"; } from "@material-ui/core";
import CheckCircleIcon from "@material-ui/icons/CheckCircle";
import { useVehicleContext } from "../../Contexts/VehicleContext"; import { useVehicleContext } from "../../Contexts/VehicleContext";
import { useStatusContext } from "../../Contexts/StatusContext"; import { useStatusContext } from "../../Contexts/StatusContext";
import { LocalDateTimeString } from "../../../utils/dates"; import { LocalDateTimeString } from "../../../utils/dates";
import TableHeaderSortable from "../../Table/HeaderSortable"; import TableHeaderSortable from "../../Table/HeaderSortable";
import { logger } from "../../../services/monitoring"; import { logger } from "../../../services/monitoring";
import ConnectedIcon from "../../Controls/ConnectedIcon";
const tableColumns = [ const tableColumns = [
{ {
@@ -138,14 +138,10 @@ const CarSelectionTable = (props) => {
/> />
</TableCell> </TableCell>
<TableCell align="center"> <TableCell align="center">
{row.connected && ( <ConnectedIcon
<> connected={row.connected}
<CheckCircleIcon style={{ marginRight: 5 }}
style={{ color: "Green", fontSize: 12 }} />
/>
<span>&nbsp;</span>
</>
)}
<Link to={`/vehicle-status/${row.vin}`}>{row.vin}</Link> <Link to={`/vehicle-status/${row.vin}`}>{row.vin}</Link>
</TableCell> </TableCell>
<TableCell align="center">{row.model}</TableCell> <TableCell align="center">{row.model}</TableCell>

View File

@@ -21,6 +21,7 @@ import { LocalDateTimeString } from "../../../utils/dates";
import TableHeaderSortable from "../../Table/HeaderSortable"; import TableHeaderSortable from "../../Table/HeaderSortable";
import SearchField from "../../Controls/SearchField"; import SearchField from "../../Controls/SearchField";
import { logger } from "../../../services/monitoring"; import { logger } from "../../../services/monitoring";
import ConnectedIcon from "../../Controls/ConnectedIcon";
const tableColumns = [ const tableColumns = [
{ {
@@ -132,6 +133,10 @@ const MainForm = () => {
{vehicles.map((row) => ( {vehicles.map((row) => (
<TableRow key={row.vin}> <TableRow key={row.vin}>
<TableCell align="center"> <TableCell align="center">
<ConnectedIcon
connected={row.connected}
style={{ marginRight: 5 }}
/>
<Link to={`/vehicle-status/${row.vin}`}>{row.vin}</Link> <Link to={`/vehicle-status/${row.vin}`}>{row.vin}</Link>
</TableCell> </TableCell>
<TableCell align="center">{row.model}</TableCell> <TableCell align="center">{row.model}</TableCell>

View File

@@ -0,0 +1,21 @@
import React from "react";
import PropTypes from "prop-types";
import CheckCircleIcon from "@material-ui/icons/CheckCircle";
const ConnectedIcon = (props) => {
if (props.connected) {
return (
<span style={props.style}>
<CheckCircleIcon style={{ color: "Green", fontSize: 12 }} />
</span>
);
}
return null;
};
ConnectedIcon.propTypes = {
connected: PropTypes.bool.isRequired,
};
export default ConnectedIcon;