Fix API offset limit 400 Bad Request, implement requested UI/UX improvements
This commit is contained in:
@@ -117,6 +117,7 @@ async function manualUpdateTrader(id) {
|
||||
|
||||
let currentPlatform = 'All';
|
||||
let currentSort = 'default';
|
||||
let sortDirection = -1;
|
||||
|
||||
document.getElementById('platformSelect')?.addEventListener('change', (e) => {
|
||||
currentPlatform = e.target.value;
|
||||
@@ -272,7 +273,21 @@ async function loadDashboard() {
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Traders Page ───
|
||||
function setTraderSort(field) {
|
||||
if (currentSort === field) {
|
||||
sortDirection *= -1;
|
||||
} else {
|
||||
currentSort = field;
|
||||
sortDirection = -1; // Default to descending
|
||||
}
|
||||
|
||||
// Update tradersSort dropdown if it exists to match
|
||||
const sortSelect = document.getElementById('tradersSort');
|
||||
if (sortSelect) sortSelect.value = currentSort;
|
||||
|
||||
loadTraders();
|
||||
}
|
||||
|
||||
async function loadTraders() {
|
||||
let url = '/api/traders?skip=0&take=100';
|
||||
if (currentPlatform !== 'All') url += `&platform=${currentPlatform}`;
|
||||
@@ -287,24 +302,29 @@ async function loadTraders() {
|
||||
if (!data || !data.length) { tbody.innerHTML = '<tr><td colspan="11"><div class="empty-state"><p>No traders tracked yet.</p></div></td></tr>'; return; }
|
||||
|
||||
const sortSelect = document.getElementById('tradersSort');
|
||||
if (sortSelect) currentSort = sortSelect.value;
|
||||
if (sortSelect && sortSelect.value !== currentSort) currentSort = sortSelect.value;
|
||||
|
||||
const filterWinrate = document.getElementById('filterWinrate')?.value || 'all';
|
||||
const filterCopyability = document.getElementById('filterCopyability')?.value || 'all';
|
||||
const filterWinrateMin = parseFloat(document.getElementById('filterWinrateMin')?.value);
|
||||
const filterCopyabilityMin = parseFloat(document.getElementById('filterCopyabilityMin')?.value);
|
||||
|
||||
// Filtering
|
||||
if (filterWinrate === 'gt50') data = data.filter(t => t.winRate > 50);
|
||||
if (filterWinrate === 'gt60') data = data.filter(t => t.winRate > 60);
|
||||
|
||||
if (filterCopyability === 'gt50') data = data.filter(t => t.copytradingCopyabilityScore > 50);
|
||||
if (filterCopyability === 'gt80') data = data.filter(t => t.copytradingCopyabilityScore > 80);
|
||||
if (!isNaN(filterWinrateMin)) data = data.filter(t => t.winRate >= filterWinrateMin);
|
||||
if (!isNaN(filterCopyabilityMin)) data = data.filter(t => t.copytradingCopyabilityScore >= filterCopyabilityMin);
|
||||
|
||||
// Sorting
|
||||
if (currentSort === 'score') data.sort((a, b) => b.combinedScore - a.combinedScore);
|
||||
else if (currentSort === 'name') data.sort((a, b) => a.displayName.localeCompare(b.displayName));
|
||||
else if (currentSort === 'pnl') data.sort((a, b) => b.totalPnl - a.totalPnl);
|
||||
else if (currentSort === 'winrate') data.sort((a, b) => b.winRate - a.winRate);
|
||||
else if (currentSort === 'copyability') data.sort((a, b) => (b.copytradingCopyabilityScore || 0) - (a.copytradingCopyabilityScore || 0));
|
||||
data.sort((a, b) => {
|
||||
let valA, valB;
|
||||
if (currentSort === 'score') { valA = a.combinedScore; valB = b.combinedScore; }
|
||||
else if (currentSort === 'quality') { valA = a.copytradingQualityScore || 0; valB = b.copytradingQualityScore || 0; }
|
||||
else if (currentSort === 'copyability') { valA = a.copytradingCopyabilityScore || 0; valB = b.copytradingCopyabilityScore || 0; }
|
||||
else if (currentSort === 'winrate') { valA = a.winRate; valB = b.winRate; }
|
||||
else if (currentSort === 'pnl') { valA = a.totalPnl; valB = b.totalPnl; }
|
||||
else if (currentSort === 'name') { return a.displayName.localeCompare(b.displayName) * sortDirection; }
|
||||
else if (currentSort === 'platform') { return a.platform.localeCompare(b.platform) * sortDirection; }
|
||||
else { valA = a.combinedScore; valB = b.combinedScore; }
|
||||
|
||||
return (valA < valB ? -1 : valA > valB ? 1 : 0) * sortDirection;
|
||||
});
|
||||
|
||||
tbody.innerHTML = data.map((t, i) => `
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user