Fix jwt-token

This commit is contained in:
2025-08-18 06:44:16 +02:00
parent c03385dc2b
commit f002130c1e
7 changed files with 505 additions and 33 deletions

View File

@@ -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>