import React, { useState } from 'react'; import { Accordion, AccordionDetails, AccordionSummary, Container, makeStyles, Paper, Slider, Tooltip, Typography, } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import MainToolbar from '../MainToolbar'; import Map from '../map/Map'; import t from '../LocalizationProvider'; import ReplayPathMap from '../map/ReplayPathMap'; import PositionsMap from '../map/PositionsMap'; import { formatPosition } from '../common/formatter'; import ReportFilter from './ReportFilter'; const useStyles = makeStyles((theme) => ({ root: { height: '100%', display: 'flex', flexDirection: 'column', }, controlPanel: { position: 'absolute', bottom: theme.spacing(5), left: '50%', transform: 'translateX(-50%)', }, controlContent: { padding: theme.spacing(2), marginBottom: theme.spacing(2), }, configForm: { display: 'flex', flexDirection: 'column', }, })); const TimeLabel = ({ children, open, value }) => ( {children} ); const ReplayPage = () => { const classes = useStyles(); const [expanded, setExpanded] = useState(true); const [positions, setPositions] = useState([]); const [index, setIndex] = useState(0); const handleSubmit = async (deviceId, from, to, _, headers) => { const query = new URLSearchParams({ deviceId, from, to }); const response = await fetch(`/api/positions?${query.toString()}`, { headers }); if (response.ok) { setIndex(0); setPositions(await response.json()); setExpanded(false); } }; return (
{index < positions.length && } {!!positions.length && ( ({ value: index }))} value={index} onChange={(_, index) => setIndex(index)} valueLabelDisplay="auto" valueLabelFormat={(i) => (i < positions.length ? formatPosition(positions[i], 'fixTime') : '')} ValueLabelComponent={TimeLabel} /> )}
setExpanded(!expanded)}> }> {t('reportConfigure')}
); }; export default ReplayPage;