From f574d9c1c9fa89788838faf0b1a39a0e7d4c6755 Mon Sep 17 00:00:00 2001
From: Iván Ávalos <avalos@disroot.org>
Date: Tue, 2 Jul 2024 22:15:01 -0600
Subject: Re-add position details to DeviceRow, this time statically

---
 src/main/DeviceRow.jsx | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

(limited to 'src/main/DeviceRow.jsx')

diff --git a/src/main/DeviceRow.jsx b/src/main/DeviceRow.jsx
index b7c2646e..7edf64f7 100644
--- a/src/main/DeviceRow.jsx
+++ b/src/main/DeviceRow.jsx
@@ -74,7 +74,7 @@ const DeviceRow = ({ data, index, style }) => {
   const deviceSecondary = useAttributePreference('deviceSecondary', '');
 
   const positionAttributes = usePositionAttributes(t);
-  const positionItems = useAttributePreference('positionItems', 'speed,address,totalDistance,course');
+  const positionItems = ['speed', 'address', 'hours', 'serverTime'];
 
   const primaryText = () => {
     // RATIONALE: we connect output/out1 to engine lock
@@ -115,6 +115,33 @@ const DeviceRow = ({ data, index, style }) => {
     return (
       <>
         {deviceSecondary && item[deviceSecondary] && item[deviceSecondary]}
+        {/* RATIONALE: clients want more info in the list */}
+        {positionItems.map((attr) => {
+          if (position && (position.hasOwnProperty(attr) || position.attributes.hasOwnProperty(attr))) {
+            return (
+              <AttrItem
+                key={attr}
+                attr={attr}
+                name={positionAttributes[attr]?.name || attr}
+                content={(
+                  <PositionValue
+                    position={position}
+                    property={position.hasOwnProperty(attr) ? attr : null}
+                    attribute={position.hasOwnProperty(attr) ? null : attr}
+                  />
+                )}
+              />
+            );
+          }
+
+          return (
+            <AttrItem
+              key={attr}
+              attr={attr}
+              name={positionAttributes[attr]?.name || attr}
+            />
+          );
+        })}
       </>
     );
   };
@@ -187,13 +214,11 @@ const DeviceRow = ({ data, index, style }) => {
 const AttrItem = ({ attr, name, content }) => {
   const attrIcon = () => {
     switch(attr) {
-      case "address": return <PlaceIcon fontSize="inherit" />;
-      case "deviceTime": return <ScheduleIcon fontSize="inherit" />;
-      case "fixTime": return <ScheduleIcon fontSize="inherit" />;
-      case "hours": return <AvTimerIcon fontSize="inherit" />;
-      case "serverTime": return <ScheduleIcon fontSize="inherit" />;
-      case "speed": return <SpeedIcon fontSize="inherit" />;
-      default: return <b>{name}</b>;
+    case "address": return <PlaceIcon fontSize="inherit" />;
+    case "hours": return <AvTimerIcon fontSize="inherit" />;
+    case "speed": return <SpeedIcon fontSize="inherit" />;
+    case "serverTime": return <ScheduleIcon fontSize="inherit" />;
+    default: return <b>{name}</b>;
     }
   };
 
-- 
cgit v1.2.3

