Fix jwt-token

This commit is contained in:
2025-08-18 06:20:39 +02:00
parent c0d1fff02f
commit 136549f9a0
2 changed files with 37 additions and 8 deletions

View File

@@ -16,6 +16,10 @@ const Alerts = () => {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [activeTab, setActiveTab] = useState('rules'); const [activeTab, setActiveTab] = useState('rules');
const [showCreateModal, setShowCreateModal] = useState(false); const [showCreateModal, setShowCreateModal] = useState(false);
const [showEditModal, setShowEditModal] = useState(false);
const [editingRule, setEditingRule] = useState(null);
const [showDetectionModal, setShowDetectionModal] = useState(false);
const [selectedDetection, setSelectedDetection] = useState(null);
useEffect(() => { useEffect(() => {
fetchAlertData(); fetchAlertData();
@@ -50,6 +54,21 @@ const Alerts = () => {
} }
}; };
const handleEditRule = (rule) => {
setEditingRule(rule);
setShowEditModal(true);
};
const handleViewDetection = async (detectionId) => {
try {
const response = await api.get(`/detections/${detectionId}`);
setSelectedDetection(response.data.data);
setShowDetectionModal(true);
} catch (error) {
console.error('Error fetching detection details:', error);
}
};
const getStatusIcon = (status) => { const getStatusIcon = (status) => {
switch (status) { switch (status) {
case 'sent': case 'sent':
@@ -252,10 +271,7 @@ const Alerts = () => {
<td> <td>
<div className="flex space-x-2"> <div className="flex space-x-2">
<button <button
onClick={() => { onClick={() => handleEditRule(rule)}
// TODO: Edit rule
console.log('Edit rule:', rule);
}}
className="text-primary-600 hover:text-primary-900 text-sm" className="text-primary-600 hover:text-primary-900 text-sm"
> >
Edit Edit
@@ -297,6 +313,7 @@ const Alerts = () => {
<th>Type</th> <th>Type</th>
<th>Recipient</th> <th>Recipient</th>
<th>Rule</th> <th>Rule</th>
<th>Detection</th>
<th>Message</th> <th>Message</th>
<th>Sent At</th> <th>Sent At</th>
</tr> </tr>
@@ -327,6 +344,18 @@ const Alerts = () => {
{log.rule?.name || 'Unknown Rule'} {log.rule?.name || 'Unknown Rule'}
</div> </div>
</td> </td>
<td>
{log.detection_id ? (
<button
onClick={() => handleViewDetection(log.detection_id)}
className="text-primary-600 hover:text-primary-900 text-sm font-medium"
>
View Details
</button>
) : (
<span className="text-gray-400 text-sm">N/A</span>
)}
</td>
<td> <td>
<div className="text-sm text-gray-900 max-w-xs truncate"> <div className="text-sm text-gray-900 max-w-xs truncate">
{log.message} {log.message}

View File

@@ -47,10 +47,10 @@ async function seedDatabase() {
}, },
{ {
id: 2, id: 2,
name: 'Musk Naval Base Detector', name: 'Muskö Naval Base Detector',
geo_lat: 59.2753, geo_lat: 58.971724,
geo_lon: 18.2649, geo_lon: 18.121915,
location_description: 'Musk Naval Base Perimeter', location_description: 'Muskö Naval Base Perimeter',
is_active: true, is_active: true,
last_heartbeat: new Date(), last_heartbeat: new Date(),
heartbeat_interval: 300, heartbeat_interval: 300,