Fix jwt-token
This commit is contained in:
@@ -257,6 +257,38 @@ const Alerts = () => {
|
||||
{rule.cooldown_period && (
|
||||
<div>Cooldown: {rule.cooldown_period}s</div>
|
||||
)}
|
||||
{rule.min_threat_level && (
|
||||
<div>Min threat: {rule.min_threat_level}</div>
|
||||
)}
|
||||
{rule.drone_types && rule.drone_types.length > 0 && (
|
||||
<div className="mt-1">
|
||||
<div className="text-xs text-gray-500">Drone types:</div>
|
||||
<div className="flex flex-wrap gap-1 mt-1">
|
||||
{rule.drone_types.map((typeId, index) => {
|
||||
const droneTypes = {
|
||||
0: 'Consumer',
|
||||
1: 'Orlan',
|
||||
2: 'Professional',
|
||||
3: 'Racing',
|
||||
4: 'Unknown'
|
||||
};
|
||||
return (
|
||||
<span
|
||||
key={index}
|
||||
className={`px-1.5 py-0.5 rounded text-xs font-medium ${
|
||||
typeId === 1
|
||||
? 'bg-red-100 text-red-800'
|
||||
: 'bg-gray-100 text-gray-800'
|
||||
}`}
|
||||
>
|
||||
{droneTypes[typeId] || 'Unknown'}
|
||||
{typeId === 1 && '⚠️'}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -427,8 +459,8 @@ const CreateAlertRuleModal = ({ onClose, onSave }) => {
|
||||
min_detections: 1,
|
||||
time_window: 300,
|
||||
cooldown_period: 600,
|
||||
device_ids: null,
|
||||
drone_types: null,
|
||||
device_ids: [],
|
||||
drone_types: [],
|
||||
min_rssi: '',
|
||||
max_rssi: '',
|
||||
frequency_ranges: []
|
||||
@@ -475,6 +507,15 @@ const CreateAlertRuleModal = ({ onClose, onSave }) => {
|
||||
}));
|
||||
};
|
||||
|
||||
const handleDroneTypeChange = (droneType, checked) => {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
drone_types: checked
|
||||
? [...prev.drone_types, droneType]
|
||||
: prev.drone_types.filter(type => type !== droneType)
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 overflow-y-auto">
|
||||
<div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
||||
@@ -600,6 +641,37 @@ const CreateAlertRuleModal = ({ onClose, onSave }) => {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
Drone Types Filter
|
||||
</label>
|
||||
<div className="space-y-2">
|
||||
<div className="text-xs text-gray-500 mb-2">
|
||||
Leave empty to monitor all drone types
|
||||
</div>
|
||||
{[
|
||||
{ id: 0, name: 'Consumer/Hobby' },
|
||||
{ id: 1, name: 'Orlan/Military' },
|
||||
{ id: 2, name: 'Professional/Commercial' },
|
||||
{ id: 3, name: 'Racing/High-speed' },
|
||||
{ id: 4, name: 'Unknown/Custom' }
|
||||
].map(droneType => (
|
||||
<label key={droneType.id} className="flex items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={formData.drone_types.includes(droneType.id)}
|
||||
onChange={(e) => handleDroneTypeChange(droneType.id, e.target.checked)}
|
||||
className="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded"
|
||||
/>
|
||||
<span className="ml-2 text-sm text-gray-700">
|
||||
{droneType.name}
|
||||
{droneType.id === 1 && <span className="text-red-600 font-semibold"> (⚠️ High Threat)</span>}
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const Dashboard = () => {
|
||||
const [recentActivity, setRecentActivity] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [showMovementAlerts, setShowMovementAlerts] = useState(true);
|
||||
const { recentDetections, deviceStatus, connected, movementAlerts } = useSocket();
|
||||
const { recentDetections, deviceStatus, connected, movementAlerts, notificationsEnabled, toggleNotifications } = useSocket();
|
||||
|
||||
useEffect(() => {
|
||||
fetchDashboardData();
|
||||
@@ -116,12 +116,28 @@ const Dashboard = () => {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Stats */}
|
||||
<div>
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
||||
System Overview
|
||||
</h3>
|
||||
<dl className="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{stats.map((item) => (
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
||||
System Overview
|
||||
</h3>
|
||||
</div>
|
||||
<div className="flex items-center space-x-4">
|
||||
<button
|
||||
onClick={toggleNotifications}
|
||||
className={`inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md transition-colors ${
|
||||
notificationsEnabled
|
||||
? 'text-gray-700 bg-gray-100 hover:bg-gray-200'
|
||||
: 'text-red-700 bg-red-100 hover:bg-red-200'
|
||||
}`}
|
||||
>
|
||||
<BellIcon className={`h-4 w-4 mr-2 ${notificationsEnabled ? '' : 'line-through'}`} />
|
||||
{notificationsEnabled ? 'Notifications On' : 'Notifications Off'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<dl className="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{stats.map((item) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className="relative bg-white pt-5 px-4 pb-12 sm:pt-6 sm:px-6 shadow rounded-lg overflow-hidden"
|
||||
|
||||
Reference in New Issue
Block a user