aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-28 10:30:14 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-28 10:30:14 -0700
commitcd7c15987c08a875386e860a11f6533423709bc2 (patch)
treee4559254f2c7c9dba82f90e8d0e206da79fb48cd /modern/src
parent8135f8a72d8fe4521e989356431f9a86c4139ed7 (diff)
downloadtrackermap-web-cd7c15987c08a875386e860a11f6533423709bc2.tar.gz
trackermap-web-cd7c15987c08a875386e860a11f6533423709bc2.tar.bz2
trackermap-web-cd7c15987c08a875386e860a11f6533423709bc2.zip
Option to show current geofences
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/main/DevicesList.js14
-rw-r--r--modern/src/settings/PreferencesPage.js1
2 files changed, 13 insertions, 2 deletions
diff --git a/modern/src/main/DevicesList.js b/modern/src/main/DevicesList.js
index e4873a3f..cea5b253 100644
--- a/modern/src/main/DevicesList.js
+++ b/modern/src/main/DevicesList.js
@@ -74,9 +74,19 @@ const DeviceRow = ({ data, index, style }) => {
const item = items[index];
const position = useSelector((state) => state.positions.items[item.id]);
+ const geofences = useSelector((state) => state.geofences.items);
+
const [devicePrimary] = usePersistedState('devicePrimary', 'name');
const [deviceSecondary] = usePersistedState('deviceSecondary', '');
+ const formatProperty = (key) => {
+ if (key === 'geofenceIds') {
+ const geofenceIds = item[key] || [];
+ return geofenceIds.map((id) => geofences[id].name).join(', ');
+ }
+ return item[key];
+ };
+
const secondaryText = () => {
let status;
if (item.status === 'online' || !item.lastUpdate) {
@@ -86,7 +96,7 @@ const DeviceRow = ({ data, index, style }) => {
}
return (
<>
- {deviceSecondary && item[deviceSecondary] && `${item[deviceSecondary]} • `}
+ {deviceSecondary && item[deviceSecondary] && `${formatProperty(deviceSecondary)} • `}
<span className={classes[getStatusColor(item.status)]}>{status}</span>
</>
);
@@ -106,7 +116,7 @@ const DeviceRow = ({ data, index, style }) => {
</Avatar>
</ListItemAvatar>
<ListItemText
- primary={item[devicePrimary]}
+ primary={formatProperty(devicePrimary)}
primaryTypographyProps={{ noWrap: true }}
secondary={secondaryText()}
secondaryTypographyProps={{ noWrap: true }}
diff --git a/modern/src/settings/PreferencesPage.js b/modern/src/settings/PreferencesPage.js
index 8c690bd3..c86d696a 100644
--- a/modern/src/settings/PreferencesPage.js
+++ b/modern/src/settings/PreferencesPage.js
@@ -25,6 +25,7 @@ const deviceFields = [
{ id: 'phone', name: 'sharedPhone' },
{ id: 'model', name: 'deviceModel' },
{ id: 'contact', name: 'deviceContact' },
+ { id: 'geofenceIds', name: 'sharedGeofences' },
];
const useStyles = makeStyles((theme) => ({