Add alerts ssytems to the frontend

This commit is contained in:
Urtzi Alfaro
2025-09-21 17:35:36 +02:00
parent 57fd2f22f0
commit f08667150d
17 changed files with 2086 additions and 786 deletions

61
test_alert_quick.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
# Quick Alert Test Script
# This script sends a single test alert using the working configuration
# Use this for quick testing of the real-time alert system
echo "🚀 Sending quick test alert..."
docker exec bakery-ia-alert-processor-1 python -c "
import aio_pika
import asyncio
import json
import uuid
from datetime import datetime
async def quick_alert():
connection = await aio_pika.connect_robust('amqp://bakery:forecast123@rabbitmq:5672/')
channel = await connection.channel()
exchange = await channel.declare_exchange(
'alerts.exchange',
aio_pika.ExchangeType.TOPIC,
durable=True
)
tenant_id = 'c464fb3e-7af2-46e6-9e43-85318f34199a'
# Quick test alert
alert = {
'id': str(uuid.uuid4()),
'tenant_id': tenant_id,
'item_type': 'alert',
'type': 'quick_test',
'severity': 'urgent',
'service': 'quick-test',
'title': '⚡ QUICK TEST - ' + datetime.now().strftime('%H:%M:%S'),
'message': 'Quick test alert sent at ' + datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'actions': ['Check frontend', 'Verify reception'],
'metadata': {'quick_test': True, 'sent_at': datetime.utcnow().isoformat()},
'timestamp': datetime.utcnow().isoformat()
}
await exchange.publish(
aio_pika.Message(json.dumps(alert).encode()),
routing_key='alert.urgent.quick-test'
)
print(f'✅ Quick alert sent: {alert[\"title\"]}')
print(f' ID: {alert[\"id\"]}')
print(' Check your frontend for real-time update!')
await connection.close()
asyncio.run(quick_alert())
"
echo "✅ Quick test completed!"
echo "🌐 Check your frontend - the alert should appear immediately in:"
echo " - Notification icon (header)"
echo " - Panel de control (alerts section)"
echo " - Toast notification (if urgent/high priority)"