From dbf6e8127733414b1f25b6c033bfc5437801414d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 15 May 2022 16:13:05 -0700 Subject: Configurable card attributes --- modern/src/main/StatusCard.js | 23 +++++++++++++++++------ modern/src/settings/PreferencesPage.js | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) (limited to 'modern/src') diff --git a/modern/src/main/StatusCard.js b/modern/src/main/StatusCard.js index f49799b5..92de7bba 100644 --- a/modern/src/main/StatusCard.js +++ b/modern/src/main/StatusCard.js @@ -16,6 +16,9 @@ import RemoveDialog from '../common/components/RemoveDialog'; import PositionValue from '../common/components/PositionValue'; import dimensions from '../common/theme/dimensions'; import { useDeviceReadonly, useReadonly } from '../common/util/permissions'; +import usePersistedState from '../common/util/usePersistedState'; +import usePositionProperties from '../common/attributes/usePositionProperties'; +import usePositionAttributes from '../common/attributes/usePositionAttributes'; const useStyles = makeStyles((theme) => ({ card: { @@ -66,6 +69,11 @@ const StatusCard = ({ deviceId, onClose }) => { const device = useSelector((state) => state.devices.items[deviceId]); const position = useSelector((state) => state.positions.items[deviceId]); + const positionProperties = usePositionProperties(t); + const positionAttributes = usePositionAttributes(t); + const positionObject = { ...positionProperties, ...positionAttributes }; + const [positionItems] = usePersistedState('positionItems', ['speed', 'address', 'totalDistance', 'course']); + const [removeDialogShown, setRemoveDialogShown] = useState(false); return ( @@ -91,12 +99,15 @@ const StatusCard = ({ deviceId, onClose }) => { - } /> - } /> - {position.attributes.odometer - ? } /> - : } />} - } /> + {positionItems.map((key) => ( + + } /> + ))}
diff --git a/modern/src/settings/PreferencesPage.js b/modern/src/settings/PreferencesPage.js index 1256a53a..a7ce6903 100644 --- a/modern/src/settings/PreferencesPage.js +++ b/modern/src/settings/PreferencesPage.js @@ -7,6 +7,8 @@ import { useLocalization, useTranslation } from '../common/components/Localizati import usePersistedState from '../common/util/usePersistedState'; import PageLayout from '../common/components/PageLayout'; import SettingsMenu from './components/SettingsMenu'; +import usePositionProperties from '../common/attributes/usePositionProperties'; +import usePositionAttributes from '../common/attributes/usePositionAttributes'; const useStyles = makeStyles((theme) => ({ container: { @@ -24,6 +26,11 @@ const PreferencesPage = () => { const { languages, language, setLanguage } = useLocalization(); const languageList = Object.entries(languages).map((values) => ({ code: values[0], name: values[1].name })); + const positionProperties = usePositionProperties(t); + const positionAttributes = usePositionAttributes(t); + const positionObject = { ...positionProperties, ...positionAttributes }; + const [positionItems, setPositionItems] = usePersistedState('positionItems', ['speed', 'address', 'totalDistance', 'course']); + const [mapLiveRoutes, setMapLiveRoutes] = usePersistedState('mapLiveRoutes', false); const [mapFollow, setMapFollow] = usePersistedState('mapFollow', false); const [mapCluster, setMapCluster] = usePersistedState('mapCluster', true); @@ -53,6 +60,19 @@ const PreferencesPage = () => { + + {t('sharedAttributes')} + + setMapLiveRoutes(event.target.checked)} />} label={t('mapLiveRoutes')} -- cgit v1.2.3