diff --git a/server/index.ts b/server/index.ts index 6935606..4d08b87 100644 --- a/server/index.ts +++ b/server/index.ts @@ -398,8 +398,8 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse): if (url.pathname === '/api/requests/series' && method === 'POST') { const config = await readConfig(session!.encryptionKey); - const body = await readJson<{ tmdbId: number; user: string | null; qualityProfileId?: number }>(request); - await requestSeries(config, Number(body.tmdbId), body.user, Number(body.qualityProfileId) || undefined); + const body = await readJson<{ tmdbId: number; user: string | null; qualityProfileId?: number; seasonNumber?: number }>(request); + await requestSeries(config, Number(body.tmdbId), body.user, Number(body.qualityProfileId) || undefined, Number(body.seasonNumber) || undefined); sendJson(response, 200, { ok: true }); return; } diff --git a/server/lib/services.ts b/server/lib/services.ts index 67db7d3..0c02538 100644 --- a/server/lib/services.ts +++ b/server/lib/services.ts @@ -299,6 +299,7 @@ interface SonarrSeriesRecord { title?: string; tmdbId?: number; tvdbId?: number; + images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>; seasons?: Array<{ seasonNumber?: number; monitored?: boolean; @@ -2653,7 +2654,13 @@ export async function requestMovie(config: AppConfig, tmdbId: number, user: stri }); } -export async function requestSeries(config: AppConfig, tmdbId: number, user: string | null, qualityProfileId?: number): Promise { +export async function requestSeries( + config: AppConfig, + tmdbId: number, + user: string | null, + qualityProfileId?: number, + seasonNumber?: number +): Promise { if (!config.sonarr.baseUrl || !config.sonarr.apiKey) { throw new Error('Sonarr is not configured.'); } @@ -2675,13 +2682,16 @@ export async function requestSeries(config: AppConfig, tmdbId: number, user: str addProcessingItem({ source: 'sonarr', title: String(details.name || details.original_name || 'Series'), - subtitle: 'All seasons', + subtitle: typeof seasonNumber === 'number' ? `Season ${seasonNumber}` : 'All seasons', tmdbId, + posterUrl: typeof details.poster_path === 'string' && details.poster_path + ? `${TMDB_IMAGE}/w342${details.poster_path}` + : undefined, mediaType: 'series', user: user || 'Unknown', }); - await fetchJson(`${config.sonarr.baseUrl}/api/v3/series`, { + const series = await fetchJson(`${config.sonarr.baseUrl}/api/v3/series`, { method: 'POST', headers: { 'X-Api-Key': config.sonarr.apiKey, @@ -2696,13 +2706,53 @@ export async function requestSeries(config: AppConfig, tmdbId: number, user: str seasonFolder: true, monitored: config.sonarr.monitor !== 'none', addOptions: { - monitor: config.sonarr.monitor, - searchForMissingEpisodes: true, - searchForCutoffUnmetEpisodes: true + monitor: typeof seasonNumber === 'number' ? 'none' : config.sonarr.monitor, + searchForMissingEpisodes: typeof seasonNumber !== 'number', + searchForCutoffUnmetEpisodes: typeof seasonNumber !== 'number' } }) }); + if (typeof seasonNumber !== 'number') { + return + } + + if (!series?.id) { + throw new Error('Sonarr did not return the added series.') + } + + const seasons = (series.seasons || []).map((season) => + season.seasonNumber === seasonNumber + ? { ...season, monitored: true } + : { ...season, monitored: false } + ) + if (!seasons.some((season) => season.seasonNumber === seasonNumber)) { + throw new Error(`Season ${seasonNumber} was not found in Sonarr.`) + } + + await fetchJson(`${config.sonarr.baseUrl}/api/v3/series/${encodeURIComponent(String(series.id))}`, { + method: 'PUT', + headers: { + 'X-Api-Key': config.sonarr.apiKey, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ ...series, seasons }) + }) + + await fetchJson(`${config.sonarr.baseUrl}/api/v3/command`, { + method: 'POST', + headers: { + 'X-Api-Key': config.sonarr.apiKey, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + name: 'SeasonSearch', + seriesId: series.id, + seasonNumber, + qualityProfileId + }) + }) + } export async function requestSeason(config: AppConfig, payload: SeasonRequestPayload, user: string | null): Promise { @@ -2760,6 +2810,7 @@ export async function requestSeason(config: AppConfig, payload: SeasonRequestPay title: series.title || 'Series', subtitle: `Season ${payload.seasonNumber}`, tmdbId: series.tmdbId, + posterUrl: extractRemoteImage(series.images), mediaType: 'tv', user: user || 'Unknown', }); diff --git a/src/App.tsx b/src/App.tsx index c8a2288..7ed0103 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -340,7 +340,7 @@ function App() { } } - async function handleRequest(card: MediaCard, qualityProfileId?: number) { + async function handleRequest(card: MediaCard, qualityProfileId?: number, seasonNumber?: number) { if (!card.tmdbId) return setBusy(true) @@ -350,7 +350,7 @@ function App() { if (card.mediaType === 'movie') { await api.requestMovie(card.tmdbId, currentJellyfinUser, qualityProfileId) } else { - await api.requestSeries(card.tmdbId, currentJellyfinUser, qualityProfileId) + await api.requestSeries(card.tmdbId, currentJellyfinUser, qualityProfileId, seasonNumber) } if (route !== 'downloads' && route !== 'settings' && route !== 'search' && route !== 'calendar') { await loadHub(route as HubPageResponse['page'], { silent: true }) @@ -1571,7 +1571,7 @@ function TitleDetailsModal(props: { config: AppConfig onClose: () => void originRect: ModalOriginRect | null - onRequest: (card: MediaCard, qualityProfileId?: number) => Promise + onRequest: (card: MediaCard, qualityProfileId?: number, seasonNumber?: number) => Promise currentUser: string | null qualityProfiles: { sonarr: SelectOption[]; radarr: SelectOption[] } }) { @@ -2184,7 +2184,7 @@ function TitleDetailsModal(props: { qualityProfileId, }, props.currentUser) } else { - await props.onRequest(props.card, qualityProfileId) + await props.onRequest(props.card, qualityProfileId, activeSeasonNumber) } await refreshSeasonState(seasonValue || undefined) } catch (error) { @@ -3083,23 +3083,84 @@ function DownloadsPage(props: { onDismissAllCompleted: () => void }) { const hasAny = props.processingItems.length > 0 || props.downloads.length > 0 || props.completedDownloads.length > 0 + const [selectionMode, setSelectionMode] = useState(false) + const [selectedDownloadIds, setSelectedDownloadIds] = useState([]) + const [selectedHistoryIds, setSelectedHistoryIds] = useState([]) + const [batchBusy, setBatchBusy] = useState(false) + const selectedCount = selectedDownloadIds.length + selectedHistoryIds.length + + function toggleSelection(id: string, type: 'download' | 'history') { + const update = type === 'download' ? setSelectedDownloadIds : setSelectedHistoryIds + update((current) => current.includes(id) ? current.filter((value) => value !== id) : [...current, id]) + } + + function closeSelectionMode() { + setSelectionMode(false) + setSelectedDownloadIds([]) + setSelectedHistoryIds([]) + } + + async function cancelSelectedDownloads() { + if (!selectedDownloadIds.length || !window.confirm(`Cancel ${selectedDownloadIds.length} selected download${selectedDownloadIds.length === 1 ? '' : 's'}?`)) { + return + } + + setBatchBusy(true) + try { + await Promise.all(selectedDownloadIds.map((id) => props.onDelete(id))) + setSelectedDownloadIds([]) + } finally { + setBatchBusy(false) + } + } + + function dismissSelectedHistory() { + if (!selectedHistoryIds.length || !window.confirm(`Delete ${selectedHistoryIds.length} selected history entr${selectedHistoryIds.length === 1 ? 'y' : 'ies'}?`)) { + return + } + + selectedHistoryIds.forEach((id) => props.onDismissCompleted(id)) + setSelectedHistoryIds([]) + } return (

Downloads

+
+ {selectionMode ? ( +
+ {selectedCount ? `${selectedCount} selected` : 'Select downloads or history entries'} +
+ {selectedDownloadIds.length ? : null} + {selectedHistoryIds.length ? : null} +
+
+ ) : null} + {props.processingItems.length > 0 ? (

Processing

{props.processingItems.map((item) => (
-
+
{item.posterUrl || item.backdropUrl - ? {item.title} + ? ( + + {item.posterUrl ? : null} + {item.title} + + ) :
{item.title.slice(0, 1).toUpperCase()}
}
@@ -3142,6 +3203,9 @@ function DownloadsPage(props: { item={item} key={item.id} onDelete={props.onDelete} + onToggleSelection={() => toggleSelection(item.id, 'download')} + selected={selectedDownloadIds.includes(item.id)} + selectionMode={selectionMode} /> ))}
@@ -3152,21 +3216,33 @@ function DownloadsPage(props: {

History

- + : null}
{props.completedDownloads.map((item) => ( -
- +
+ {selectionMode ? ( + + ) : ( + + )}
{item.posterUrl || item.backdropUrl @@ -3206,9 +3282,14 @@ function DownloadsPage(props: { ) : null} {!hasAny ? ( -
-
- +
+
+ +

No active downloads

+

The queue will appear here as soon as your services start working.

) : null} @@ -3220,6 +3301,9 @@ function DownloadRow(props: { item: DownloadItem busy: boolean onDelete: (id: string) => Promise + selectionMode: boolean + selected: boolean + onToggleSelection: () => void }) { const item = props.item const progressMeta = [item.size, item.speed, item.eta].filter(Boolean).join(' · ') @@ -3234,10 +3318,26 @@ function DownloadRow(props: { } return ( -
+
+ {props.selectionMode ? ( + + ) : null}
- {artwork ? {item.title} :
{item.title.slice(0, 1).toUpperCase()}
} + {artwork ? ( + + {item.posterUrl ? : null} + {item.title} + + ) :
{item.title.slice(0, 1).toUpperCase()}
}

{item.title}

@@ -3256,7 +3356,7 @@ function DownloadRow(props: {
- + : null}
@@ -3408,7 +3508,12 @@ function CalendarPage(props: { type="button" >
- {entry.imageUrl ? {entry.title} :
{entry.title.slice(0, 1).toUpperCase()}
} + {entry.imageUrl || entry.card.posterUrl ? ( + + {entry.card.posterUrl ? : null} + {entry.title} + + ) :
{entry.title.slice(0, 1).toUpperCase()}
}

{entry.title}

diff --git a/src/api.ts b/src/api.ts index de7fa3d..4e48793 100644 --- a/src/api.ts +++ b/src/api.ts @@ -127,10 +127,10 @@ export const api = { method: 'POST', body: JSON.stringify({ tmdbId, user, qualityProfileId }), }), - requestSeries: (tmdbId: number, user: string | null, qualityProfileId?: number) => + requestSeries: (tmdbId: number, user: string | null, qualityProfileId?: number, seasonNumber?: number) => request<{ ok: boolean }>('/api/requests/series', { method: 'POST', - body: JSON.stringify({ tmdbId, user, qualityProfileId }), + body: JSON.stringify({ tmdbId, user, qualityProfileId, seasonNumber }), }), requestSeason: (payload: SeasonRequestPayload, user: string | null) => request<{ ok: boolean }>('/api/requests/season', { diff --git a/src/index.css b/src/index.css index c35985e..f677ad4 100644 --- a/src/index.css +++ b/src/index.css @@ -562,6 +562,7 @@ img { .notice { background: rgba(97, 239, 171, 0.14); color: #91f5c4; + display: none; } .error-banner { @@ -3021,6 +3022,99 @@ img { flex: 0 0 auto; } +.downloads-header { + position: relative; +} + +.downloads-selection-toggle { + position: absolute; + top: 50%; + right: 2.35rem; + display: inline-grid; + box-sizing: border-box; + width: auto; + height: 2.2rem; + min-height: 0; + padding: 0.35rem 0.75rem; + place-items: center; + border: 1px solid rgba(255, 255, 255, 0.14); + border-radius: 999px; + background: rgba(255, 255, 255, 0.06); + color: #dfe7f5; + font: inherit; + font-size: 0.82rem; + font-weight: 700; + transform: translateY(-50%); +} + +.downloads-selection-toggle.is-active { + border-color: rgba(104, 171, 255, 0.65); + background: rgba(104, 171, 255, 0.16); + color: #cce1ff; +} + +.downloads-selection-toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + margin: 0 2.35rem; + padding: 0.7rem 0.85rem; + border: 1px solid rgba(104, 171, 255, 0.18); + border-radius: 0.9rem; + background: rgba(104, 171, 255, 0.08); + color: #c8d5ea; + font-size: 0.84rem; +} + +.downloads-selection-toolbar > div { + display: flex; + flex-wrap: wrap; + justify-content: flex-end; + gap: 0.45rem; +} + +.downloads-selection-toolbar button { + min-height: 2rem; + padding: 0.3rem 0.65rem; + border: 1px solid rgba(255, 255, 255, 0.16); + border-radius: 0.6rem; + background: rgba(255, 255, 255, 0.09); + color: #f0f5ff; + font: inherit; + font-size: 0.78rem; + font-weight: 700; +} + +.download-row.is-selecting { + position: relative; + border-color: rgba(104, 171, 255, 0.3); +} + +.download-selection-check { + position: absolute; + z-index: 3; + top: 0.65rem; + right: 0.65rem; + display: grid; + width: 1.55rem; + height: 1.55rem; + padding: 0; + place-items: center; + border: 1px solid rgba(255, 255, 255, 0.28); + border-radius: 999px; + background: rgba(9, 11, 16, 0.8); + color: #07111e; + font: inherit; + font-size: 0.9rem; + font-weight: 800; +} + +.download-selection-check.is-selected { + border-color: #7ab7ff; + background: #7ab7ff; +} + .search-header p { margin: 0.35rem 0 0; color: #95a2ba; @@ -3177,6 +3271,12 @@ img { object-fit: cover; } +.calendar-entry-art picture { + display: block; + width: 100%; + height: 100%; +} + .calendar-entry-copy { display: grid; align-content: center; @@ -3229,6 +3329,159 @@ img { color: #93a0b9; } +/* The calendar's desktop rules are declared last, so keep the mobile layout here. */ +@media (max-width: 980px) { + .calendar-page { + gap: 1rem; + height: auto; + min-height: 100%; + padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1rem 1rem; + } + + .calendar-header { + gap: 1rem; + padding: 0; + } + + .calendar-container { + flex: none; + padding: 0.7rem; + border-radius: 1.1rem; + } + + .calendar-scroll-container { + height: auto; + overflow: visible; + } + + .calendar-group-header { + padding: 0 0.3rem; + } + + .calendar-entry-card { + grid-template-columns: 4.8rem minmax(0, 1fr); + grid-template-areas: + 'art copy' + 'art time'; + gap: 0.35rem 0.75rem; + align-items: start; + padding: 0.65rem; + border-radius: 1rem; + } + + .calendar-entry-art { + grid-area: art; + order: initial; + aspect-ratio: 2 / 3; + border-radius: 0.7rem; + } + + .calendar-entry-copy { + grid-area: copy; + align-content: start; + gap: 0.25rem; + padding-top: 0.1rem; + } + + .calendar-entry-copy h4 { + font-size: 0.95rem; + line-height: 1.2; + } + + .calendar-entry-subtitle, + .calendar-entry-detail { + font-size: 0.78rem; + line-height: 1.3; + } + + .calendar-entry-time { + grid-area: time; + justify-items: start; + align-content: end; + padding-top: 0; + } + + .calendar-entry-time span { + min-height: 0; + font-size: 1rem; + } +} + +@media (max-width: 980px) { + .calendar-page { + gap: 1rem; + height: auto; + min-height: 100%; + padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1rem 1rem; + } + + .calendar-header { + gap: 1rem; + padding: 0; + } + + .calendar-container { + flex: none; + padding: 0.7rem; + border-radius: 1.1rem; + } + + .calendar-scroll-container { + height: auto; + overflow: visible; + } + + .calendar-group-header { + padding: 0 0.3rem; + } + + .calendar-entry-card { + grid-template-columns: 4.8rem minmax(0, 1fr); + grid-template-areas: + 'art copy' + 'art time'; + gap: 0.35rem 0.75rem; + align-items: start; + padding: 0.65rem; + border-radius: 1rem; + } + + .calendar-entry-art { + grid-area: art; + aspect-ratio: 2 / 3; + border-radius: 0.7rem; + } + + .calendar-entry-copy { + grid-area: copy; + align-content: start; + gap: 0.25rem; + padding-top: 0.1rem; + } + + .calendar-entry-copy h4 { + font-size: 0.95rem; + line-height: 1.2; + } + + .calendar-entry-subtitle, + .calendar-entry-detail { + font-size: 0.78rem; + line-height: 1.3; + } + + .calendar-entry-time { + grid-area: time; + justify-items: start; + align-content: end; + } + + .calendar-entry-time span { + min-height: 0; + font-size: 1rem; + } +} + .downloads-section { padding: 0 1.25rem 1.4rem; } @@ -3308,6 +3561,86 @@ img { color: #9ca4b8; } +.downloads-empty-section { + display: grid; + min-height: clamp(14rem, 44svh, 28rem); + place-items: center; +} + +.downloads-empty-state { + display: grid; + justify-items: center; + max-width: 28rem; + gap: 0.45rem; + text-align: center; +} + +.downloads-empty-state h4, +.downloads-empty-state p { + margin: 0; +} + +.downloads-empty-state h4 { + color: #eef4ff; + font-size: 1.15rem; +} + +.downloads-empty-state p { + color: #9ca4b8; +} + +.downloads-empty-icon { + position: relative; + display: grid; + width: 3.5rem; + height: 3.5rem; + margin-bottom: 0.35rem; + place-items: center; + border: 1px solid rgba(255, 255, 255, 0.14); + border-radius: 1rem; + background: rgba(255, 255, 255, 0.045); + color: #c5cede; +} + +.downloads-empty-icon .title-action-icon { + width: 1.55rem; + height: 1.55rem; +} + +.downloads-empty-icon span { + position: absolute; + top: 0; + right: 0; + display: grid; + box-sizing: border-box; + width: 1.2rem; + height: 1.2rem; + border: 2px solid #000; + border-radius: 999px; + background: #7e8798; + transform: translate(35%, -35%); +} + +.downloads-empty-icon span::before, +.downloads-empty-icon span::after { + content: ''; + position: absolute; + top: 50%; + left: 50%; + width: 0.55rem; + height: 2px; + border-radius: 999px; + background: #10131a; +} + +.downloads-empty-icon span::before { + transform: translate(-50%, -50%) rotate(45deg); +} + +.downloads-empty-icon span::after { + transform: translate(-50%, -50%) rotate(-45deg); +} + .download-subtitle { margin: 0; color: #dce4f4; @@ -3671,12 +4004,20 @@ img { } .loading-orb { - width: 4rem; - height: 4rem; + width: 3rem; + height: 3rem; + box-sizing: border-box; border-radius: 999px; - background: radial-gradient(circle, #ffd166 0%, #ff8d4d 50%, rgba(255, 141, 77, 0) 70%); - filter: blur(4px); - animation: pulse 1.8s ease-in-out infinite; + border: 3px solid rgba(238, 244, 255, 0.16); + border-top-color: #eef4ff; + border-right-color: rgba(104, 171, 255, 0.8); + animation: loading-spinner 720ms linear infinite; +} + +@keyframes loading-spinner { + to { + transform: rotate(360deg); + } } .loading-placeholder { @@ -5232,3 +5573,119 @@ img { .calendar-entry-detail { color: #93a0b9; } + +/* Mobile overrides must come after the desktop calendar component styles. */ +@media (max-width: 980px) { + .mobile-menu-toggle { + top: max(1rem, calc(env(safe-area-inset-top, 0px) + 0.15rem)); + } + + .calendar-page { + gap: 1rem; + height: auto; + min-height: 100%; + padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1rem 1rem; + } + + .calendar-header { + gap: 1rem; + min-height: 2.9rem; + padding: 0; + } + + .downloads-header { + display: grid; + box-sizing: border-box; + height: 2.9rem; + min-height: 2.9rem; + margin-top: calc(env(safe-area-inset-top, 0px) + 1rem); + padding: 0 4.75rem; + position: relative; + top: 0; + place-items: center; + } + + .downloads-selection-toggle { + top: 0; + bottom: 0; + right: 1rem; + margin-block: auto; + transform: none; + } + + .downloads-selection-toolbar { + align-items: flex-start; + flex-direction: column; + margin: 0 1rem; + } + + .downloads-selection-toolbar > div { + width: 100%; + justify-content: flex-start; + } + + .calendar-container { + flex: none; + padding: 0; + border: 0; + border-radius: 0; + background: transparent; + } + + .calendar-scroll-container { + height: auto; + overflow: visible; + } + + .calendar-group-header { + padding: 0 0.3rem; + } + + .calendar-entry-card { + grid-template-columns: 4.8rem minmax(0, 1fr); + grid-template-areas: + 'art copy' + 'art time'; + gap: 0.35rem 0.75rem; + align-items: start; + padding: 0.65rem; + border-radius: 1rem; + } + + .calendar-entry-art { + grid-area: art; + order: initial; + aspect-ratio: 2 / 3; + border-radius: 0.7rem; + } + + .calendar-entry-copy { + grid-area: copy; + align-content: start; + gap: 0.25rem; + padding-top: 0.1rem; + } + + .calendar-entry-copy h4 { + font-size: 0.95rem; + line-height: 1.2; + } + + .calendar-entry-subtitle, + .calendar-entry-detail { + font-size: 0.78rem; + line-height: 1.3; + } + + .calendar-entry-time { + grid-area: time; + justify-items: start; + align-content: end; + padding-top: 0; + } + + .calendar-entry-time span { + min-height: 0; + font-size: 1rem; + } +}