Fix jwt-token
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import api from '../services/api';
|
import api from '../services/api';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
import { formatFrequency } from '../utils/formatFrequency';
|
||||||
import { XMarkIcon } from '@heroicons/react/24/outline';
|
import { XMarkIcon } from '@heroicons/react/24/outline';
|
||||||
|
|
||||||
// Edit Alert Rule Modal
|
// Edit Alert Rule Modal
|
||||||
@@ -403,7 +404,7 @@ export const DetectionDetailsModal = ({ detection, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-gray-500">Frequency:</span>
|
<span className="text-gray-500">Frequency:</span>
|
||||||
<span>{detection.frequency ? `${detection.frequency} MHz` : 'N/A'}</span>
|
<span>{formatFrequency(detection.frequency)}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-gray-500">Drone Type:</span>
|
<span className="text-gray-500">Drone Type:</span>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
import { formatFrequency } from '../utils/formatFrequency';
|
||||||
import { useSocket } from '../contexts/SocketContext';
|
import { useSocket } from '../contexts/SocketContext';
|
||||||
import { useTranslation } from '../utils/tempTranslations';
|
import { useTranslation } from '../utils/tempTranslations';
|
||||||
import {
|
import {
|
||||||
@@ -184,7 +185,7 @@ const MovementAlertsPanel = () => {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span className="font-medium text-gray-700">Frequency:</span>
|
<span className="font-medium text-gray-700">Frequency:</span>
|
||||||
<div className="text-gray-900">{alert.detection.freq}MHz</div>
|
<div className="text-gray-900">{formatFrequency(alert.detection.freq)}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { useSocket } from '../contexts/SocketContext';
|
import { useSocket } from '../contexts/SocketContext';
|
||||||
import MovementAlertsPanel from '../components/MovementAlertsPanel';
|
import MovementAlertsPanel from '../components/MovementAlertsPanel';
|
||||||
import api from '../services/api';
|
import api from '../services/api';
|
||||||
|
import { formatFrequency } from '../utils/formatFrequency';
|
||||||
import { t } from '../utils/tempTranslations'; // Temporary translation system
|
import { t } from '../utils/tempTranslations'; // Temporary translation system
|
||||||
import {
|
import {
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
@@ -319,7 +320,7 @@ const Dashboard = () => {
|
|||||||
<p className="text-xs text-gray-500">
|
<p className="text-xs text-gray-500">
|
||||||
{detection.device.name || `Device ${detection.device_id}`} •
|
{detection.device.name || `Device ${detection.device_id}`} •
|
||||||
RSSI: {detection.rssi}dBm •
|
RSSI: {detection.rssi}dBm •
|
||||||
Freq: {detection.freq}MHz
|
Freq: {formatFrequency(detection.freq)}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-gray-500">
|
<p className="text-xs text-gray-500">
|
||||||
{format(new Date(detection.server_timestamp), 'HH:mm:ss')}
|
{format(new Date(detection.server_timestamp), 'HH:mm:ss')}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import api from '../services/api';
|
import api from '../services/api';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
import { formatFrequency } from '../utils/formatFrequency';
|
||||||
import {
|
import {
|
||||||
BugAntIcon,
|
BugAntIcon,
|
||||||
ExclamationTriangleIcon,
|
ExclamationTriangleIcon,
|
||||||
@@ -320,7 +321,7 @@ const Debug = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
<td className="px-6 py-4 whitespace-nowrap">
|
||||||
<div className="text-sm text-gray-900">{detection.rssi} dBm</div>
|
<div className="text-sm text-gray-900">{detection.rssi} dBm</div>
|
||||||
<div className="text-sm text-gray-500">{detection.freq} MHz</div>
|
<div className="text-sm text-gray-500">{formatFrequency(detection.freq)}</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
<td className="px-6 py-4 whitespace-nowrap">
|
||||||
{detection.threat_level ? (
|
{detection.threat_level ? (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import api from '../services/api';
|
import api from '../services/api';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
import { formatFrequency } from '../utils/formatFrequency';
|
||||||
import { t } from '../utils/tempTranslations'; // Temporary translation system
|
import { t } from '../utils/tempTranslations'; // Temporary translation system
|
||||||
import {
|
import {
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
@@ -214,7 +215,7 @@ const Detections = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span className="text-sm text-gray-900">
|
<span className="text-sm text-gray-900">
|
||||||
{detection.freq} MHz
|
{formatFrequency(detection.freq)}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import L from 'leaflet'; // For divIcon and other Leaflet utilities
|
|||||||
import { useSocket } from '../contexts/SocketContext';
|
import { useSocket } from '../contexts/SocketContext';
|
||||||
import api from '../services/api';
|
import api from '../services/api';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
import { formatFrequency } from '../utils/formatFrequency';
|
||||||
import { t } from '../utils/tempTranslations';
|
import { t } from '../utils/tempTranslations';
|
||||||
import {
|
import {
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
@@ -742,7 +743,7 @@ const DevicePopup = ({ device, status, detections }) => (
|
|||||||
</div>
|
</div>
|
||||||
{detections.slice(0, 3).map((detection, index) => (
|
{detections.slice(0, 3).map((detection, index) => (
|
||||||
<div key={index} className="text-xs text-gray-600">
|
<div key={index} className="text-xs text-gray-600">
|
||||||
Drone {detection.drone_id} • {detection.freq}MHz • {detection.rssi}dBm
|
Drone {detection.drone_id} • {formatFrequency(detection.freq)} • {detection.rssi}dBm
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -833,7 +834,7 @@ const DroneDetectionPopup = ({ detection, age, droneTypes, droneDetectionHistory
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span className="font-medium text-gray-700">{t('map.frequency')}:</span>
|
<span className="font-medium text-gray-700">{t('map.frequency')}:</span>
|
||||||
<div className="text-gray-900">{detection.freq}MHz</div>
|
<div className="text-gray-900">{formatFrequency(detection.freq)}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
48
client/src/utils/formatFrequency.js
Normal file
48
client/src/utils/formatFrequency.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Format frequency value with appropriate units (MHz or GHz)
|
||||||
|
* @param {number} frequency - Frequency value in MHz
|
||||||
|
* @returns {string} Formatted frequency string with appropriate units
|
||||||
|
*/
|
||||||
|
export const formatFrequency = (frequency) => {
|
||||||
|
if (!frequency && frequency !== 0) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
|
||||||
|
const freq = parseFloat(frequency);
|
||||||
|
|
||||||
|
// Convert to GHz if frequency is 1000 MHz or higher
|
||||||
|
if (freq >= 1000) {
|
||||||
|
const ghz = freq / 1000;
|
||||||
|
// Show one decimal place for GHz if needed
|
||||||
|
return ghz % 1 === 0 ? `${ghz} GHz` : `${ghz.toFixed(1)} GHz`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show MHz for frequencies below 1000 MHz
|
||||||
|
return freq % 1 === 0 ? `${freq} MHz` : `${freq.toFixed(1)} MHz`;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get frequency display info (value and unit separately)
|
||||||
|
* @param {number} frequency - Frequency value in MHz
|
||||||
|
* @returns {object} Object with value and unit properties
|
||||||
|
*/
|
||||||
|
export const getFrequencyInfo = (frequency) => {
|
||||||
|
if (!frequency && frequency !== 0) {
|
||||||
|
return { value: 'N/A', unit: '' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const freq = parseFloat(frequency);
|
||||||
|
|
||||||
|
if (freq >= 1000) {
|
||||||
|
const ghz = freq / 1000;
|
||||||
|
return {
|
||||||
|
value: ghz % 1 === 0 ? ghz : ghz.toFixed(1),
|
||||||
|
unit: 'GHz'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
value: freq % 1 === 0 ? freq : freq.toFixed(1),
|
||||||
|
unit: 'MHz'
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user