Fix jwt-token
This commit is contained in:
@@ -73,8 +73,8 @@ const MapView = () => {
|
||||
const [devices, setDevices] = useState([]);
|
||||
const [selectedDevice, setSelectedDevice] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [mapCenter, setMapCenter] = useState([59.3293, 18.0686]); // Stockholm default
|
||||
const [mapZoom, setMapZoom] = useState(10);
|
||||
const [mapCenter, setMapCenter] = useState([59.4, 18.1]); // Stockholm area center
|
||||
const [mapZoom, setMapZoom] = useState(11); // Closer zoom for Stockholm area
|
||||
const [showDroneDetections, setShowDroneDetections] = useState(true);
|
||||
const [droneDetectionHistory, setDroneDetectionHistory] = useState([]);
|
||||
const { recentDetections, deviceStatus } = useSocket();
|
||||
@@ -131,10 +131,15 @@ const MapView = () => {
|
||||
|
||||
setDevices(deviceData);
|
||||
|
||||
// Set map center to first device with valid coordinates
|
||||
const deviceWithCoords = deviceData.find(d => d.geo_lat && d.geo_lon);
|
||||
if (deviceWithCoords && devices.length === 0) {
|
||||
setMapCenter([deviceWithCoords.geo_lat, deviceWithCoords.geo_lon]);
|
||||
// Set map bounds to Stockholm area with all three detectors
|
||||
if (deviceData.length > 0 && devices.length === 0) {
|
||||
// Stockholm area bounds that include Arlanda, Naval Base, and Royal Castle
|
||||
const stockholmBounds = [
|
||||
[59.2, 17.8], // Southwest
|
||||
[59.7, 18.4] // Northeast
|
||||
];
|
||||
setMapCenter([59.4, 18.1]); // Center of Stockholm area
|
||||
setMapZoom(11);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching devices:', error);
|
||||
@@ -216,12 +221,12 @@ const MapView = () => {
|
||||
zoom={mapZoom}
|
||||
className="h-full w-full"
|
||||
whenCreated={(map) => {
|
||||
// Auto-fit to device locations if available
|
||||
const validDevices = devices.filter(d => d.geo_lat && d.geo_lon);
|
||||
if (validDevices.length > 1) {
|
||||
const bounds = validDevices.map(d => [d.geo_lat, d.geo_lon]);
|
||||
map.fitBounds(bounds, { padding: [20, 20] });
|
||||
}
|
||||
// Set bounds to Stockholm area to show all three detectors
|
||||
const stockholmBounds = [
|
||||
[59.2, 17.8], // Southwest
|
||||
[59.7, 18.4] // Northeast
|
||||
];
|
||||
map.fitBounds(stockholmBounds, { padding: [20, 20] });
|
||||
}}
|
||||
>
|
||||
<TileLayer
|
||||
@@ -294,38 +299,42 @@ const MapView = () => {
|
||||
})}
|
||||
</MapContainer>
|
||||
|
||||
{/* Map Legend */}
|
||||
<div className="absolute bottom-4 left-4 bg-white bg-opacity-90 backdrop-blur-sm rounded-lg p-3 shadow-lg text-xs">
|
||||
<div className="font-semibold mb-2">Legend</div>
|
||||
<div className="space-y-1">
|
||||
{/* Map Legend - Fixed positioning and visibility */}
|
||||
<div className="absolute bottom-4 left-4 bg-white rounded-lg p-3 shadow-lg text-xs border border-gray-200 z-[1000] max-w-xs">
|
||||
<div className="font-semibold mb-2 text-gray-800">Map Legend</div>
|
||||
<div className="space-y-1.5">
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-green-500 rounded-full"></div>
|
||||
<span>Device Online</span>
|
||||
<div className="w-3 h-3 bg-green-500 rounded-full border border-green-600"></div>
|
||||
<span className="text-gray-700">Device Online</span>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-red-500 rounded-full"></div>
|
||||
<span>Device Detecting</span>
|
||||
<div className="w-3 h-3 bg-red-500 rounded-full border border-red-600"></div>
|
||||
<span className="text-gray-700">Device Detecting</span>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-gray-500 rounded-full"></div>
|
||||
<span>Device Offline</span>
|
||||
<div className="w-3 h-3 bg-gray-500 rounded-full border border-gray-600"></div>
|
||||
<span className="text-gray-700">Device Offline</span>
|
||||
</div>
|
||||
{showDroneDetections && (
|
||||
<>
|
||||
<div className="border-t border-gray-200 mt-2 pt-1">
|
||||
<div className="font-medium">Drone Detections:</div>
|
||||
<div className="border-t border-gray-200 mt-2 pt-2">
|
||||
<div className="font-medium text-gray-800 mb-1">Drone Detections:</div>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-red-500 rounded-full opacity-100"></div>
|
||||
<span>Strong Signal (>-60dBm)</span>
|
||||
<div className="w-3 h-3 bg-red-500 rounded-full border border-red-600 opacity-100"></div>
|
||||
<span className="text-gray-700">Strong Signal (>-60dBm)</span>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-orange-500 rounded-full opacity-80"></div>
|
||||
<span>Medium Signal (-60 to -70dBm)</span>
|
||||
<div className="w-3 h-3 bg-orange-500 rounded-full border border-orange-600 opacity-90"></div>
|
||||
<span className="text-gray-700">Medium Signal (-60 to -70dBm)</span>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-green-500 rounded-full opacity-60"></div>
|
||||
<span>Weak Signal (<-70dBm)</span>
|
||||
<div className="w-3 h-3 bg-green-500 rounded-full border border-green-600 opacity-80"></div>
|
||||
<span className="text-gray-700">Weak Signal (<-70dBm)</span>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-3 h-3 border-2 border-red-400 rounded-full bg-transparent"></div>
|
||||
<span className="text-gray-700">Detection Range</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -30,21 +30,46 @@ async function seedDatabase() {
|
||||
console.log('✅ Admin user already exists');
|
||||
}
|
||||
|
||||
// Create a sample device if none exist
|
||||
// Create sample devices if none exist
|
||||
const deviceCount = await Device.count();
|
||||
if (deviceCount === 0) {
|
||||
await Device.create({
|
||||
name: 'Drone Detector Alpha',
|
||||
geo_lat: 59.3293,
|
||||
geo_lon: 18.0686,
|
||||
location_description: 'Stockholm Central',
|
||||
await Device.bulkCreate([
|
||||
{
|
||||
id: 1,
|
||||
name: 'Arlanda Airport Detector',
|
||||
geo_lat: 59.6519,
|
||||
geo_lon: 17.9186,
|
||||
location_description: 'Arlanda Airport Security Zone',
|
||||
is_active: true,
|
||||
last_heartbeat: new Date(),
|
||||
heartbeat_interval: 300,
|
||||
firmware_version: '1.0.0'
|
||||
});
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Musk Naval Base Detector',
|
||||
geo_lat: 59.2753,
|
||||
geo_lon: 18.2649,
|
||||
location_description: 'Musk Naval Base Perimeter',
|
||||
is_active: true,
|
||||
last_heartbeat: new Date(),
|
||||
heartbeat_interval: 300,
|
||||
firmware_version: '1.0.0'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Royal Castle Detector',
|
||||
geo_lat: 59.3268,
|
||||
geo_lon: 18.0717,
|
||||
location_description: 'Royal Castle Security Zone',
|
||||
is_active: true,
|
||||
last_heartbeat: new Date(),
|
||||
heartbeat_interval: 300,
|
||||
firmware_version: '1.0.0'
|
||||
}
|
||||
]);
|
||||
|
||||
console.log('✅ Sample device created');
|
||||
console.log('✅ Three detector devices created (Arlanda, Naval Base, Royal Castle)');
|
||||
} else {
|
||||
console.log('✅ Devices already exist');
|
||||
}
|
||||
|
||||
@@ -19,24 +19,24 @@ API_BASE_URL = "http://selfservice.cqers.com/drones/api"
|
||||
DEVICES = [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Stockholm Central Detector",
|
||||
"lat": 59.3293,
|
||||
"lon": 18.0686,
|
||||
"coverage_radius": 5.0 # km
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Arlanda Airport Detector",
|
||||
"lat": 59.6519,
|
||||
"lon": 17.9186,
|
||||
"coverage_radius": 8.0 # km
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Göteborg Harbor Detector",
|
||||
"lat": 57.7089,
|
||||
"lon": 11.9746,
|
||||
"id": 2,
|
||||
"name": "Musk Naval Base Detector",
|
||||
"lat": 59.2753,
|
||||
"lon": 18.2649,
|
||||
"coverage_radius": 6.0 # km
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Royal Castle Detector",
|
||||
"lat": 59.3268,
|
||||
"lon": 18.0717,
|
||||
"coverage_radius": 4.0 # km
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user