From be320bf33c143a9d60f30dfd8a110937e7b51a3c Mon Sep 17 00:00:00 2001 From: mx57 <38256814+mx57@users.noreply.github.com> Date: Tue, 1 Sep 2026 20:11:47 +0000 Subject: [PATCH] feat(web): add custom notification trade size threshold settings Implement UI inputs allowing users to specify a minimum USDT trade size threshold (realtime_min_trade_size) for real-time visual pop-ups and sound alerts on the Web Dashboard and Settings page. --- IntelliTrader.Web/Views/Home/Dashboard.cshtml | 39 ++++-- IntelliTrader.Web/Views/Home/Settings.cshtml | 115 ++++++++++++++++-- magda_agent_system/agent_tasks.json | 2 +- 3 files changed, 140 insertions(+), 16 deletions(-) diff --git a/IntelliTrader.Web/Views/Home/Dashboard.cshtml b/IntelliTrader.Web/Views/Home/Dashboard.cshtml index ce9e3fe..501c9a2 100644 --- a/IntelliTrader.Web/Views/Home/Dashboard.cshtml +++ b/IntelliTrader.Web/Views/Home/Dashboard.cshtml @@ -27,25 +27,27 @@ - +
-
+
Громкость: 50%
-
+
- Профиль звука: + Профиль:
-
- Настройки звука +
+ + Мин. сумма (USDT): +
@@ -59,6 +61,7 @@ const soundVolumeSlider = document.getElementById("soundVolumeSlider"); const soundVolumeValue = document.getElementById("soundVolumeValue"); const soundProfileSelect = document.getElementById("soundProfileSelect"); + const minTradeSizeInput = document.getElementById("minTradeSizeInput"); const notificationContainer = document.getElementById("notificationContainer"); let isSoundEnabled = localStorage.getItem("realtime_sound_enabled") !== "false"; @@ -74,10 +77,17 @@ // Load sound profile with fallback to 'chime' let soundProfile = localStorage.getItem("realtime_sound_profile") || "chime"; + // Load min trade size with fallback to 0 + let minTradeSize = parseFloat(localStorage.getItem("realtime_min_trade_size") || "0"); + if (isNaN(minTradeSize) || minTradeSize < 0) minTradeSize = 0; + // Sync UI controls with values soundVolumeSlider.value = soundVolume; soundVolumeValue.textContent = Math.round(soundVolume * 100) + "%"; soundProfileSelect.value = soundProfile; + if (minTradeSizeInput) { + minTradeSizeInput.value = minTradeSize > 0 ? minTradeSize : ""; + } updateSoundButtonUI(); @@ -206,6 +216,16 @@ playNotificationSound(); }); + // Min trade size threshold input handling + if (minTradeSizeInput) { + minTradeSizeInput.addEventListener("input", function () { + let val = parseFloat(minTradeSizeInput.value); + if (isNaN(val) || val < 0) val = 0; + minTradeSize = val; + localStorage.setItem("realtime_min_trade_size", val); + }); + } + // Sound profile select handling soundProfileSelect.addEventListener("change", function () { soundProfile = soundProfileSelect.value; @@ -332,8 +352,11 @@ knownTrades.add(tradeId); if (!isFirstLoad) { - hasNewTrade = true; - showToastNotification(trade); + const tradeCost = (parseFloat(trade.Amount) || 0) * (parseFloat(trade.AveragePrice) || 0); + if (tradeCost >= minTradeSize) { + hasNewTrade = true; + showToastNotification(trade); + } } } }); diff --git a/IntelliTrader.Web/Views/Home/Settings.cshtml b/IntelliTrader.Web/Views/Home/Settings.cshtml index 88c654d..cba45d0 100644 --- a/IntelliTrader.Web/Views/Home/Settings.cshtml +++ b/IntelliTrader.Web/Views/Home/Settings.cshtml @@ -39,13 +39,41 @@
-

Оформление

-
- - +

Оформление и Уведомления

