aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-11-19 07:16:56 -0800
committerAnton Tananaev <anton@traccar.org>2023-11-19 07:17:22 -0800
commit1b21fad46cd8c857a8c542ee2cbfbc3ee4951dcd (patch)
tree2714c7d489d81b40fe82ee987f42e63494fe5787 /modern/src/common
parent00eb4948cac4035d34fb118f788b08ca62bc173b (diff)
downloadtrackermap-web-1b21fad46cd8c857a8c542ee2cbfbc3ee4951dcd.tar.gz
trackermap-web-1b21fad46cd8c857a8c542ee2cbfbc3ee4951dcd.tar.bz2
trackermap-web-1b21fad46cd8c857a8c542ee2cbfbc3ee4951dcd.zip
Show driver name
Diffstat (limited to 'modern/src/common')
-rw-r--r--modern/src/common/attributes/usePositionAttributes.js2
-rw-r--r--modern/src/common/components/DriverValue.js9
-rw-r--r--modern/src/common/components/PositionValue.jsx16
-rw-r--r--modern/src/common/components/StatusCard.jsx2
4 files changed, 22 insertions, 7 deletions
diff --git a/modern/src/common/attributes/usePositionAttributes.js b/modern/src/common/attributes/usePositionAttributes.js
index e08e91d5..0b191ebc 100644
--- a/modern/src/common/attributes/usePositionAttributes.js
+++ b/modern/src/common/attributes/usePositionAttributes.js
@@ -349,7 +349,7 @@ export default (t) => useMemo(() => ({
type: 'string',
},
driverUniqueId: {
- name: t('positionDriverUniqueId'),
+ name: t('sharedDriver'),
type: 'string',
},
card: {
diff --git a/modern/src/common/components/DriverValue.js b/modern/src/common/components/DriverValue.js
new file mode 100644
index 00000000..0969ca20
--- /dev/null
+++ b/modern/src/common/components/DriverValue.js
@@ -0,0 +1,9 @@
+import { useSelector } from 'react-redux';
+
+const DriverValue = ({ driverUniqueId }) => {
+ const driver = useSelector((state) => state.drivers.items[driverUniqueId]);
+
+ return driver.name;
+};
+
+export default DriverValue;
diff --git a/modern/src/common/components/PositionValue.jsx b/modern/src/common/components/PositionValue.jsx
index 64f9dc04..b1f8f656 100644
--- a/modern/src/common/components/PositionValue.jsx
+++ b/modern/src/common/components/PositionValue.jsx
@@ -25,6 +25,7 @@ import { useTranslation } from './LocalizationProvider';
import { useAdministrator } from '../util/permissions';
import AddressValue from './AddressValue';
import GeofencesValue from './GeofencesValue';
+import DriverValue from './DriverValue';
const PositionValue = ({ position, property, attribute }) => {
const t = useTranslation();
@@ -97,26 +98,31 @@ const PositionValue = ({ position, property, attribute }) => {
case 'image':
case 'video':
case 'audio':
- return (<Link href={`/api/media/${device.uniqueId}/${value}`} target="_blank">{value}</Link>);
+ return <Link href={`/api/media/${device.uniqueId}/${value}`} target="_blank">{value}</Link>;
case 'totalDistance':
case 'hours':
return (
<>
{formatValue(value)}
&nbsp;&nbsp;
- {admin && (<Link component={RouterLink} underline="none" to={`/settings/accumulators/${position.deviceId}`}>&#9881;</Link>)}
+ {admin && <Link component={RouterLink} underline="none" to={`/settings/accumulators/${position.deviceId}`}>&#9881;</Link>}
</>
);
case 'address':
- return (<AddressValue latitude={position.latitude} longitude={position.longitude} originalAddress={value} />);
+ return <AddressValue latitude={position.latitude} longitude={position.longitude} originalAddress={value} />;
case 'network':
if (value) {
- return (<Link component={RouterLink} underline="none" to={`/network/${position.id}`}>{t('sharedInfoTitle')}</Link>);
+ return <Link component={RouterLink} underline="none" to={`/network/${position.id}`}>{t('sharedInfoTitle')}</Link>;
}
return '';
case 'geofenceIds':
if (value) {
- return (<GeofencesValue geofenceIds={value} />);
+ return <GeofencesValue geofenceIds={value} />;
+ }
+ return '';
+ case 'driverUniqueId':
+ if (value) {
+ return <DriverValue driverUniqueId={value} />;
}
return '';
default:
diff --git a/modern/src/common/components/StatusCard.jsx b/modern/src/common/components/StatusCard.jsx
index 38de944b..04e1d172 100644
--- a/modern/src/common/components/StatusCard.jsx
+++ b/modern/src/common/components/StatusCard.jsx
@@ -211,7 +211,7 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin
{positionItems.split(',').filter((key) => position.hasOwnProperty(key) || position.attributes.hasOwnProperty(key)).map((key) => (
<StatusRow
key={key}
- name={positionAttributes.hasOwnProperty(key) ? positionAttributes[key].name : key}
+ name={positionAttributes[key]?.name || key}
content={(
<PositionValue
position={position}