From 3f6f8fc17de70d644b7ca7d1db172fefd508ca83 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 5 Jul 2026 19:04:35 +0200 Subject: [PATCH] feat: rebuild trader detail UI with tabs and manual recalculate button --- src/Predictalytics.Api/wwwroot/index.html | 86 +++++++++++++++-------- src/Predictalytics.Api/wwwroot/js/app.js | 35 ++++++++- 2 files changed, 91 insertions(+), 30 deletions(-) diff --git a/src/Predictalytics.Api/wwwroot/index.html b/src/Predictalytics.Api/wwwroot/index.html index 84a5894..1097f24 100644 --- a/src/Predictalytics.Api/wwwroot/index.html +++ b/src/Predictalytics.Api/wwwroot/index.html @@ -211,39 +211,69 @@
-
-
-
- AI Analysis - +
+ +
+ + + +
+ + +
+
+
Win Rate
---
+
Total PnL
---
+
Total Trades
---
+
+
Score
+
---
+ +
+
+ +
+
+

AI Strategy Analysis

+ +
+
Click 'Run Deep Analysis' to generate a detailed summary of this trader's behavior.
+
+ +
+

Category Specialization

+
+ + + +
CategorySubcategoryWin RatePnLVolumeTrades
-
Not analyzed yet.
-
-
-
-
Win Rate
-
Total PnL
-
Total Trades
-
Score
-
-
-

Category Specialization

-
- - - -
CategoryWin RatePnLVolumeTrades
+ + + -
-

Recent Trades

-
- - - -
TimeMarketSidePriceSizeAmount
+ + +
diff --git a/src/Predictalytics.Api/wwwroot/js/app.js b/src/Predictalytics.Api/wwwroot/js/app.js index 2558155..1b84e39 100644 --- a/src/Predictalytics.Api/wwwroot/js/app.js +++ b/src/Predictalytics.Api/wwwroot/js/app.js @@ -346,6 +346,9 @@ async function viewTrader(id) { const t = await api(`/api/traders/${id}`); if (!t) return; + // Reset tabs to default (Analytics) + switchTraderTab('td-tab-analytics'); + document.getElementById('td-name').textContent = t.displayName; document.getElementById('td-platform').textContent = t.platform; document.getElementById('td-platformId').textContent = t.platformUserId; @@ -360,11 +363,26 @@ async function viewTrader(id) { const refreshBtn = document.getElementById('btn-refresh-trader'); refreshBtn.onclick = () => manualUpdateTrader(id); + const forceBtn = document.getElementById('btn-force-analyze'); + if(forceBtn) { + forceBtn.onclick = async () => { + forceBtn.disabled = true; + forceBtn.textContent = '...'; + try { + await api(`/api/traders/${id}/force-analyze`, { method: 'POST' }); + alert('Deep Analysis queued! Please wait a moment and then refresh.'); + } finally { + forceBtn.disabled = false; + forceBtn.textContent = 'Recalculate'; + } + }; + } + const aiBtn = document.getElementById('btn-ai-analysis'); aiBtn.onclick = () => triggerAiAnalysis(id, true); const wlBtn = document.getElementById('btn-toggle-watchlist'); - wlBtn.textContent = t.isOnWatchlist ? '★ Watchlist (Remove)' : '☆ Watchlist (Add)'; + wlBtn.textContent = t.isOnWatchlist ? 'Watchlist (Remove)' : 'Watchlist (Add)'; wlBtn.onclick = async () => { const method = t.isOnWatchlist ? 'DELETE' : 'POST'; await api(`/api/traders/${id}/watchlist`, { method }); @@ -385,6 +403,7 @@ async function viewTrader(id) { catBody.innerHTML = t.categoryPerformances.map(c => ` ${c.category} + ${c.subcategory || '-'} ${fmt.pct(c.winRate)} ${fmt.pnl(c.totalPnL)} ${fmt.usd(c.totalVolume)} @@ -392,7 +411,7 @@ async function viewTrader(id) { `).join(''); } else { - catBody.innerHTML = 'No category data available'; + catBody.innerHTML = 'No category data available'; } const tbody = document.getElementById('td-tradesBody'); @@ -410,6 +429,18 @@ async function viewTrader(id) { `).join(''); } +function switchTraderTab(tabId) { + // Hide all tabs + document.querySelectorAll('.tab-content').forEach(el => el.style.display = 'none'); + // Deactivate all buttons + document.querySelectorAll('.btn-tab').forEach(el => el.classList.remove('active')); + // Show active tab + document.getElementById(tabId).style.display = 'block'; + // Activate clicked button + const btn = document.querySelector(`.btn-tab[data-tab="${tabId}"]`); + if(btn) btn.classList.add('active'); +} + async function viewMarket(id) { navigateTo('market-detail'); const m = await api(`/api/markets/${id}`);