+
+
+ + +
+
+ + +
+
+ +
+
+ + + 50% +
+
+ + +
+
+ + +
@@ -87,6 +115,79 @@ } }); } + + // Realtime Notification Controls in Settings + const settingsSoundToggleBtn = document.getElementById("settingsSoundToggleBtn"); + const settingsSoundVolumeSlider = document.getElementById("settingsSoundVolumeSlider"); + const settingsSoundVolumeValue = document.getElementById("settingsSoundVolumeValue"); + const settingsSoundProfileSelect = document.getElementById("settingsSoundProfileSelect"); + const settingsMinTradeSizeInput = document.getElementById("settingsMinTradeSizeInput"); + + let isSoundEnabled = localStorage.getItem("realtime_sound_enabled") !== "false"; + let soundVolume = parseFloat(localStorage.getItem("realtime_sound_volume") || "0.5"); + if (isNaN(soundVolume)) soundVolume = 0.5; + let soundProfile = localStorage.getItem("realtime_sound_profile") || "chime"; + let minTradeSize = parseFloat(localStorage.getItem("realtime_min_trade_size") || "0"); + if (isNaN(minTradeSize) || minTradeSize < 0) minTradeSize = 0; + + function updateSoundBtn() { + if (settingsSoundToggleBtn) { + if (isSoundEnabled) { + settingsSoundToggleBtn.innerHTML = ' Звук: Вкл'; + settingsSoundToggleBtn.className = "btn btn-sm btn-outline-success"; + settingsSoundToggleBtn.style.color = "#9ece6a"; + settingsSoundToggleBtn.style.borderColor = "#9ece6a"; + } else { + settingsSoundToggleBtn.innerHTML = ' Звук: Выкл'; + settingsSoundToggleBtn.className = "btn btn-sm btn-outline-secondary"; + settingsSoundToggleBtn.style.color = "#a9b1d6"; + settingsSoundToggleBtn.style.borderColor = "#4a4a6a"; + } + } + } + + updateSoundBtn(); + if (settingsSoundVolumeSlider) { + settingsSoundVolumeSlider.value = soundVolume; + settingsSoundVolumeValue.textContent = Math.round(soundVolume * 100) + "%"; + } + if (settingsSoundProfileSelect) { + settingsSoundProfileSelect.value = soundProfile; + } + if (settingsMinTradeSizeInput) { + settingsMinTradeSizeInput.value = minTradeSize > 0 ? minTradeSize : ""; + } + + if (settingsSoundToggleBtn) { + settingsSoundToggleBtn.addEventListener("click", function() { + isSoundEnabled = !isSoundEnabled; + localStorage.setItem("realtime_sound_enabled", isSoundEnabled); + updateSoundBtn(); + }); + } + + if (settingsSoundVolumeSlider) { + settingsSoundVolumeSlider.addEventListener("input", function() { + soundVolume = parseFloat(settingsSoundVolumeSlider.value); + settingsSoundVolumeValue.textContent = Math.round(soundVolume * 100) + "%"; + localStorage.setItem("realtime_sound_volume", soundVolume); + }); + } + + if (settingsSoundProfileSelect) { + settingsSoundProfileSelect.addEventListener("change", function() { + soundProfile = settingsSoundProfileSelect.value; + localStorage.setItem("realtime_sound_profile", soundProfile); + }); + } + + if (settingsMinTradeSizeInput) { + settingsMinTradeSizeInput.addEventListener("input", function() { + let val = parseFloat(settingsMinTradeSizeInput.value); + if (isNaN(val) || val < 0) val = 0; + localStorage.setItem("realtime_min_trade_size", val); + }); + } }); diff --git a/magda_agent_system/agent_tasks.json b/magda_agent_system/agent_tasks.json index 7d53bc6..8e8cadb 100644 --- a/magda_agent_system/agent_tasks.json +++ b/magda_agent_system/agent_tasks.json @@ -446,7 +446,7 @@ }, { "id": "web-dashboard-custom-alerts", - "status": "todo", + "status": "done", "area": "web", "risk": "low", "title": "Add custom notification threshold settings on Dashboard",