]> git.digitality.be Git - pdw25-26/commitdiff
Intégration du script.js depuis branche oceane-web
authorChris H <amunneo@hotmail.com>
Fri, 27 Feb 2026 20:00:46 +0000 (21:00 +0100)
committerChris H <amunneo@hotmail.com>
Fri, 27 Feb 2026 20:00:46 +0000 (21:00 +0100)
Wallette/web/script.js

index 2decdf7551888ee1921a3a7c11c556e8c260715e..8e7e31e8aa6f05ab2793de10f909d5aa9dfbb773 100644 (file)
@@ -74,6 +74,63 @@ onAlert(function(alert) {
     setTimeout(() => pop.remove(), 6000);
   }
 
+  if (typeof alert === 'object') {
+
+    // Date & heure
+    const d = new Date(alert.timestamp || Date.now());
+    const dateStr = d.toLocaleString('fr-FR', {
+      day: '2-digit',
+      month: '2-digit',
+      year: 'numeric',
+      hour: '2-digit',
+      minute: '2-digit'
+    });
+
+    // Level
+    const level = alert.alertLevel || alert.level || 'INFO';
+
+    // Action
+    const action = alert.action || 'HOLD';
+
+    // Prix (si présent)
+    let priceStr = '';
+    if (alert.price !== undefined) {
+      const currency = (alert.pair && alert.pair.includes('USD')) ? 'USD' : 'EUR';
+      priceStr = Number(alert.price).toLocaleString('fr-FR', {
+        style: 'currency',
+        currency: currency
+      });
+    }
+
+    // Pair + confiance
+    const pair = alert.pair || '';
+    const conf = typeof alert.confidence === 'number'
+      ? ` • confiance ${Math.round(alert.confidence * 100)}%`
+      : '';
+
+    // Badge couleur level
+    let badgeClass = 'bg-primary';
+    const lvl = level.toUpperCase();
+
+    if (lvl.includes('DANGER') || lvl.includes('CRITICAL')) badgeClass = 'bg-danger';
+    else if (lvl.includes('WARNING')) badgeClass = 'bg-warning text-dark';
+    else if (lvl.includes('INFO')) badgeClass = 'bg-info text-dark';
+
+    // Appliquer affichage formaté (remplace le texte brut)
+    li.innerHTML = `
+      <div style="display:flex; gap:8px; align-items:center; flex-wrap:wrap;">
+        <small class="text-muted">${dateStr}</small>
+        <span class="badge ${badgeClass}">${lvl}</span>
+        <strong>${action}</strong>
+        ${priceStr ? `<span style="font-weight:600;">${priceStr}</span>` : ''}
+      </div>
+      <div style="margin-top:4px; font-size:0.85rem; color:#cbd5e1;">
+        ${pair}${conf}
+      </div>
+    `;
+  }
+
+
   // Préfixer pour voir les nouvelles alertes en haut
   list.prepend(li);
 });