feat: WebSocket temps réel + Finance Workflow + corrections
- Task #6: WebSocket /ws/dashboard + Kafka events (5 topics) * Backend: KafkaEventProducer, KafkaEventConsumer * Mobile: WebSocketService (reconnection, heartbeat, typed events) * DashboardBloc: Auto-refresh depuis WebSocket events - Finance Workflow: approbations + budgets (backend + mobile) * Backend: entities, services, resources, migrations Flyway V6 * Mobile: features finance_workflow complète avec BLoC - Corrections DI: interfaces IRepository partout * IProfileRepository, IOrganizationRepository, IMembreRepository * GetIt configuré avec @injectable - Spec-Kit: constitution + templates mis à jour * .specify/memory/constitution.md enrichie * Templates agent, plan, spec, tasks, checklist - Nettoyage: fichiers temporaires supprimés Signed-off-by: lions dev Team
This commit is contained in:
226
unionflow/scripts/kafka/test-websocket.html
Normal file
226
unionflow/scripts/kafka/test-websocket.html
Normal file
@@ -0,0 +1,226 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Test WebSocket UnionFlow</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
h1 {
|
||||
color: #2c3e50;
|
||||
border-bottom: 3px solid #3498db;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.status {
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
margin: 10px 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
.connected {
|
||||
background-color: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
.disconnected {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
button {
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #2980b9;
|
||||
}
|
||||
button:disabled {
|
||||
background-color: #95a5a6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
#messages {
|
||||
background-color: #2c3e50;
|
||||
color: #ecf0f1;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
height: 400px;
|
||||
overflow-y: auto;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.event {
|
||||
margin: 5px 0;
|
||||
padding: 8px;
|
||||
border-left: 3px solid #3498db;
|
||||
background-color: #34495e;
|
||||
}
|
||||
.event-type {
|
||||
color: #3498db;
|
||||
font-weight: bold;
|
||||
}
|
||||
.timestamp {
|
||||
color: #95a5a6;
|
||||
font-size: 11px;
|
||||
}
|
||||
.controls {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.info {
|
||||
background-color: #d1ecf1;
|
||||
border: 1px solid #bee5eb;
|
||||
color: #0c5460;
|
||||
padding: 12px;
|
||||
border-radius: 4px;
|
||||
margin: 15px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🔌 Test WebSocket UnionFlow</h1>
|
||||
|
||||
<div class="info">
|
||||
<strong>URL WebSocket :</strong> ws://localhost:8085/ws/dashboard
|
||||
</div>
|
||||
|
||||
<div id="status" class="status disconnected">
|
||||
❌ Déconnecté
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<button id="connectBtn" onclick="connect()">🔗 Connecter</button>
|
||||
<button id="disconnectBtn" onclick="disconnect()" disabled>🔌 Déconnecter</button>
|
||||
<button id="pingBtn" onclick="sendPing()" disabled>📤 Envoyer Ping</button>
|
||||
<button id="clearBtn" onclick="clearMessages()">🗑️ Effacer</button>
|
||||
</div>
|
||||
|
||||
<h3>📨 Messages reçus :</h3>
|
||||
<div id="messages"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let ws = null;
|
||||
let reconnectInterval = null;
|
||||
|
||||
function updateStatus(connected) {
|
||||
const statusDiv = document.getElementById('status');
|
||||
const connectBtn = document.getElementById('connectBtn');
|
||||
const disconnectBtn = document.getElementById('disconnectBtn');
|
||||
const pingBtn = document.getElementById('pingBtn');
|
||||
|
||||
if (connected) {
|
||||
statusDiv.className = 'status connected';
|
||||
statusDiv.innerHTML = '✅ Connecté';
|
||||
connectBtn.disabled = true;
|
||||
disconnectBtn.disabled = false;
|
||||
pingBtn.disabled = false;
|
||||
} else {
|
||||
statusDiv.className = 'status disconnected';
|
||||
statusDiv.innerHTML = '❌ Déconnecté';
|
||||
connectBtn.disabled = false;
|
||||
disconnectBtn.disabled = true;
|
||||
pingBtn.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function addMessage(type, message, data = null) {
|
||||
const messagesDiv = document.getElementById('messages');
|
||||
const timestamp = new Date().toLocaleTimeString('fr-FR');
|
||||
|
||||
let content = `<div class="event">`;
|
||||
content += `<span class="timestamp">[${timestamp}]</span> `;
|
||||
content += `<span class="event-type">${type}</span>: ${message}`;
|
||||
|
||||
if (data) {
|
||||
content += `<pre style="margin: 5px 0; padding: 5px; background: #1a252f; border-radius: 3px;">${JSON.stringify(data, null, 2)}</pre>`;
|
||||
}
|
||||
|
||||
content += `</div>`;
|
||||
|
||||
messagesDiv.innerHTML += content;
|
||||
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
||||
}
|
||||
|
||||
function connect() {
|
||||
try {
|
||||
addMessage('SYSTEM', 'Tentative de connexion à ws://localhost:8085/ws/dashboard...');
|
||||
|
||||
ws = new WebSocket('ws://localhost:8085/ws/dashboard');
|
||||
|
||||
ws.onopen = function() {
|
||||
updateStatus(true);
|
||||
addMessage('SYSTEM', '✅ Connexion WebSocket établie avec succès !');
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
const eventType = data.type || data.eventType || 'UNKNOWN';
|
||||
addMessage('RECEIVED', eventType, data);
|
||||
} catch (e) {
|
||||
addMessage('RECEIVED', 'Message brut', event.data);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = function(error) {
|
||||
addMessage('ERROR', 'Erreur WebSocket', error);
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
updateStatus(false);
|
||||
addMessage('SYSTEM', '❌ Connexion WebSocket fermée');
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
addMessage('ERROR', 'Erreur lors de la connexion', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
updateStatus(false);
|
||||
addMessage('SYSTEM', 'Déconnexion manuelle');
|
||||
}
|
||||
}
|
||||
|
||||
function sendPing() {
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
const ping = { type: 'ping' };
|
||||
ws.send(JSON.stringify(ping));
|
||||
addMessage('SENT', 'Ping envoyé', ping);
|
||||
}
|
||||
}
|
||||
|
||||
function clearMessages() {
|
||||
document.getElementById('messages').innerHTML = '';
|
||||
addMessage('SYSTEM', 'Messages effacés');
|
||||
}
|
||||
|
||||
// Auto-connect au chargement
|
||||
window.onload = function() {
|
||||
addMessage('SYSTEM', 'Page chargée. Prêt à se connecter.');
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user