From 4442c8468cd52d52c84fb11bd3cbaf3680174fd1 Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Sun, 12 Oct 2025 22:44:25 +0530 Subject: [PATCH] working --- static/index.html | 112 +++++++++++++++++++++++++++++++++++++++++----- watchlist.json | 2 +- 2 files changed, 101 insertions(+), 13 deletions(-) diff --git a/static/index.html b/static/index.html index a29194a..b440c4a 100644 --- a/static/index.html +++ b/static/index.html @@ -251,6 +251,7 @@ let wsReconnectTimer = null; let wsReconnectAttempts = 0; let maxReconnectAttempts = 10; + let watchlistUpdateTimeout = null; let state = { spots: [], @@ -281,6 +282,7 @@ wsStatus: 'disconnected', activeTab: 'stats', watchlist: [], + watchlistShowOnlyActive: false, spotFilters: { showAll: true, showNewDXCC: false, @@ -372,6 +374,7 @@ case 'stats': state.stats = message.data; updateStatsOnly(); + updateStatusIndicators(); break; case 'spots': state.spots = message.data || []; @@ -381,6 +384,16 @@ if (state.activeTab === 'stats') { updateBandPropagation(); } + if (state.activeTab === 'watchlist') { + if (watchlistUpdateTimeout) { + clearTimeout(watchlistUpdateTimeout); + } + watchlistUpdateTimeout = setTimeout(() => { + updateWatchlistItems(); + updateWatchlistCounters(); + watchlistUpdateTimeout = null; + }, 2000); + } break; case 'spotters': state.topSpotters = message.data || []; @@ -554,6 +567,7 @@ } } + function updateSpotCounts() { // Vider le cache countCache = {}; @@ -1624,7 +1638,17 @@
-

Watchlist

+
+

Watchlist

+ +

${countWatchlistSpots()} matching spots

@@ -1760,6 +1784,9 @@ updateBandPropagation(); updateTopSpotters(); // Au cas où } + + updateStatusIndicators(); + // Restaurer le scroll de la table des spots const newSpotsContainer = document.querySelector('.scrollable'); if (newSpotsContainer && scrollTop > 0) { @@ -1863,7 +1890,6 @@ // Grouper les spots par callsign/prefix const spotsByCallsign = {}; watchlistSpots.forEach(spot => { - // Trouver le pattern correspondant let matchedPattern = ''; for (const pattern of state.watchlist) { if (spot.dx === pattern || spot.dx.startsWith(pattern)) { @@ -1878,7 +1904,26 @@ spotsByCallsign[matchedPattern].push(spot); }); - container.innerHTML = state.watchlist.map(callsign => { + // ✅ Filtrer la liste selon le toggle "Active Only" + const displayList = state.watchlistShowOnlyActive + ? state.watchlist.filter(callsign => (spotsByCallsign[callsign] || []).length > 0) + : state.watchlist; + + // ✅ Afficher un message si aucun callsign avec spots actifs + if (displayList.length === 0 && state.watchlistShowOnlyActive) { + container.innerHTML = ` +
+ + + +

No active spots for watchlist callsigns

+

Click "Active Only" to see all watchlist entries

+
+ `; + return; + } + + container.innerHTML = displayList.map(callsign => { const spots = spotsByCallsign[callsign] || []; const matchingCount = spots.length; @@ -1922,21 +1967,28 @@
` : '
No active spots
'; - const neededCount = spots.filter(s => !s.workedBandMode).length; - let neededBadge = ''; - if (matchingCount > 0) { - neededBadge = neededCount > 0 - ? `${neededCount} needed` - : 'All worked'; - } + // ✅ Ne calculer le badge que s'il y a des spots + let neededBadge = ''; + if (matchingCount > 0) { + const neededCount = spots.filter(s => !s.workedBandMode).length; + neededBadge = neededCount > 0 + ? `${neededCount} needed` + : 'All worked'; + } + + const neededCount = spots.filter(s => !s.workedBandMode).length; + const borderClass = neededCount > 0 ? 'border-orange-500/30' : 'border-slate-700/50'; return ` -
+
${callsign}
- ${matchingCount} active spot${matchingCount !== 1 ? 's' : ''} + ${matchingCount > 0 + ? `${matchingCount} active spot${matchingCount !== 1 ? 's' : ''}` + : 'No active spots' + } ${neededBadge}
@@ -1960,6 +2012,38 @@ } } + function toggleWatchlistActiveOnly() { + state.watchlistShowOnlyActive = !state.watchlistShowOnlyActive; + + // Sauvegarder la préférence + localStorage.setItem('watchlistShowOnlyActive', state.watchlistShowOnlyActive); + + // Mettre à jour visuellement le bouton + const button = document.querySelector('button[onclick="toggleWatchlistActiveOnly()"]'); + if (button) { + if (state.watchlistShowOnlyActive) { + button.className = 'px-3 py-1.5 text-xs rounded transition-colors flex items-center gap-2 bg-blue-600 text-white'; + button.innerHTML = ` + + + + Show All + `; + } else { + button.className = 'px-3 py-1.5 text-xs rounded transition-colors flex items-center gap-2 bg-slate-700/50 text-slate-300 hover:bg-slate-700'; + button.innerHTML = ` + + + + Active Only + `; + } + } + + // Mettre à jour la liste + updateWatchlistItems(); + } + async function initPropagation() { state.solarData = await fetchPropagationData(); @@ -1973,6 +2057,10 @@ // Initialize async function init() { + const savedPref = localStorage.getItem('watchlistShowOnlyActive'); + if (savedPref !== null) { + state.watchlistShowOnlyActive = savedPref === 'true'; + } await initPropagation(); await fetchLogData(); connectWebSocket(); diff --git a/watchlist.json b/watchlist.json index fa20274..335ddb4 100644 --- a/watchlist.json +++ b/watchlist.json @@ -1 +1 @@ -["H44MS","5X2I","PY0FB","PY0FBS","XT2AW","ZL7IO","YJ0CA","FW5K","J38","E6AD","E51MWA","PJ6Y","5J0EA","5K0UA","VP2M"] \ No newline at end of file +["H44MS","5X2I","PY0FB","PY0FBS","XT2AW","ZL7IO","YJ0CA","FW5K","J38","E6AD","E51MWA","PJ6Y","5J0EA","5K0UA","VP2M","5X1XA","C5R","C5LT","EL2BG"] \ No newline at end of file