// Copyright (c) 2026 Gordon Bolton. MIT License. import { useState, useEffect } from 'react'; import axios from 'axios'; import './App.css'; function App() { const [sessionId, setSessionId] = useState(''); const [currentUser, setCurrentUser] = useState(null); const [downloads, setDownloads] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [sessions, setSessions] = useState([]); useEffect(() => { fetchSessions(); }, []); const fetchSessions = async () => { try { const response = await axios.get('/api/emby/sessions'); setSessions(response.data); // Auto-select first active session const activeSession = response.data.find(s => s.NowPlayingItem || s.Active); if (activeSession) { setSessionId(activeSession.Id); fetchUserDownloads(activeSession.Id); } } catch (err) { setError('Failed to fetch Emby sessions. Make sure Emby is running and configured.'); console.error(err); } }; const fetchUserDownloads = async (sessionId) => { setLoading(true); setError(null); try { const response = await axios.get(`/api/dashboard/user-downloads/${sessionId}`); setCurrentUser(response.data.user); setDownloads(response.data.downloads); } catch (err) { setError('Failed to fetch downloads. Make sure all services are configured.'); console.error(err); } finally { setLoading(false); } }; const handleSessionChange = (e) => { const newSessionId = e.target.value; setSessionId(newSessionId); if (newSessionId) { fetchUserDownloads(newSessionId); } }; const formatSize = (bytes) => { if (!bytes) return 'N/A'; const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(1024)); return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i]; }; const formatDate = (dateString) => { if (!dateString) return 'N/A'; return new Date(dateString).toLocaleString(); }; return (

Media Download Dashboard

{currentUser && (
Current User: {currentUser}
)}
{error && (
{error}
)} {loading && (
Loading downloads...
)} {!loading && !error && (

Your Downloads

{downloads.length === 0 ? (

No downloads found for your user.

Make sure your shows and movies are tagged with "user:yourusername" in Sonarr/Radarr.

) : (
{downloads.map((download, index) => (
{download.coverArt && (
{download.movieName
)}
{download.type === 'series' ? '📺 Series' : '🎬 Movie'} {download.status}

{download.title}

{download.seriesName && (

Series: {download.seriesName}

)} {download.movieName && (

Movie: {download.movieName}

)}
Size: {formatSize(download.size)}
{download.progress && (
Progress: {download.progress}%
)} {download.speed && (
Speed: {download.speed}
)} {download.eta && (
ETA: {download.eta}
)} {download.completedAt && (
Completed: {formatDate(download.completedAt)}
)}
))}
)}
)}
); } export default App;