]> git.digitality.be Git - pdw25-26/commitdiff
fix(web): bouton stratégie branché API, options STANDARD/GREEDY
authorSteph Ponzo <ponzo.stephane2@gmail.com>
Sun, 1 Mar 2026 17:33:21 +0000 (18:33 +0100)
committerSteph Ponzo <ponzo.stephane2@gmail.com>
Sun, 1 Mar 2026 17:33:21 +0000 (18:33 +0100)
Wallette/web/index.html
Wallette/web/script.js

index 982c565a5b09395174c8362bcf6d6bc7888af86d..1953653557eb71c1ab8874ca46fa5c32306884e4 100644 (file)
     <div class="card p-4 mb-4">
         <h5>Stratégie</h5>
         <select class="form-select mb-3" id="strategySelect">
-            <option value="hold">Always HOLD</option>
-            <option value="ma_cross">MA Cross</option>
+            <option value="STANDARD">Standard (RSI + SMA)</option>
+            <option value="GREEDY">Greedy (Agressif)</option>
         </select>
         <button class="btn btn-primary">
             Appliquer la stratégie
index c32d2c79b3ef07d5a6a16d604574a80271384334..fb7796579b9b08627ff1051f11425cffcfc95233 100644 (file)
@@ -240,6 +240,29 @@ onAlert(handleIncomingAlert);
 // ─────────────────────────────────────────────────────────────
 // BOUTONS
 // ─────────────────────────────────────────────────────────────
+
+// Bouton "Appliquer la stratégie"
+document.querySelectorAll('button').forEach(btn => {
+    if (btn.textContent.trim() === 'Appliquer la stratégie') {
+        btn.addEventListener('click', async () => {
+            try {
+                const mode = document.getElementById("strategySelect")?.value || "SAFE";
+                const res = await fetch(`${SERVER_URL}/api/strategy/select`, {
+                    method: 'POST',
+                    headers: { 'Content-Type': 'application/json' },
+                    body: JSON.stringify({ userId, pairId: 1, mode })
+                });
+                const data = await res.json();
+                if (data.ok) alert("✅ Stratégie appliquée !");
+                else alert("Erreur : " + (data.message || 'inconnue'));
+            } catch (err) {
+                console.error("Erreur stratégie :", err);
+                alert("Erreur de connexion");
+            }
+        });
+    }
+});
+
 document.getElementById("saveUserBtn")?.addEventListener("click", () => {
     const input = document.getElementById("userIdInput");
     if (input?.value.trim()) {