diff --git a/allstarr/wwwroot/index.html b/allstarr/wwwroot/index.html index f628332..f9c70b1 100644 --- a/allstarr/wwwroot/index.html +++ b/allstarr/wwwroot/index.html @@ -1803,7 +1803,7 @@ } else { // isLocal is null/undefined - track is missing (not found locally or externally) statusBadge = 'Missing'; - // Add manual map button for missing tracks too + // Add both mapping buttons for missing tracks const firstArtist = (t.artists && t.artists.length > 0) ? t.artists[0] : ''; mapButton = ``; + style="margin-left:8px;font-size:0.75rem;padding:4px 8px;">Map to Local + `; } return ` @@ -1841,6 +1848,18 @@ openManualMap(playlistName, position, title, artist, spotifyId); }); }); + + // Add event listeners to external map buttons + document.querySelectorAll('.map-external-btn').forEach(btn => { + btn.addEventListener('click', function() { + const playlistName = this.getAttribute('data-playlist-name'); + const position = parseInt(this.getAttribute('data-position')); + const title = this.getAttribute('data-title'); + const artist = this.getAttribute('data-artist'); + const spotifyId = this.getAttribute('data-spotify-id'); + openExternalMap(playlistName, position, title, artist, spotifyId); + }); + }); } catch (error) { document.getElementById('tracks-list').innerHTML = '
Failed to load tracks
'; } @@ -2120,6 +2139,31 @@ openModal('manual-map-modal'); } + // Open external mapping modal (pre-set to external mode) + function openExternalMap(playlistName, position, title, artist, spotifyId) { + document.getElementById('map-playlist-name').value = playlistName; + document.getElementById('map-position').textContent = position + 1; + document.getElementById('map-spotify-title').textContent = title; + document.getElementById('map-spotify-artist').textContent = artist; + document.getElementById('map-spotify-id').value = spotifyId; + + // Set to external mapping mode + document.getElementById('map-type-select').value = 'external'; + document.getElementById('jellyfin-mapping-section').style.display = 'none'; + document.getElementById('external-mapping-section').style.display = 'block'; + + // Reset all fields + document.getElementById('map-search-query').value = ''; + document.getElementById('map-jellyfin-url').value = ''; + document.getElementById('map-selected-jellyfin-id').value = ''; + document.getElementById('map-external-id').value = ''; + document.getElementById('map-external-provider').value = 'SquidWTF'; + document.getElementById('map-save-btn').disabled = true; + document.getElementById('map-search-results').innerHTML = 'Enter an external provider ID above
'; + + openModal('manual-map-modal'); + } + // Update the saveManualMapping function to handle both types async function saveManualMapping() { const playlistName = document.getElementById('map-playlist-name').value;