diff options
author | Anton Tananaev <anton@traccar.org> | 2023-08-19 13:58:45 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-08-19 13:59:07 -0700 |
commit | d3c7705bedebd65c94f9eea691aaf2fe03b0cafe (patch) | |
tree | 5f98b3d9bbbd4fe8067b5a334e84aff008b8db22 /modern/src/main/DeviceList.js | |
parent | 0161ae449d4a7bd0781c0665d663353663ab0faf (diff) | |
download | trackermap-web-d3c7705bedebd65c94f9eea691aaf2fe03b0cafe.tar.gz trackermap-web-d3c7705bedebd65c94f9eea691aaf2fe03b0cafe.tar.bz2 trackermap-web-d3c7705bedebd65c94f9eea691aaf2fe03b0cafe.zip |
Move to Vite
Diffstat (limited to 'modern/src/main/DeviceList.js')
-rw-r--r-- | modern/src/main/DeviceList.js | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/modern/src/main/DeviceList.js b/modern/src/main/DeviceList.js deleted file mode 100644 index eb51232f..00000000 --- a/modern/src/main/DeviceList.js +++ /dev/null @@ -1,66 +0,0 @@ -import React, { useEffect, useRef, useState } from 'react'; -import { useDispatch } from 'react-redux'; -import makeStyles from '@mui/styles/makeStyles'; -import { FixedSizeList } from 'react-window'; -import AutoSizer from 'react-virtualized-auto-sizer'; -import { devicesActions } from '../store'; -import { useEffectAsync } from '../reactHelper'; -import DeviceRow from './DeviceRow'; - -const useStyles = makeStyles((theme) => ({ - list: { - maxHeight: '100%', - }, - listInner: { - position: 'relative', - margin: theme.spacing(1.5, 0), - }, -})); - -const DeviceList = ({ devices }) => { - const classes = useStyles(); - const dispatch = useDispatch(); - const listInnerEl = useRef(null); - - if (listInnerEl.current) { - listInnerEl.current.className = classes.listInner; - } - - const [, setTime] = useState(Date.now()); - - useEffect(() => { - const interval = setInterval(() => setTime(Date.now()), 60000); - return () => { - clearInterval(interval); - }; - }, []); - - useEffectAsync(async () => { - const response = await fetch('/api/devices'); - if (response.ok) { - dispatch(devicesActions.refresh(await response.json())); - } else { - throw Error(await response.text()); - } - }, []); - - return ( - <AutoSizer className={classes.list}> - {({ height, width }) => ( - <FixedSizeList - width={width} - height={height} - itemCount={devices.length} - itemData={devices} - itemSize={72} - overscanCount={10} - innerRef={listInnerEl} - > - {DeviceRow} - </FixedSizeList> - )} - </AutoSizer> - ); -}; - -export default DeviceList; |