feat(ui): display detailed source provenance and match confidence in hero
This commit is contained in:
1 parent
fcca37ede7
commit
03fdfaed3b
1 file changed
+25
-4
+25
-4
@@ -134,12 +134,32 @@ function getYoutubeUrl(track) {
|
||||
return `https://www.youtube.com/results?search_query=${encodeURIComponent(term)}`;
|
||||
}
|
||||
|
||||
function formatSourceInfo(source, isCorrected) {
|
||||
if (isCorrected) return { match: '100%', label: 'PostgreSQL (Fix)' };
|
||||
switch (source) {
|
||||
case 'spotify':
|
||||
case 'seed':
|
||||
return { match: '100%', label: 'Spotify (Verifiziert)' };
|
||||
case 'songbpm':
|
||||
return { match: '98%', label: 'SongBPM (Spotify API)' };
|
||||
case 'audio_analysis':
|
||||
return { match: '85%', label: 'Audio-Analyse (ffmpeg)' };
|
||||
case 'getsongbpm':
|
||||
return { match: '90%', label: 'GetSongBPM' };
|
||||
case 'postgresql':
|
||||
return { match: '100%', label: 'PostgreSQL (Lokal)' };
|
||||
default:
|
||||
return { match: 'Online', label: 'Deezer / Online' };
|
||||
}
|
||||
}
|
||||
|
||||
async function selectTrack(track) {
|
||||
// Update Hero UI
|
||||
const initialSource = formatSourceInfo(track.source || (track.is_local ? 'postgresql' : null), track.is_corrected);
|
||||
document.getElementById('track-title').textContent = track.title;
|
||||
document.getElementById('track-artist').textContent = track.artist;
|
||||
document.getElementById('stat-match').textContent = track.is_corrected ? '100%' : 'Online';
|
||||
document.getElementById('stat-source-sub').textContent = track.is_local ? (track.is_corrected ? 'PostgreSQL (Fix)' : 'PostgreSQL') : 'Deezer / Online';
|
||||
document.getElementById('stat-match').textContent = initialSource.match;
|
||||
document.getElementById('stat-source-sub').textContent = initialSource.label;
|
||||
|
||||
// Stop any ongoing preview playback
|
||||
if (window.stopAllPreviews) window.stopAllPreviews();
|
||||
@@ -202,8 +222,9 @@ async function selectTrack(track) {
|
||||
const deezEl = document.getElementById('action-deezer');
|
||||
if (deezEl) deezEl.href = getDeezerUrl(track);
|
||||
}
|
||||
document.getElementById('stat-match').textContent = d.is_corrected ? '100%' : (d.source === 'postgresql' ? '100%' : 'Online');
|
||||
document.getElementById('stat-source-sub').textContent = d.source === 'postgresql' ? (d.is_corrected ? 'PostgreSQL (Fix)' : 'PostgreSQL') : 'PostgreSQL (Neu)';
|
||||
const metaSource = formatSourceInfo(d.source, d.is_corrected);
|
||||
document.getElementById('stat-match').textContent = metaSource.match;
|
||||
document.getElementById('stat-source-sub').textContent = metaSource.label;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Search] Metadata fetch failed, using fallback', e);
|
||||
|
||||
Reference in new issue
Block a user