Fix jwt-token

This commit is contained in:
2025-09-19 14:35:02 +02:00
parent 395a5b8842
commit 348b489b0e
3 changed files with 236 additions and 78 deletions

View File

@@ -137,19 +137,19 @@ const Alerts = () => {
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<div className="bg-white p-4 rounded-lg shadow border">
<div className="text-2xl font-bold text-gray-900">{alertStats.total_alerts}</div>
<div className="text-sm text-gray-500">Total Alerts (24h)</div>
<div className="text-sm text-gray-500">{t('alerts.totalAlerts24h')}</div>
</div>
<div className="bg-white p-4 rounded-lg shadow border">
<div className="text-2xl font-bold text-green-600">{alertStats.sent_alerts}</div>
<div className="text-sm text-gray-500">Sent Successfully</div>
<div className="text-sm text-gray-500">{t('alerts.sentSuccessfully')}</div>
</div>
<div className="bg-white p-4 rounded-lg shadow border">
<div className="text-2xl font-bold text-red-600">{alertStats.failed_alerts}</div>
<div className="text-sm text-gray-500">Failed</div>
<div className="text-sm text-gray-500">{t('alerts.failed')}</div>
</div>
<div className="bg-white p-4 rounded-lg shadow border">
<div className="text-2xl font-bold text-yellow-600">{alertStats.pending_alerts}</div>
<div className="text-sm text-gray-500">Pending</div>
<div className="text-sm text-gray-500">{t('alerts.pending')}</div>
</div>
</div>
)}
@@ -165,7 +165,7 @@ const Alerts = () => {
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
}`}
>
Alert Rules ({alertRules.length})
{t('alerts.alertRules')} ({alertRules.length})
</button>
<button
onClick={() => setActiveTab('logs')}
@@ -175,7 +175,7 @@ const Alerts = () => {
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
}`}
>
Alert Logs ({alertLogs?.length || 0})
{t('alerts.alertLogs')} ({alertLogs?.length || 0})
</button>
</nav>
</div>
@@ -186,9 +186,9 @@ const Alerts = () => {
{(alertRules?.length || 0) === 0 ? (
<div className="text-center py-12">
<BellIcon className="mx-auto h-12 w-12 text-gray-400" />
<h3 className="mt-2 text-sm font-medium text-gray-900">No alert rules</h3>
<h3 className="mt-2 text-sm font-medium text-gray-900">{t('alerts.noAlertRules')}</h3>
<p className="mt-1 text-sm text-gray-500">
Get started by creating your first alert rule.
{t('alerts.noAlertRulesDescription')}
</p>
<div className="mt-6">
<button
@@ -196,7 +196,7 @@ const Alerts = () => {
className="btn btn-primary"
>
<PlusIcon className="h-4 w-4 mr-2" />
Create Alert Rule
{t('alerts.createAlertRule')}
</button>
</div>
</div>
@@ -205,13 +205,13 @@ const Alerts = () => {
<table className="table">
<thead>
<tr>
<th>Name</th>
<th>Priority</th>
<th>Channels</th>
<th>Conditions</th>
<th>Status</th>
<th>Created</th>
<th>Actions</th>
<th>{t('alerts.name')}</th>
<th>{t('alerts.priority')}</th>
<th>{t('alerts.channels')}</th>
<th>{t('alerts.conditions')}</th>
<th>{t('alerts.status')}</th>
<th>{t('alerts.created')}</th>
<th>{t('alerts.actions')}</th>
</tr>
</thead>
<tbody>
@@ -233,7 +233,7 @@ const Alerts = () => {
<span className={`px-2 py-1 rounded-full text-xs font-medium ${
getPriorityColor(rule.priority)
}`}>
{rule.priority}
{t(`alerts.${rule.priority}`)}
</span>
</td>
<td>
@@ -251,28 +251,28 @@ const Alerts = () => {
<td>
<div className="text-sm text-gray-900">
{rule.min_detections > 1 && (
<div>Min detections: {rule.min_detections}</div>
<div>{t('alerts.minDetections')}: {rule.min_detections}</div>
)}
{rule.time_window && (
<div>Time window: {rule.time_window}s</div>
<div>{t('alerts.timeWindow')}: {rule.time_window}s</div>
)}
{rule.cooldown_period && (
<div>Cooldown: {rule.cooldown_period}s</div>
<div>{t('alerts.cooldown')}: {rule.cooldown_period}s</div>
)}
{rule.min_threat_level && (
<div>Min threat: {rule.min_threat_level}</div>
<div>{t('alerts.minThreat')}: {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="text-xs text-gray-500">{t('alerts.droneTypes')}:</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'
const droneTypeKeys = {
0: 'consumer',
1: 'orlan',
2: 'professional',
3: 'racing',
4: 'unknown'
};
return (
<span
@@ -283,7 +283,7 @@ const Alerts = () => {
: 'bg-gray-100 text-gray-800'
}`}
>
{droneTypes[typeId] || 'Unknown'}
{t(`alerts.${droneTypeKeys[typeId] || 'unknown'}`)}
{typeId === 1 && '⚠️'}
</span>
);
@@ -299,7 +299,7 @@ const Alerts = () => {
? 'bg-green-100 text-green-800'
: 'bg-gray-100 text-gray-800'
}`}>
{rule.is_active ? 'Active' : 'Inactive'}
{rule.is_active ? t('alerts.active') : t('alerts.inactive')}
</span>
</td>
<td>
@@ -313,13 +313,13 @@ const Alerts = () => {
onClick={() => handleEditRule(rule)}
className="text-primary-600 hover:text-primary-900 text-sm"
>
Edit
{t('alerts.edit')}
</button>
<button
onClick={() => handleDeleteRule(rule.id)}
className="text-red-600 hover:text-red-900 text-sm"
>
Delete
{t('alerts.delete')}
</button>
</div>
</td>
@@ -338,9 +338,9 @@ const Alerts = () => {
{(alertLogs?.length || 0) === 0 ? (
<div className="text-center py-12">
<BellIcon className="mx-auto h-12 w-12 text-gray-400" />
<h3 className="mt-2 text-sm font-medium text-gray-900">No alert logs</h3>
<h3 className="mt-2 text-sm font-medium text-gray-900">{t('alerts.noAlertLogs')}</h3>
<p className="mt-1 text-sm text-gray-500">
Alert logs will appear here when alerts are triggered.
{t('alerts.noAlertLogsDescription')}
</p>
</div>
) : (
@@ -348,13 +348,13 @@ const Alerts = () => {
<table className="table">
<thead>
<tr>
<th>Status</th>
<th>Type</th>
<th>Recipient</th>
<th>Rule</th>
<th>Detection</th>
<th>Message</th>
<th>Sent At</th>
<th>{t('alerts.status')}</th>
<th>{t('alerts.type')}</th>
<th>{t('alerts.recipient')}</th>
<th>{t('alerts.rule')}</th>
<th>{t('alerts.detection')}</th>
<th>{t('alerts.message')}</th>
<th>{t('alerts.sentAt')}</th>
</tr>
</thead>
<tbody>
@@ -380,7 +380,7 @@ const Alerts = () => {
</td>
<td>
<div className="text-sm text-gray-900">
{log.rule?.name || 'Unknown Rule'}
{log.rule?.name || t('alerts.unknownRule')}
</div>
</td>
<td>
@@ -389,10 +389,10 @@ const Alerts = () => {
onClick={() => handleViewDetection(log.detection_id)}
className="text-primary-600 hover:text-primary-900 text-sm font-medium"
>
View Details
{t('alerts.viewDetails')}
</button>
) : (
<span className="text-gray-400 text-sm">N/A</span>
<span className="text-gray-400 text-sm">{t('alerts.na')}</span>
)}
</td>
<td>