Fix profile page and Now Playing in frameset mode

Profile page fixes:
- Use session:field with string 'user-id' instead of symbol
- Use find-user-by-id to get user object
- Use dm:field to access user data (username, role)
- Add missing template parameters (top-artist-4, top-artist-5)
- Add error handling with detailed logging

Player-content fixes:
- Remove broken player.js that was causing ReferenceError
- Add simple inline Now Playing updater script
- Fetches /api/asteroid/partial/now-playing every 10 seconds
- Updates after 200ms initial delay

All fixes tested and working in frameset mode:
- Profile page loads correctly with user data
- Now Playing panel updates on player page
- Stream continues playing during navigation
- Spectrum analyzer MUTED indicator working
- Login/logout without halting stream

Known issue:
- ParenScript player.lisp has compilation issue (extra paren on line 242)
- Only 15/36 functions compile
- Non-frameset mode still halts stream on navigation (expected)
This commit is contained in:
Glenn Thompson 2025-12-07 10:17:44 +03:00
parent b54af08eeb
commit d39b155df3
2 changed files with 73 additions and 30 deletions

View File

@ -577,35 +577,53 @@
(define-page profile-content #@"/profile-content" () (define-page profile-content #@"/profile-content" ()
"User profile content (displayed in content frame)" "User profile content (displayed in content frame)"
(require-authentication) (require-authentication)
(clip:process-to-string (handler-case
(load-template "profile-content") (let* ((user-id (session:field "user-id"))
:title "🎧 admin - Profile | Asteroid Radio" (current-user (when user-id (find-user-by-id user-id)))
:username "admin" (username (if current-user
:user-role "admin" (let ((uname (dm:field current-user "username")))
:join-date "Unknown" (format nil "~a" (or uname "Unknown")))
:last-active "Unknown" "Unknown"))
:total-listen-time "0h 0m" (user-role (if current-user
:tracks-played "0" (let ((role (dm:field current-user "role")))
:session-count "0" (format nil "~a" (or role "user")))
:favorite-genre "Unknown" "user")))
:recent-track-1-title "" (clip:process-to-string
:recent-track-1-artist "" (load-template "profile-content")
:recent-track-1-duration "" :title (format nil "🎧 ~a - Profile | Asteroid Radio" username)
:recent-track-1-played-at "" :username username
:recent-track-2-title "" :user-role user-role
:recent-track-2-artist "" :join-date "Unknown"
:recent-track-2-duration "" :last-active "Unknown"
:recent-track-2-played-at "" :total-listen-time "0h 0m"
:recent-track-3-title "" :tracks-played "0"
:recent-track-3-artist "" :session-count "0"
:recent-track-3-duration "" :favorite-genre "Unknown"
:recent-track-3-played-at "" :recent-track-1-title ""
:top-artist-1 "" :recent-track-1-artist ""
:top-artist-1-plays "" :recent-track-1-duration ""
:top-artist-2 "" :recent-track-1-played-at ""
:top-artist-2-plays "" :recent-track-2-title ""
:top-artist-3 "" :recent-track-2-artist ""
:top-artist-3-plays "")) :recent-track-2-duration ""
:recent-track-2-played-at ""
:recent-track-3-title ""
:recent-track-3-artist ""
:recent-track-3-duration ""
:recent-track-3-played-at ""
:top-artist-1 ""
:top-artist-1-plays ""
:top-artist-2 ""
:top-artist-2-plays ""
:top-artist-3 ""
:top-artist-3-plays ""
:top-artist-4 ""
:top-artist-4-plays ""
:top-artist-5 ""
:top-artist-5-plays ""))
(error (e)
(format t "ERROR in profile-content: ~a~%" e)
(format nil "<html><body><h1>Error loading profile</h1><pre>~a</pre></body></html>" e))))
;; Status content frame (for frameset mode) ;; Status content frame (for frameset mode)
(define-page status-content #@"/status-content" () (define-page status-content #@"/status-content" ()

View File

@ -6,8 +6,33 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css"> <link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
<script src="/asteroid/static/js/auth-ui.js"></script> <script src="/asteroid/static/js/auth-ui.js"></script>
<script src="/asteroid/static/js/player.js"></script>
<script src="/api/asteroid/spectrum-analyzer.js"></script> <script src="/api/asteroid/spectrum-analyzer.js"></script>
<script>
// Simple Now Playing updater
function updateNowPlaying() {
fetch('/api/asteroid/partial/now-playing')
.then(response => {
const contentType = response.headers.get('content-type');
if (contentType && contentType.includes('text/html')) {
return response.text();
}
return '';
})
.then(data => {
const nowPlayingDiv = document.getElementById('now-playing');
if (nowPlayingDiv) {
nowPlayingDiv.innerHTML = data;
}
})
.catch(error => console.log('Could not fetch now playing:', error));
}
// Update on load and every 10 seconds
document.addEventListener('DOMContentLoaded', function() {
setTimeout(updateNowPlaying, 200);
setInterval(updateNowPlaying, 10000);
});
</script>
<script> <script>
// Handle logout without navigation // Handle logout without navigation
function handleLogout() { function handleLogout() {