diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-30 06:04:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-30 06:04:01 -0700 |
commit | 1b293563daa883eccfb81bfeebd1034cb6556ea9 (patch) | |
tree | 2f0763d6deee1c9073e297b366f0652387ac5b1e | |
parent | f9f5ea547e61b6ff527149fa5814851240d2c967 (diff) | |
download | trackermap-web-1b293563daa883eccfb81bfeebd1034cb6556ea9.tar.gz trackermap-web-1b293563daa883eccfb81bfeebd1034cb6556ea9.tar.bz2 trackermap-web-1b293563daa883eccfb81bfeebd1034cb6556ea9.zip |
Add missing user attributes
-rw-r--r-- | modern/src/common/attributes/useCommonUserAttributes.js | 4 | ||||
-rw-r--r-- | modern/src/map/main/MapLiveRoutes.js | 5 | ||||
-rw-r--r-- | modern/src/map/main/MapSelectedDevice.js | 5 |
3 files changed, 10 insertions, 4 deletions
diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js index 791f46d4..c813a912 100644 --- a/modern/src/common/attributes/useCommonUserAttributes.js +++ b/modern/src/common/attributes/useCommonUserAttributes.js @@ -65,14 +65,14 @@ export default (t) => useMemo(() => ({ name: t('attributeUiDisableMaintenance'), type: 'boolean', }, - /* 'web.liveRouteLength': { + 'web.liveRouteLength': { name: t('attributeWebLiveRouteLength'), type: 'number', }, 'web.selectZoom': { name: t('attributeWebSelectZoom'), type: 'number', - }, */ + }, 'web.maxZoom': { name: t('attributeWebMaxZoom'), type: 'number', diff --git a/modern/src/map/main/MapLiveRoutes.js b/modern/src/map/main/MapLiveRoutes.js index fc1a1dde..e98bea74 100644 --- a/modern/src/map/main/MapLiveRoutes.js +++ b/modern/src/map/main/MapLiveRoutes.js @@ -4,12 +4,15 @@ import { useSelector } from 'react-redux'; import { useTheme } from '@mui/styles'; import { map } from '../core/MapView'; import { usePrevious } from '../../reactHelper'; +import { useAttributePreference } from '../../common/util/preferences'; const MapLiveRoutes = () => { const id = 'liveRoute'; const theme = useTheme(); + const liveRouteLength = useAttributePreference('web.liveRouteLength', 10); + const selectedDeviceId = useSelector((state) => state.devices.selectedId); const currentDeviceId = usePrevious(selectedDeviceId); @@ -62,7 +65,7 @@ const MapLiveRoutes = () => { } else if (position) { const last = route.at(-1); if (!last || (last.latitude !== position.latitude && last.longitude !== position.longitude)) { - setRoute([...route.slice(-9), position]); + setRoute([...route.slice(1 - liveRouteLength), position]); } } }, [selectedDeviceId, currentDeviceId, position, route]); diff --git a/modern/src/map/main/MapSelectedDevice.js b/modern/src/map/main/MapSelectedDevice.js index 9d97dd75..c52b8df0 100644 --- a/modern/src/map/main/MapSelectedDevice.js +++ b/modern/src/map/main/MapSelectedDevice.js @@ -5,11 +5,14 @@ import dimensions from '../../common/theme/dimensions'; import { map } from '../core/MapView'; import { usePrevious } from '../../reactHelper'; import usePersistedState from '../../common/util/usePersistedState'; +import { useAttributePreference } from '../../common/util/preferences'; const MapSelectedDevice = () => { const selectedDeviceId = useSelector((state) => state.devices.selectedId); const previousDeviceId = usePrevious(selectedDeviceId); + const selectZoom = useAttributePreference('web.selectZoom', 10); + const position = useSelector((state) => state.positions.items[selectedDeviceId]); const [mapFollow] = usePersistedState('mapFollow', false); @@ -18,7 +21,7 @@ const MapSelectedDevice = () => { if ((selectedDeviceId !== previousDeviceId || mapFollow) && position) { map.easeTo({ center: [position.longitude, position.latitude], - zoom: Math.max(map.getZoom(), 10), + zoom: Math.max(map.getZoom(), selectZoom), offset: [0, -dimensions.popupMapOffset / 2], }); } |