CEC-1450 Show Trex version (#169)
* CEC-1450 Show Trex version * Code smells * Clean up * Fixes * Optimize test
This commit is contained in:
@@ -179,7 +179,8 @@ const Component = () => {
|
||||
doors={carState.doors}
|
||||
location={carState.location}
|
||||
windows={carState.windows}
|
||||
updatedAt={carState.updated}
|
||||
trex_version={carState.trex_version}
|
||||
updated={carState.updated}
|
||||
className={classes.popup}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
|
||||
@@ -1,84 +1,63 @@
|
||||
import React from "react";
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
import MuiDialogTitle from '@material-ui/core/DialogTitle';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import CloseIcon from '@material-ui/icons/Close';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Dialog from "@material-ui/core/Dialog";
|
||||
import MuiDialogTitle from "@material-ui/core/DialogTitle";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import CloseIcon from "@material-ui/icons/Close";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
|
||||
import useStyles from "../useStyles";
|
||||
import { LocalDateTimeString } from "../../utils/dates";
|
||||
import DigitalTwin from "../DigitalTwin";
|
||||
|
||||
const VehiclePopUp = (props) => {
|
||||
const classes = useStyles();
|
||||
const { vin, online, battery, doors, location, updatedAt, windows, onClose } = props;
|
||||
const classes = useStyles();
|
||||
const { vin, online, battery, doors, location, windows, onClose } = props;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
fullWidth
|
||||
classes={{ paper: classes.popUp }}
|
||||
open={true}
|
||||
onClose={onClose}
|
||||
>
|
||||
<DialogTitle align="center" onClose={onClose}>{vin}</DialogTitle>
|
||||
<div align="center" className={classes.popUpContent}>
|
||||
<p><b>Connected</b>: {online.toString()}</p>
|
||||
{online && (
|
||||
<div>
|
||||
{battery != null && (
|
||||
<p><b>Battery</b>: {battery.percent}%</p>
|
||||
)}
|
||||
{doors != null && (
|
||||
<div className={classes.popupSection}>
|
||||
<h3>Doors</h3>
|
||||
{Object.entries(doors).map((value) => (<p key={value[0]}><b>{value[0]}</b>: {value[1] ? "open" : "closed"}</p>))}
|
||||
</div>
|
||||
)}
|
||||
{windows != null && (
|
||||
<div className={classes.popupSection}>
|
||||
<h3>Windows</h3>
|
||||
{Object.entries(windows).map((value) => (<p key={value[0]}><b>{value[0]}</b>: {value[1] ? "open" : "closed"}</p>))}
|
||||
</div>
|
||||
)}
|
||||
{location != null && (
|
||||
<div className={classes.popupSection}>
|
||||
<h3>Location</h3>
|
||||
{Object.entries(location).map((value) => {
|
||||
if (value[0] === "altitude") {
|
||||
return (<p key={value[0]}><b>{value[0]}</b>: {value[1]}</p>);
|
||||
} else {
|
||||
return (<p key={value[0]}><b>{value[0]}</b>: {value[1]}°</p>)
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{updatedAt != null && (
|
||||
<div className={classes.popupSection}>
|
||||
<p><b>Updated at</b>: {LocalDateTimeString(updatedAt)}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(!online || (battery == null && doors == null && location == null && windows == null)) && (
|
||||
<p>No vehicle data to display.</p>
|
||||
)}
|
||||
</div>
|
||||
</Dialog >
|
||||
);
|
||||
return (
|
||||
<Dialog
|
||||
fullWidth
|
||||
classes={{ paper: classes.popUp }}
|
||||
open={true}
|
||||
onClose={onClose}
|
||||
>
|
||||
<DialogTitle align="center" onClose={onClose}>
|
||||
{vin}
|
||||
</DialogTitle>
|
||||
<div align="center" className={classes.popUpContent}>
|
||||
<p>
|
||||
<b>Connected</b>: {online.toString()}
|
||||
</p>
|
||||
{online && <DigitalTwin {...props} />}
|
||||
{(!online ||
|
||||
(battery == null &&
|
||||
doors == null &&
|
||||
location == null &&
|
||||
windows == null)) && <p>No vehicle data to display.</p>}
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const DialogTitle = (props) => {
|
||||
const { children, onClose, ...other } = props;
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<MuiDialogTitle disableTypography className={classes.ppopUpTItle} {...other}>
|
||||
<Typography variant="h6">{children}</Typography>
|
||||
{onClose ? (
|
||||
<IconButton aria-label="close" className={classes.closeButton} onClick={onClose}>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
) : null}
|
||||
</MuiDialogTitle>
|
||||
);
|
||||
const { children, onClose, ...other } = props;
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<MuiDialogTitle
|
||||
disableTypography
|
||||
className={classes.ppopUpTItle}
|
||||
{...other}
|
||||
>
|
||||
<Typography variant="h6">{children}</Typography>
|
||||
{onClose ? (
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
className={classes.closeButton}
|
||||
onClick={onClose}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
) : null}
|
||||
</MuiDialogTitle>
|
||||
);
|
||||
};
|
||||
|
||||
export { VehiclePopUp };
|
||||
|
||||
Reference in New Issue
Block a user