From 2328c6d1a0415bf6094fb0bcb7ebbf462d730240 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Thu, 28 Aug 2025 07:39:20 +0200 Subject: [PATCH] Fix jwt-token --- client/src/pages/Devices.jsx | 154 ++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 2 deletions(-) diff --git a/client/src/pages/Devices.jsx b/client/src/pages/Devices.jsx index 9068ac1..d8c542c 100644 --- a/client/src/pages/Devices.jsx +++ b/client/src/pages/Devices.jsx @@ -17,6 +17,8 @@ const Devices = () => { const [showAddModal, setShowAddModal] = useState(false); const [editingDevice, setEditingDevice] = useState(null); const [filter, setFilter] = useState('all'); // 'all', 'approved', 'pending' + const [showDetailsModal, setShowDetailsModal] = useState(false); + const [selectedDevice, setSelectedDevice] = useState(null); useEffect(() => { fetchDevices(); @@ -63,6 +65,21 @@ const Devices = () => { } }; + const handleViewDetails = (device) => { + setSelectedDevice(device); + setShowDetailsModal(true); + }; + + const handleViewOnMap = (device) => { + if (device.geo_lat && device.geo_lon) { + // Open Google Maps with the device location + const url = `https://www.google.com/maps?q=${device.geo_lat},${device.geo_lon}&z=15`; + window.open(url, '_blank'); + } else { + alert('Device location coordinates are not available'); + } + }; + const handleDeleteDevice = async (deviceId) => { if (window.confirm('Are you sure you want to deactivate this device?')) { try { @@ -312,10 +329,16 @@ const Devices = () => { ) : null}
- -
@@ -372,6 +395,133 @@ const Devices = () => { }} /> )} + + {/* Device Details Modal */} + {showDetailsModal && selectedDevice && ( +
+
+
+
+

+ Device Details +

+ +
+ +
+
+ Device ID: + {selectedDevice.id} +
+ +
+ Name: + {selectedDevice.name || 'Unnamed'} +
+ +
+ Status: + + {selectedDevice.stats?.status || 'Unknown'} + +
+ +
+ Approved: + + {selectedDevice.is_approved ? 'Yes' : 'Pending'} + +
+ + {selectedDevice.location_description && ( +
+ Location: + {selectedDevice.location_description} +
+ )} + + {(selectedDevice.geo_lat && selectedDevice.geo_lon) && ( +
+ Coordinates: + {selectedDevice.geo_lat}, {selectedDevice.geo_lon} +
+ )} + + {selectedDevice.last_heartbeat && ( +
+ Last Heartbeat: + {format(new Date(selectedDevice.last_heartbeat), 'MMM dd, yyyy HH:mm')} +
+ )} + + {selectedDevice.firmware_version && ( +
+ Firmware: + {selectedDevice.firmware_version} +
+ )} + + {selectedDevice.stats && ( +
+ Detections (24h): + 0 ? 'text-red-600' : 'text-green-600' + }`}> + {selectedDevice.stats.detections_24h} + +
+ )} + + {selectedDevice.created_at && ( +
+ Created: + {format(new Date(selectedDevice.created_at), 'MMM dd, yyyy HH:mm')} +
+ )} +
+ +
+ {!selectedDevice.is_approved && ( + + )} + + {(selectedDevice.geo_lat && selectedDevice.geo_lon) && ( + + )} + + +
+
+
+
+ )} ); };