mirror of
https://github.com/WonderAliceUwU/OmniArr.git
synced 2026-11-19 19:35:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f1cde1852 | ||
|
|
adf9993b10 | ||
|
|
7da0377d50 | ||
|
|
64f9a84678 | ||
|
|
ee288e7bd7 | ||
|
|
6a59aaffa3 | ||
|
|
9ed8260a10 | ||
|
|
1376d75ed8 | ||
|
|
4cea990eb3 | ||
|
|
2b4119a906 | ||
|
|
8fc9833679 | ||
|
|
0672b8c72b | ||
|
|
591fac51b2 | ||
|
|
a926964834 | ||
|
|
fb07b27675 | ||
|
|
9f1d50b35d |
No files matched your search
@@ -33,6 +33,7 @@ If OmniArr is useful to you, you can support its development on [Ko-fi](https://
|
|||||||
<img width="4208" height="2562" alt="Screenshot 2026-10-13 at 09 47 49" src="https://github.com/user-attachments/assets/82766b80-fb0d-4ff2-b594-203e6b52828f" />
|
<img width="4208" height="2562" alt="Screenshot 2026-10-13 at 09 47 49" src="https://github.com/user-attachments/assets/82766b80-fb0d-4ff2-b594-203e6b52828f" />
|
||||||
|
|
||||||
- A download manager to see what's cooking.
|
- A download manager to see what's cooking.
|
||||||
|
- Per-profile control of which sections each person sees (see [Profiles](#profiles)).
|
||||||
|
|
||||||
And many things more!
|
And many things more!
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ Create a directory for OmniArr and add this `docker-compose.yml`:
|
|||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
omniarr:
|
omniarr:
|
||||||
image: wonderalice/omniarr:1.2.2
|
image: wonderalice/omniarr:1.2.5
|
||||||
container_name: omniarr
|
container_name: omniarr
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
@@ -90,11 +91,11 @@ the mount loses that state when the container is replaced.
|
|||||||
The current release is available as:
|
The current release is available as:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
wonderalice/omniarr:1.2.2
|
wonderalice/omniarr:1.2.5
|
||||||
wonderalice/omniarr:latest
|
wonderalice/omniarr:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Pin `1.2.2` in production for repeatable updates. Use `latest` only when you want
|
Pin `1.2.5` in production for repeatable updates. Use `latest` only when you want
|
||||||
Compose to follow the newest published image.
|
Compose to follow the newest published image.
|
||||||
|
|
||||||
## Build locally
|
## Build locally
|
||||||
@@ -122,6 +123,50 @@ npm run lint
|
|||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Profiles
|
||||||
|
|
||||||
|
Open **Administration → Profiles** to see every Jellyfin profile. Selecting one
|
||||||
|
opens its settings:
|
||||||
|
|
||||||
|
- **Sections** are on/off switches for Search, Upcoming, Downloads, Wishlist,
|
||||||
|
K-Drama, Anime, Library and each network. Everything is on by default and
|
||||||
|
Home is always available. A hidden section disappears from the menu and the
|
||||||
|
server refuses its requests for that profile. The administrator always sees
|
||||||
|
everything.
|
||||||
|
- **Libraries** shows which Jellyfin libraries the profile can open. It is read
|
||||||
|
from Jellyfin and cannot be changed here; manage it in Jellyfin.
|
||||||
|
|
||||||
|
Save with the check button of the Profiles card.
|
||||||
|
|
||||||
|
### Upcoming and library access
|
||||||
|
|
||||||
|
Upcoming comes from Sonarr and Radarr, which know nothing about Jellyfin
|
||||||
|
permissions. To keep each profile's calendar to what it can open, OmniArr asks
|
||||||
|
Jellyfin for the libraries a profile cannot open and leaves out the releases
|
||||||
|
that are stored in them.
|
||||||
|
|
||||||
|
Sonarr, Radarr and Jellyfin often mount the media folder under different paths
|
||||||
|
(for example `/shared/Library/Anime` for Sonarr and `/library/Anime` for
|
||||||
|
Jellyfin), so a release is matched to a library by the **name of the library
|
||||||
|
folder** found in the series or movie path. Keep that folder name the same in
|
||||||
|
all three apps. A release whose path does not contain the name of any library is
|
||||||
|
shown to everyone, and if Jellyfin cannot be reached the calendar is not
|
||||||
|
filtered.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
The tests run against small stand-ins for Jellyfin, Sonarr and Radarr
|
||||||
|
(`server/test/mock-services.ts`). Some call the code directly and `api.e2e.test.ts`
|
||||||
|
starts the real server and signs in as the administrator and as profiles, so it
|
||||||
|
checks what each of them receives from the API. To point a running OmniArr at them while
|
||||||
|
developing, start them with `node dist-server/server/test/mock-services.js` after
|
||||||
|
a build; it prints the three URLs, accepts any API key and offers a `full`
|
||||||
|
profile and a `limited` one that cannot open Anime or Anime Movies.
|
||||||
|
|
||||||
## Data and security
|
## Data and security
|
||||||
|
|
||||||
OmniArr keeps critical state under `OMNIARR_DATA_DIR` (by default
|
OmniArr keeps critical state under `OMNIARR_DATA_DIR` (by default
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
omniarr:
|
omniarr:
|
||||||
image: wonderalice/omniarr:1.2.2
|
image: wonderalice/omniarr:1.2.5
|
||||||
# Para construir desde código fuente en su lugar, descomenta estas líneas:
|
# Para construir desde código fuente en su lugar, descomenta estas líneas:
|
||||||
# build:
|
# build:
|
||||||
# context: .
|
# context: .
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,8 @@
|
|||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"start": "node dist-server/server/index.js",
|
"start": "node dist-server/server/index.js",
|
||||||
"serve": "npm run build && npm run start"
|
"serve": "npm run build && npm run start",
|
||||||
|
"test": "tsc -p tsconfig.server.json && node --test dist-server/server/test/*.test.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^19.2.5",
|
"react": "^19.2.5",
|
||||||
|
|||||||
+35
-2
@@ -4,6 +4,7 @@ import { BlockList, isIP } from 'node:net';
|
|||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import {
|
import {
|
||||||
defaultConfig,
|
defaultConfig,
|
||||||
|
HIDEABLE_SECTIONS,
|
||||||
type AppConfig,
|
type AppConfig,
|
||||||
type AuthPayload,
|
type AuthPayload,
|
||||||
type BackupFile,
|
type BackupFile,
|
||||||
@@ -14,6 +15,7 @@ import {
|
|||||||
type SeriesEpisodeRequestPayload,
|
type SeriesEpisodeRequestPayload,
|
||||||
type EpisodeWatchStateRequest,
|
type EpisodeWatchStateRequest,
|
||||||
type DiskSpaceStatus,
|
type DiskSpaceStatus,
|
||||||
|
type HideableSection,
|
||||||
type HubPageResponse,
|
type HubPageResponse,
|
||||||
type JellyfinLoginPayload,
|
type JellyfinLoginPayload,
|
||||||
type MovieDeletePayload,
|
type MovieDeletePayload,
|
||||||
@@ -58,6 +60,7 @@ import {
|
|||||||
setEpisodeWatchState,
|
setEpisodeWatchState,
|
||||||
sanitizeConfig,
|
sanitizeConfig,
|
||||||
getDownloadsResponse,
|
getDownloadsResponse,
|
||||||
|
getProfileLibraryAccess,
|
||||||
dismissCompletedDownload,
|
dismissCompletedDownload,
|
||||||
dismissAllCompletedDownloads
|
dismissAllCompletedDownloads
|
||||||
} from './lib/services.js';
|
} from './lib/services.js';
|
||||||
@@ -274,6 +277,23 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.pathname === '/api/admin/profile-access' && method === 'GET') {
|
||||||
|
const config = await readConfig(session!.encryptionKey);
|
||||||
|
sendJson(response, 200, { profiles: await getProfileLibraryAccess(config) });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sections the administrator switched off for this profile are closed on the
|
||||||
|
// server too, not only hidden from the menu.
|
||||||
|
const section = session?.role === 'user' && session.userId ? getSectionOfRoute(url.pathname) : null;
|
||||||
|
if (section) {
|
||||||
|
const config = await readConfig(session!.encryptionKey);
|
||||||
|
if ((config.preferences.hiddenSections[session!.userId!] ?? []).includes(section)) {
|
||||||
|
sendJson(response, 403, { error: 'This section is not available for your profile.' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (url.pathname === '/api/admin/backup' && method === 'GET') {
|
if (url.pathname === '/api/admin/backup' && method === 'GET') {
|
||||||
const backup: BackupFile = {
|
const backup: BackupFile = {
|
||||||
app: 'omniarr',
|
app: 'omniarr',
|
||||||
@@ -711,6 +731,16 @@ function mergeStoredConfig(stored: Partial<AppConfig>): AppConfig {
|
|||||||
|
|
||||||
// Profiles keep their own wishlist; the administrator has no Jellyfin profile
|
// Profiles keep their own wishlist; the administrator has no Jellyfin profile
|
||||||
// and shares a single one.
|
// and shares a single one.
|
||||||
|
// The section of the app an API route serves, if the administrator can switch it off.
|
||||||
|
function getSectionOfRoute(pathname: string): HideableSection | null {
|
||||||
|
const section = pathname.startsWith('/api/downloads') ? 'downloads'
|
||||||
|
: pathname.startsWith('/api/calendar') ? 'calendar'
|
||||||
|
: pathname.startsWith('/api/search') ? 'search'
|
||||||
|
: pathname.startsWith('/api/hubs/') ? decodeURIComponent(pathname.replace('/api/hubs/', ''))
|
||||||
|
: '';
|
||||||
|
return HIDEABLE_SECTIONS.find((candidate) => candidate.id === section)?.id ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
function getWishlistOwner(session: SessionRecord): string {
|
function getWishlistOwner(session: SessionRecord): string {
|
||||||
return session.role === 'user' && session.userId ? session.userId : 'admin';
|
return session.role === 'user' && session.userId ? session.userId : 'admin';
|
||||||
}
|
}
|
||||||
@@ -817,14 +847,17 @@ async function serveApp(pathname: string, response: ServerResponse): Promise<voi
|
|||||||
try {
|
try {
|
||||||
const content = await readFile(filePath);
|
const content = await readFile(filePath);
|
||||||
response.writeHead(200, {
|
response.writeHead(200, {
|
||||||
'Content-Type': contentType(filePath)
|
'Content-Type': contentType(filePath),
|
||||||
|
// Hashed bundles never change; the entry page must always be revalidated so a new release reaches every browser.
|
||||||
|
'Cache-Control': relativePath.startsWith('/assets/') ? 'public, max-age=31536000, immutable' : 'no-cache'
|
||||||
});
|
});
|
||||||
response.end(content);
|
response.end(content);
|
||||||
} catch {
|
} catch {
|
||||||
try {
|
try {
|
||||||
const indexHtml = await readFile(resolve(process.cwd(), 'dist', 'index.html'));
|
const indexHtml = await readFile(resolve(process.cwd(), 'dist', 'index.html'));
|
||||||
response.writeHead(200, {
|
response.writeHead(200, {
|
||||||
'Content-Type': 'text/html; charset=utf-8'
|
'Content-Type': 'text/html; charset=utf-8',
|
||||||
|
'Cache-Control': 'no-cache'
|
||||||
});
|
});
|
||||||
response.end(indexHtml);
|
response.end(indexHtml);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
+124
-9
@@ -11,10 +11,12 @@ import type {
|
|||||||
EpisodeRequestPayload,
|
EpisodeRequestPayload,
|
||||||
EpisodeWatchStateRequest,
|
EpisodeWatchStateRequest,
|
||||||
HubPageResponse,
|
HubPageResponse,
|
||||||
|
HideableSection,
|
||||||
HubSection,
|
HubSection,
|
||||||
MediaCard,
|
MediaCard,
|
||||||
MovieDeletePayload,
|
MovieDeletePayload,
|
||||||
ProcessingItem,
|
ProcessingItem,
|
||||||
|
ProfileLibraryAccess,
|
||||||
SeasonDeletePayload,
|
SeasonDeletePayload,
|
||||||
SeasonRequestPayload,
|
SeasonRequestPayload,
|
||||||
SeriesEpisodeRequestPayload,
|
SeriesEpisodeRequestPayload,
|
||||||
@@ -26,6 +28,7 @@ import type {
|
|||||||
TitleDetailsSeason,
|
TitleDetailsSeason,
|
||||||
TitleDetailsCastMember
|
TitleDetailsCastMember
|
||||||
} from '../../shared/contracts.js';
|
} from '../../shared/contracts.js';
|
||||||
|
import { HIDEABLE_SECTIONS } from '../../shared/contracts.js';
|
||||||
|
|
||||||
const TMDB_IMAGE = 'https://image.tmdb.org/t/p';
|
const TMDB_IMAGE = 'https://image.tmdb.org/t/p';
|
||||||
const TMDB_ARTWORK_TTL_MS = 6 * 60 * 60 * 1000;
|
const TMDB_ARTWORK_TTL_MS = 6 * 60 * 60 * 1000;
|
||||||
@@ -190,6 +193,7 @@ interface SonarrCalendarRecord {
|
|||||||
series?: {
|
series?: {
|
||||||
title?: string;
|
title?: string;
|
||||||
tmdbId?: number;
|
tmdbId?: number;
|
||||||
|
path?: string;
|
||||||
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
||||||
year?: number;
|
year?: number;
|
||||||
status?: string;
|
status?: string;
|
||||||
@@ -240,6 +244,7 @@ interface RadarrCalendarRecord {
|
|||||||
digitalRelease?: string;
|
digitalRelease?: string;
|
||||||
monitored?: boolean;
|
monitored?: boolean;
|
||||||
hasFile?: boolean;
|
hasFile?: boolean;
|
||||||
|
path?: string;
|
||||||
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +376,24 @@ let tvdbTokenCache: { token: string; expiresAt: number } | null = null;
|
|||||||
const tmdbArtworkCache = new Map<string, { expiresAt: number; value: Promise<TmdbArtwork> }>();
|
const tmdbArtworkCache = new Map<string, { expiresAt: number; value: Promise<TmdbArtwork> }>();
|
||||||
const tvdbTranslationCache = new Map<string, { expiresAt: number; value: Promise<TvdbTranslationRecord | null> }>();
|
const tvdbTranslationCache = new Map<string, { expiresAt: number; value: Promise<TvdbTranslationRecord | null> }>();
|
||||||
|
|
||||||
|
const HIDEABLE_SECTION_IDS = new Set<string>(HIDEABLE_SECTIONS.map((section) => section.id));
|
||||||
|
|
||||||
|
function sanitizeHiddenSections(input: unknown): Record<string, HideableSection[]> {
|
||||||
|
const hidden: Record<string, HideableSection[]> = {};
|
||||||
|
if (!input || typeof input !== 'object') {
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
for (const [userId, sections] of Object.entries(input)) {
|
||||||
|
const valid = Array.isArray(sections)
|
||||||
|
? [...new Set(sections.map(String))].filter((section): section is HideableSection => HIDEABLE_SECTION_IDS.has(section))
|
||||||
|
: [];
|
||||||
|
if (userId && valid.length) {
|
||||||
|
hidden[userId] = valid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
|
||||||
export function sanitizeConfig(input: AppConfig): AppConfig {
|
export function sanitizeConfig(input: AppConfig): AppConfig {
|
||||||
return {
|
return {
|
||||||
preferences: {
|
preferences: {
|
||||||
@@ -383,7 +406,8 @@ export function sanitizeConfig(input: AppConfig): AppConfig {
|
|||||||
: [],
|
: [],
|
||||||
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
|
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
|
||||||
? input.preferences.radarrDownloadQualityProfileIds.map(String)
|
? input.preferences.radarrDownloadQualityProfileIds.map(String)
|
||||||
: []
|
: [],
|
||||||
|
hiddenSections: sanitizeHiddenSections(input.preferences.hiddenSections)
|
||||||
},
|
},
|
||||||
jellyfin: {
|
jellyfin: {
|
||||||
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
|
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
|
||||||
@@ -745,16 +769,22 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr
|
|||||||
getRadarrCalendar(config, start, end)
|
getRadarrCalendar(config, start, end)
|
||||||
])
|
])
|
||||||
|
|
||||||
const sonarrItems = sonarrResult.status === 'fulfilled'
|
|
||||||
? sonarrResult.value.map((item) => mapSonarrCalendarEntry(item))
|
|
||||||
: []
|
|
||||||
const radarrItems = radarrResult.status === 'fulfilled'
|
|
||||||
? radarrResult.value.map((item) => mapRadarrCalendarEntry(item))
|
|
||||||
: []
|
|
||||||
|
|
||||||
// Link each entry to its Jellyfin item, as search does, so the details can
|
// Link each entry to its Jellyfin item, as search does, so the details can
|
||||||
// tell which episodes are already in the library.
|
// tell which episodes are already in the library.
|
||||||
const library = await getLibrarySnapshot(config).catch(() => null);
|
const library = await getLibrarySnapshot(config).catch(() => null);
|
||||||
|
|
||||||
|
// A profile does not see releases that will be stored in a library it cannot open.
|
||||||
|
const hiddenFolders = await getHiddenLibraryFolders(config);
|
||||||
|
const sonarrItems = sonarrResult.status === 'fulfilled'
|
||||||
|
? sonarrResult.value
|
||||||
|
.filter((item) => !isInFolders(item.series?.path, hiddenFolders))
|
||||||
|
.map((item) => mapSonarrCalendarEntry(item))
|
||||||
|
: []
|
||||||
|
const radarrItems = radarrResult.status === 'fulfilled'
|
||||||
|
? radarrResult.value
|
||||||
|
.filter((item) => !isInFolders(item.path, hiddenFolders))
|
||||||
|
.map((item) => mapRadarrCalendarEntry(item))
|
||||||
|
: []
|
||||||
const libraryProviderIds = new Map<string, string>();
|
const libraryProviderIds = new Map<string, string>();
|
||||||
for (const libraryItem of library?.allItems ?? []) {
|
for (const libraryItem of library?.allItems ?? []) {
|
||||||
const libraryCard = jellyfinToCard(libraryItem, libraryItem.Name || 'Library');
|
const libraryCard = jellyfinToCard(libraryItem, libraryItem.Name || 'Library');
|
||||||
@@ -791,6 +821,88 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeLibraryId(id: string | undefined): string {
|
||||||
|
return String(id || '').replace(/-/g, '').toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFolderNames(locations: string[] | undefined): string[] {
|
||||||
|
return (locations ?? [])
|
||||||
|
.map((location) => location.replace(/\\/g, '/').split('/').filter(Boolean).pop()?.toLowerCase() ?? '')
|
||||||
|
.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sonarr and Radarr rarely see a folder under the same path as Jellyfin (they
|
||||||
|
// mount it differently), so a release is matched to a library by the folder
|
||||||
|
// name: a series stored in /shared/Library/Shows/X belongs to the library whose
|
||||||
|
// folder is called "Shows".
|
||||||
|
export function isInFolders(path: string | undefined, folderNames: string[] | null): boolean {
|
||||||
|
if (!path || !folderNames?.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// The last segment is the title's own folder, not a library.
|
||||||
|
const parents = path.replace(/\\/g, '/').split('/').filter(Boolean).slice(0, -1).map((segment) => segment.toLowerCase());
|
||||||
|
return parents.some((segment) => folderNames.includes(segment));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The folder names of the libraries the signed-in profile cannot open, read
|
||||||
|
// from Jellyfin (its libraries, and the ones in the profile's views). Admin
|
||||||
|
// sessions have no profile and see everything.
|
||||||
|
async function getHiddenLibraryFolders(config: AppConfig): Promise<string[] | null> {
|
||||||
|
if (!config.jellyfin.userId || !config.jellyfin.baseUrl || !config.jellyfin.apiKey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [folders, views] = await Promise.all([
|
||||||
|
jellyfinFetch<Array<{ ItemId?: string; Locations?: string[] }>>(config, '/Library/VirtualFolders'),
|
||||||
|
jellyfinFetch<JellyfinItem[]>(config, `/UserViews?userId=${encodeURIComponent(config.jellyfin.userId)}`)
|
||||||
|
]);
|
||||||
|
const visibleLibraryIds = new Set(views.map((view) => normalizeLibraryId(view.Id)));
|
||||||
|
const visibleNames = new Set(folders.filter((folder) => visibleLibraryIds.has(normalizeLibraryId(folder.ItemId))).flatMap((folder) => getFolderNames(folder.Locations)));
|
||||||
|
// A name shared with a library the profile can open stays visible.
|
||||||
|
const hidden = folders
|
||||||
|
.filter((folder) => folder.ItemId && !visibleLibraryIds.has(normalizeLibraryId(folder.ItemId)))
|
||||||
|
.flatMap((folder) => getFolderNames(folder.Locations))
|
||||||
|
.filter((name) => !visibleNames.has(name));
|
||||||
|
return hidden.length ? [...new Set(hidden)] : null;
|
||||||
|
} catch (error) {
|
||||||
|
// Better to show the calendar than to break it when Jellyfin cannot be asked.
|
||||||
|
console.warn('Could not read the profile libraries; the calendar is not filtered.', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// What Jellyfin lets each profile open, for the administrator to review; the
|
||||||
|
// permissions themselves are managed in Jellyfin.
|
||||||
|
export async function getProfileLibraryAccess(config: AppConfig): Promise<ProfileLibraryAccess[]> {
|
||||||
|
if (!config.jellyfin.baseUrl || !config.jellyfin.apiKey) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const [users, folders] = await Promise.all([
|
||||||
|
jellyfinFetch<Array<{ Id?: string; Name?: string; Policy?: { EnableAllFolders?: boolean; EnabledFolders?: string[] } }>>(config, '/Users'),
|
||||||
|
jellyfinFetch<Array<{ Name?: string; ItemId?: string }>>(config, '/Library/VirtualFolders')
|
||||||
|
]);
|
||||||
|
const libraries = folders.filter((folder) => folder.ItemId && folder.Name);
|
||||||
|
|
||||||
|
return users
|
||||||
|
.filter((user) => user.Id)
|
||||||
|
.map((user) => {
|
||||||
|
const allLibraries = user.Policy?.EnableAllFolders !== false;
|
||||||
|
const enabled = new Set((user.Policy?.EnabledFolders ?? []).map(normalizeLibraryId));
|
||||||
|
return {
|
||||||
|
userId: String(user.Id),
|
||||||
|
label: user.Name || 'User',
|
||||||
|
allLibraries,
|
||||||
|
libraries: libraries.map((folder) => ({
|
||||||
|
id: String(folder.ItemId),
|
||||||
|
name: String(folder.Name),
|
||||||
|
access: allLibraries || enabled.has(normalizeLibraryId(folder.ItemId))
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function searchTitles(
|
export async function searchTitles(
|
||||||
config: AppConfig,
|
config: AppConfig,
|
||||||
rawQuery: string
|
rawQuery: string
|
||||||
@@ -4153,7 +4265,10 @@ function jellyfinToCard(
|
|||||||
const backdropItemId = item.ParentBackdropItemId || item.Id;
|
const backdropItemId = item.ParentBackdropItemId || item.Id;
|
||||||
const backdropTag = item.ParentBackdropImageTags?.[0] || item.BackdropImageTags?.[0] || posterTag;
|
const backdropTag = item.ParentBackdropImageTags?.[0] || item.BackdropImageTags?.[0] || posterTag;
|
||||||
const progress = Math.round(item.UserData?.PlayedPercentage || 0);
|
const progress = Math.round(item.UserData?.PlayedPercentage || 0);
|
||||||
const tmdbId = Number(item.ProviderIds?.Tmdb) || (item.SeriesId ? tmdbIdByItemId?.get(item.SeriesId) : undefined);
|
// An episode's own TMDb id is not its series' id, and artwork is looked up per series.
|
||||||
|
const tmdbId = item.Type === 'Episode'
|
||||||
|
? (item.SeriesId ? tmdbIdByItemId?.get(item.SeriesId) : undefined)
|
||||||
|
: Number(item.ProviderIds?.Tmdb) || (item.SeriesId ? tmdbIdByItemId?.get(item.SeriesId) : undefined);
|
||||||
const episodeCode = formatEpisodeCode(item.ParentIndexNumber, item.IndexNumber);
|
const episodeCode = formatEpisodeCode(item.ParentIndexNumber, item.IndexNumber);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { spawn, type ChildProcess } from 'node:child_process';
|
||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import { mkdtemp, rm } from 'node:fs/promises';
|
||||||
|
import { createServer } from 'node:net';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { after, before, describe, it } from 'node:test';
|
||||||
|
import { defaultConfig, type CalendarResponse } from '../../shared/contracts.js';
|
||||||
|
import { startMockServices } from './mock-services.js';
|
||||||
|
|
||||||
|
// The real server, started on its own port and data folder, talking to the
|
||||||
|
// mock Jellyfin, Sonarr and Radarr. It signs in through the app's own login
|
||||||
|
// endpoints, so what a profile receives is what the browser would receive.
|
||||||
|
let mocks: Awaited<ReturnType<typeof startMockServices>>;
|
||||||
|
let server: ChildProcess;
|
||||||
|
let dataDir = '';
|
||||||
|
let baseUrl = '';
|
||||||
|
let adminCookie = '';
|
||||||
|
|
||||||
|
async function freePort(): Promise<number> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const probe = createServer().listen(0, '127.0.0.1', () => {
|
||||||
|
const { port } = probe.address() as { port: number };
|
||||||
|
probe.close(() => resolve(port));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function call(path: string, options: { method?: string; cookie?: string; body?: unknown } = {}) {
|
||||||
|
const response = await fetch(`${baseUrl}${path}`, {
|
||||||
|
method: options.method ?? 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...(options.cookie ? { Cookie: options.cookie } : {})
|
||||||
|
},
|
||||||
|
body: options.body === undefined ? undefined : JSON.stringify(options.body)
|
||||||
|
});
|
||||||
|
const cookie = response.headers.get('set-cookie')?.split(';')[0] ?? '';
|
||||||
|
const text = await response.text();
|
||||||
|
return { status: response.status, cookie, json: text ? JSON.parse(text) : null };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function signInAs(userId: string): Promise<string> {
|
||||||
|
const result = await call('/api/auth/profile-login', { method: 'POST', body: { userId, password: 'any-password' } });
|
||||||
|
assert.equal(result.status, 200);
|
||||||
|
return result.cookie;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function calendarTitles(cookie: string): Promise<string[]> {
|
||||||
|
const result = await call('/api/calendar?start=2026-11-01&end=2026-11-30', { cookie });
|
||||||
|
assert.equal(result.status, 200);
|
||||||
|
return (result.json as CalendarResponse).items.map((item) => item.title).sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
mocks = await startMockServices();
|
||||||
|
dataDir = await mkdtemp(join(tmpdir(), 'omniarr-e2e-'));
|
||||||
|
const port = await freePort();
|
||||||
|
baseUrl = `http://127.0.0.1:${port}`;
|
||||||
|
server = spawn(process.execPath, ['dist-server/server/index.js'], {
|
||||||
|
env: { ...process.env, PORT: String(port), OMNIARR_DATA_DIR: dataDir },
|
||||||
|
stdio: 'ignore'
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let attempt = 0; attempt < 50; attempt += 1) {
|
||||||
|
const ready = await fetch(`${baseUrl}/api/health`).then((response) => response.ok).catch(() => false);
|
||||||
|
if (ready) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
// A throwaway master password for this throwaway data folder.
|
||||||
|
const registered = await call('/api/auth/register', { method: 'POST', body: { password: randomUUID() } });
|
||||||
|
assert.equal(registered.status, 200);
|
||||||
|
adminCookie = registered.cookie;
|
||||||
|
|
||||||
|
const saved = await call('/api/settings', {
|
||||||
|
method: 'PUT',
|
||||||
|
cookie: adminCookie,
|
||||||
|
body: {
|
||||||
|
...defaultConfig,
|
||||||
|
preferences: { ...defaultConfig.preferences, hiddenSections: { limited: ['downloads', 'anime'] } },
|
||||||
|
jellyfin: { baseUrl: mocks.jellyfinUrl, apiKey: 'key', userId: '' },
|
||||||
|
sonarr: { ...defaultConfig.sonarr, baseUrl: mocks.sonarrUrl, apiKey: 'key' },
|
||||||
|
radarr: { ...defaultConfig.radarr, baseUrl: mocks.radarrUrl, apiKey: 'key' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assert.equal(saved.status, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
server?.kill();
|
||||||
|
await mocks?.close();
|
||||||
|
if (dataDir) {
|
||||||
|
await rm(dataDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('upcoming calendar through the API', () => {
|
||||||
|
it('gives the administrator every release', async () => {
|
||||||
|
assert.deepEqual(await calendarTitles(adminCookie), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('gives a profile with every library every release', async () => {
|
||||||
|
assert.deepEqual(await calendarTitles(await signInAs('full')), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps releases of libraries a profile cannot open out of its calendar', async () => {
|
||||||
|
assert.deepEqual(await calendarTitles(await signInAs('limited')), ['Anime', 'Better Call Saul', 'Dune']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('sections hidden for a profile', () => {
|
||||||
|
it('closes the hidden sections for that profile only', async () => {
|
||||||
|
const limited = await signInAs('limited');
|
||||||
|
const full = await signInAs('full');
|
||||||
|
assert.equal((await call('/api/downloads', { cookie: limited })).status, 403);
|
||||||
|
assert.equal((await call('/api/hubs/anime', { cookie: limited })).status, 403);
|
||||||
|
assert.notEqual((await call('/api/downloads', { cookie: full })).status, 403);
|
||||||
|
assert.notEqual((await call('/api/downloads', { cookie: adminCookie })).status, 403);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets only the administrator read the library access and change settings', async () => {
|
||||||
|
const limited = await signInAs('limited');
|
||||||
|
assert.equal((await call('/api/admin/profile-access', { cookie: limited })).status, 403);
|
||||||
|
assert.equal((await call('/api/settings', { method: 'PUT', cookie: limited, body: defaultConfig })).status, 403);
|
||||||
|
|
||||||
|
const access = await call('/api/admin/profile-access', { cookie: adminCookie });
|
||||||
|
assert.equal(access.status, 200);
|
||||||
|
assert.deepEqual(
|
||||||
|
(access.json as { profiles: Array<{ userId: string; libraries: Array<{ name: string; access: boolean }> }> })
|
||||||
|
.profiles.find((profile) => profile.userId === 'limited')?.libraries.filter((library) => library.access).map((library) => library.name),
|
||||||
|
['Shows', 'Movies']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { after, before, describe, it } from 'node:test';
|
||||||
|
import { defaultConfig, type AppConfig } from '../../shared/contracts.js';
|
||||||
|
import { getCalendar, getProfileLibraryAccess, isInFolders } from '../lib/services.js';
|
||||||
|
import { startMockServices } from './mock-services.js';
|
||||||
|
|
||||||
|
let mocks: Awaited<ReturnType<typeof startMockServices>>;
|
||||||
|
|
||||||
|
function configFor(userId: string): AppConfig {
|
||||||
|
return {
|
||||||
|
...defaultConfig,
|
||||||
|
jellyfin: { baseUrl: mocks.jellyfinUrl, apiKey: 'key', userId },
|
||||||
|
sonarr: { ...defaultConfig.sonarr, baseUrl: mocks.sonarrUrl, apiKey: 'key' },
|
||||||
|
radarr: { ...defaultConfig.radarr, baseUrl: mocks.radarrUrl, apiKey: 'key' }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function calendarTitles(config: AppConfig): Promise<string[]> {
|
||||||
|
const calendar = await getCalendar(config, new Date('2026-11-01'), new Date('2026-11-30'));
|
||||||
|
return calendar.items.map((item) => item.title).sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
mocks = await startMockServices();
|
||||||
|
});
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
await mocks.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('upcoming calendar per profile', () => {
|
||||||
|
it('shows everything to the administrator, who has no Jellyfin profile', async () => {
|
||||||
|
assert.deepEqual(await calendarTitles(configFor('')), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows everything to a profile that opens every library', async () => {
|
||||||
|
assert.deepEqual(await calendarTitles(configFor('full')), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('leaves out releases stored in libraries the profile cannot open', async () => {
|
||||||
|
assert.deepEqual(await calendarTitles(configFor('limited')), ['Anime', 'Better Call Saul', 'Dune']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not calendar-filter when Jellyfin cannot be asked', async () => {
|
||||||
|
const config = configFor('limited');
|
||||||
|
config.jellyfin.baseUrl = 'http://127.0.0.1:9';
|
||||||
|
assert.deepEqual(await calendarTitles(config), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('library folder matching', () => {
|
||||||
|
it('matches a title by the library folder it is stored in', () => {
|
||||||
|
assert.equal(isInFolders('/shared/Library/Anime/Frieren', ['anime']), true);
|
||||||
|
assert.equal(isInFolders('/shared/library/ANIME/Frieren', ['anime']), true);
|
||||||
|
assert.equal(isInFolders('/shared/Library/Shows/Frieren', ['anime']), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores the title\'s own folder and handles missing data', () => {
|
||||||
|
assert.equal(isInFolders('/shared/Library/Shows/Anime', ['anime']), false);
|
||||||
|
assert.equal(isInFolders(undefined, ['anime']), false);
|
||||||
|
assert.equal(isInFolders('/shared/Library/Anime/Frieren', null), false);
|
||||||
|
assert.equal(isInFolders('C:\\Media\\Anime\\Frieren', ['anime']), true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('profile library access', () => {
|
||||||
|
it('reports which libraries each Jellyfin profile can open', async () => {
|
||||||
|
const profiles = await getProfileLibraryAccess(configFor(''));
|
||||||
|
const full = profiles.find((profile) => profile.userId === 'full');
|
||||||
|
const limited = profiles.find((profile) => profile.userId === 'limited');
|
||||||
|
assert.equal(full?.allLibraries, true);
|
||||||
|
assert.ok(full?.libraries.every((library) => library.access));
|
||||||
|
assert.equal(limited?.allLibraries, false);
|
||||||
|
assert.deepEqual(
|
||||||
|
limited?.libraries.filter((library) => library.access).map((library) => library.name),
|
||||||
|
['Shows', 'Movies']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import { createServer, type Server } from 'node:http';
|
||||||
|
import type { AddressInfo } from 'node:net';
|
||||||
|
|
||||||
|
// Stand-ins for Jellyfin, Sonarr and Radarr with two profiles: "full" opens
|
||||||
|
// every library and "limited" cannot open Anime or Anime Movies. Sonarr and
|
||||||
|
// Radarr see the media under /shared/Library while Jellyfin sees /library, the
|
||||||
|
// way the Docker mounts differ in a real setup.
|
||||||
|
export const MOCK_LIBRARIES = [
|
||||||
|
{ Name: 'Shows', ItemId: 'aaaaaaaa-0000-0000-0000-000000000001', Locations: ['/library/Shows'] },
|
||||||
|
{ Name: 'Movies', ItemId: 'aaaaaaaa-0000-0000-0000-000000000002', Locations: ['/library/Movies'] },
|
||||||
|
{ Name: 'Anime', ItemId: 'aaaaaaaa-0000-0000-0000-000000000003', Locations: ['/library/Anime'] },
|
||||||
|
{ Name: 'Anime Movies', ItemId: 'aaaaaaaa-0000-0000-0000-000000000004', Locations: ['/library/AnimeMovies'] }
|
||||||
|
];
|
||||||
|
|
||||||
|
export const MOCK_USERS = [
|
||||||
|
{ Id: 'full', Name: 'Full', Policy: { EnableAllFolders: true, EnabledFolders: [] } },
|
||||||
|
{
|
||||||
|
Id: 'limited',
|
||||||
|
Name: 'Limited',
|
||||||
|
Policy: { EnableAllFolders: false, EnabledFolders: [MOCK_LIBRARIES[0].ItemId, MOCK_LIBRARIES[1].ItemId] }
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const AIR_DATE = '2026-11-20T20:00:00Z';
|
||||||
|
|
||||||
|
const SONARR_CALENDAR = [
|
||||||
|
{ id: 1, title: 'Pilot', airDateUtc: AIR_DATE, seasonNumber: 1, episodeNumber: 1, series: { title: 'Better Call Saul', tmdbId: 60059, path: '/shared/Library/Shows/Better Call Saul' } },
|
||||||
|
{ id: 2, title: 'Chapter 1', airDateUtc: AIR_DATE, seasonNumber: 1, episodeNumber: 1, series: { title: 'Frieren', tmdbId: 209867, path: '/shared/Library/Anime/Frieren' } },
|
||||||
|
// A series folder that happens to be called like a library is still a Shows title.
|
||||||
|
{ id: 3, title: 'Episode 1', airDateUtc: AIR_DATE, seasonNumber: 1, episodeNumber: 1, series: { title: 'Anime', tmdbId: 1, path: '/shared/Library/Shows/Anime' } }
|
||||||
|
];
|
||||||
|
|
||||||
|
const RADARR_CALENDAR = [
|
||||||
|
{ id: 10, title: 'Dune', tmdbId: 438631, digitalRelease: AIR_DATE, path: '/shared/Library/Movies/Dune' },
|
||||||
|
{ id: 11, title: 'Your Name', tmdbId: 372058, digitalRelease: AIR_DATE, path: '/shared/Library/AnimeMovies/Your Name' }
|
||||||
|
];
|
||||||
|
|
||||||
|
function listen(server: Server): Promise<string> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
server.listen(0, '127.0.0.1', () => resolve(`http://127.0.0.1:${(server.address() as AddressInfo).port}`));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsonServer(handler: (path: string, query: URLSearchParams, body: string) => unknown): Server {
|
||||||
|
return createServer((request, response) => {
|
||||||
|
const url = new URL(request.url || '/', 'http://localhost');
|
||||||
|
const chunks: Buffer[] = [];
|
||||||
|
request.on('data', (chunk: Buffer) => chunks.push(chunk));
|
||||||
|
request.on('end', () => {
|
||||||
|
response.writeHead(200, { 'Content-Type': 'application/json' });
|
||||||
|
response.end(JSON.stringify(handler(url.pathname, url.searchParams, Buffer.concat(chunks).toString('utf8'))));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function startMockServices() {
|
||||||
|
const jellyfin = jsonServer((path, query, body) => {
|
||||||
|
// Any password signs a profile in, so the app's own login can be exercised.
|
||||||
|
if (path === '/Users/AuthenticateByName') {
|
||||||
|
const username = (JSON.parse(body || '{}') as { Username?: string }).Username;
|
||||||
|
return { User: { Id: MOCK_USERS.find((user) => user.Name === username)?.Id } };
|
||||||
|
}
|
||||||
|
if (path === '/Library/VirtualFolders') {
|
||||||
|
return MOCK_LIBRARIES;
|
||||||
|
}
|
||||||
|
if (path === '/Users') {
|
||||||
|
return MOCK_USERS;
|
||||||
|
}
|
||||||
|
if (path === '/UserViews') {
|
||||||
|
const user = MOCK_USERS.find((candidate) => candidate.Id === query.get('userId'));
|
||||||
|
const visible = MOCK_LIBRARIES.filter((library) => user?.Policy.EnableAllFolders || user?.Policy.EnabledFolders.includes(library.ItemId));
|
||||||
|
return { Items: visible.map((library) => ({ Id: library.ItemId.replace(/-/g, ''), Name: library.Name })) };
|
||||||
|
}
|
||||||
|
return { Items: [] };
|
||||||
|
});
|
||||||
|
const sonarr = jsonServer(() => SONARR_CALENDAR);
|
||||||
|
const radarr = jsonServer(() => RADARR_CALENDAR);
|
||||||
|
const [jellyfinUrl, sonarrUrl, radarrUrl] = await Promise.all([listen(jellyfin), listen(sonarr), listen(radarr)]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
jellyfinUrl,
|
||||||
|
sonarrUrl,
|
||||||
|
radarrUrl,
|
||||||
|
close: () => Promise.all([jellyfin, sonarr, radarr].map((server) => new Promise((resolve) => server.close(resolve))))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// `node dist-server/server/test/mock-services.js` keeps the mocks running so the
|
||||||
|
// app can be pointed at them (Jellyfin API key and Sonarr/Radarr keys: anything).
|
||||||
|
const isMain = process.argv[1] !== undefined && import.meta.url.endsWith(process.argv[1].split('/').slice(-3).join('/'));
|
||||||
|
if (isMain) {
|
||||||
|
const mocks = await startMockServices();
|
||||||
|
console.log(`Jellyfin ${mocks.jellyfinUrl}\nSonarr ${mocks.sonarrUrl}\nRadarr ${mocks.radarrUrl}`);
|
||||||
|
console.log('Profiles: "full" opens every library, "limited" cannot open Anime or Anime Movies.');
|
||||||
|
}
|
||||||
+30
-1
@@ -15,6 +15,24 @@ export type AppRoute =
|
|||||||
| 'wishlist'
|
| 'wishlist'
|
||||||
| 'settings';
|
| 'settings';
|
||||||
|
|
||||||
|
// Sections of the app the administrator can switch off for a profile.
|
||||||
|
export const HIDEABLE_SECTIONS = [
|
||||||
|
{ id: 'search', label: 'Search' },
|
||||||
|
{ id: 'calendar', label: 'Upcoming' },
|
||||||
|
{ id: 'downloads', label: 'Downloads' },
|
||||||
|
{ id: 'wishlist', label: 'Wishlist' },
|
||||||
|
{ id: 'dorama', label: 'K-Drama' },
|
||||||
|
{ id: 'anime', label: 'Anime' },
|
||||||
|
{ id: 'library', label: 'Library' },
|
||||||
|
{ id: 'netflix', label: 'Netflix' },
|
||||||
|
{ id: 'primevideo', label: 'Prime Video' },
|
||||||
|
{ id: 'hbo', label: 'HBO' },
|
||||||
|
{ id: 'viki', label: 'Viki' },
|
||||||
|
{ id: 'disney', label: 'Disney+' }
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export type HideableSection = (typeof HIDEABLE_SECTIONS)[number]['id'];
|
||||||
|
|
||||||
export interface ServiceConfig {
|
export interface ServiceConfig {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
}
|
}
|
||||||
@@ -56,6 +74,16 @@ export interface AppPreferences {
|
|||||||
animationLevel: 'smooth' | 'reduced';
|
animationLevel: 'smooth' | 'reduced';
|
||||||
sonarrDownloadQualityProfileIds: string[];
|
sonarrDownloadQualityProfileIds: string[];
|
||||||
radarrDownloadQualityProfileIds: string[];
|
radarrDownloadQualityProfileIds: string[];
|
||||||
|
/** Sections switched off for each Jellyfin profile, by user id; a profile that is not listed sees everything. */
|
||||||
|
hiddenSections: Record<string, HideableSection[]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProfileLibraryAccess {
|
||||||
|
userId: string;
|
||||||
|
label: string;
|
||||||
|
/** Jellyfin lets this profile open every library, including ones added later. */
|
||||||
|
allLibraries: boolean;
|
||||||
|
libraries: Array<{ id: string; name: string; access: boolean }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppConfig {
|
export interface AppConfig {
|
||||||
@@ -391,7 +419,8 @@ export const defaultConfig: AppConfig = {
|
|||||||
excludeLibraryItems: true,
|
excludeLibraryItems: true,
|
||||||
animationLevel: 'smooth',
|
animationLevel: 'smooth',
|
||||||
sonarrDownloadQualityProfileIds: [],
|
sonarrDownloadQualityProfileIds: [],
|
||||||
radarrDownloadQualityProfileIds: []
|
radarrDownloadQualityProfileIds: [],
|
||||||
|
hiddenSections: {}
|
||||||
},
|
},
|
||||||
jellyfin: {
|
jellyfin: {
|
||||||
baseUrl: '',
|
baseUrl: '',
|
||||||
|
|||||||
+350
-32
@@ -12,6 +12,7 @@ import {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
import { createPortal } from 'react-dom'
|
||||||
import { api } from './api'
|
import { api } from './api'
|
||||||
import {
|
import {
|
||||||
type CalendarEntry,
|
type CalendarEntry,
|
||||||
@@ -22,9 +23,11 @@ import {
|
|||||||
type CompletedDownloadItem,
|
type CompletedDownloadItem,
|
||||||
type DownloadItem,
|
type DownloadItem,
|
||||||
type DiskSpaceStatus,
|
type DiskSpaceStatus,
|
||||||
|
type HideableSection,
|
||||||
type HubPageResponse,
|
type HubPageResponse,
|
||||||
type MediaCard,
|
type MediaCard,
|
||||||
type ProcessingItem,
|
type ProcessingItem,
|
||||||
|
type ProfileLibraryAccess,
|
||||||
type SearchResponse,
|
type SearchResponse,
|
||||||
type SelectOption,
|
type SelectOption,
|
||||||
type ServiceOptionsResponse,
|
type ServiceOptionsResponse,
|
||||||
@@ -33,6 +36,7 @@ import {
|
|||||||
type TitleDetailsResponse,
|
type TitleDetailsResponse,
|
||||||
type WishlistEntry,
|
type WishlistEntry,
|
||||||
} from '../shared/contracts'
|
} from '../shared/contracts'
|
||||||
|
import { HIDEABLE_SECTIONS } from '../shared/contracts'
|
||||||
|
|
||||||
type AuthState = 'loading' | 'setup' | 'login' | 'profiles' | 'admin' | 'app'
|
type AuthState = 'loading' | 'setup' | 'login' | 'profiles' | 'admin' | 'app'
|
||||||
type EntryStage = 'onboarding' | 'profiles' | 'dashboard'
|
type EntryStage = 'onboarding' | 'profiles' | 'dashboard'
|
||||||
@@ -54,8 +58,23 @@ const topSidebarItems: SidebarItem[] = [
|
|||||||
{ route: 'wishlist', label: 'Wishlist', short: 'W', icon: 'wishlist' },
|
{ route: 'wishlist', label: 'Wishlist', short: 'W', icon: 'wishlist' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// Only English is translated today; more can be added here and show up in Settings.
|
||||||
|
const LANGUAGE_OPTIONS: SelectOption[] = [{ id: 'en-US', label: 'English (en-US)' }]
|
||||||
|
|
||||||
|
const REGION_CODES = [
|
||||||
|
'US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'ES', 'MX', 'AR', 'CL', 'CO', 'PE', 'FR', 'DE', 'IT', 'PT', 'BR',
|
||||||
|
'NL', 'BE', 'SE', 'NO', 'DK', 'FI', 'PL', 'JP', 'KR', 'CN', 'TW', 'IN',
|
||||||
|
]
|
||||||
|
const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
|
||||||
|
const REGION_OPTIONS: SelectOption[] = REGION_CODES.map((code) => ({ id: code, label: `${regionNames.of(code) ?? code} (${code})` }))
|
||||||
|
|
||||||
|
// A value saved earlier that is not in the list stays selectable instead of being lost.
|
||||||
|
function withCurrentOption(options: SelectOption[], current: string): SelectOption[] {
|
||||||
|
return current && !options.some((option) => option.id === current) ? [{ id: current, label: current }, ...options] : options
|
||||||
|
}
|
||||||
|
|
||||||
const sidebarItems: SidebarItem[] = [
|
const sidebarItems: SidebarItem[] = [
|
||||||
{ route: 'home', label: 'Inicio', short: 'H', icon: 'home' },
|
{ route: 'home', label: 'Home', short: 'H', icon: 'home' },
|
||||||
{ route: 'dorama', label: 'K-Drama', short: '아' },
|
{ route: 'dorama', label: 'K-Drama', short: '아' },
|
||||||
{ route: 'anime', label: 'Anime', short: 'あ' },
|
{ route: 'anime', label: 'Anime', short: 'あ' },
|
||||||
{ route: 'library', label: 'Library', short: 'L', icon: 'library' },
|
{ route: 'library', label: 'Library', short: 'L', icon: 'library' },
|
||||||
@@ -101,6 +120,10 @@ function App() {
|
|||||||
const [notice, setNotice] = useState('')
|
const [notice, setNotice] = useState('')
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
const [config, setConfig] = useState<AppConfig>(defaultConfig)
|
const [config, setConfig] = useState<AppConfig>(defaultConfig)
|
||||||
|
// What the server has, to tell when the settings on screen have unsaved changes.
|
||||||
|
const savedConfigJson = useRef(JSON.stringify(defaultConfig))
|
||||||
|
const configRef = useRef(config)
|
||||||
|
configRef.current = config
|
||||||
const [options, setOptions] = useState<ServiceOptionsResponse>({
|
const [options, setOptions] = useState<ServiceOptionsResponse>({
|
||||||
jellyfinUsers: [],
|
jellyfinUsers: [],
|
||||||
sonarrRootFolders: [],
|
sonarrRootFolders: [],
|
||||||
@@ -125,6 +148,10 @@ function App() {
|
|||||||
const [downloadDeleteId, setDownloadDeleteId] = useState('')
|
const [downloadDeleteId, setDownloadDeleteId] = useState('')
|
||||||
const [wishlist, setWishlist] = useState<WishlistEntry[]>([])
|
const [wishlist, setWishlist] = useState<WishlistEntry[]>([])
|
||||||
const [entryTransitionState, setEntryTransitionState] = useState<EntryTransitionState>('idle')
|
const [entryTransitionState, setEntryTransitionState] = useState<EntryTransitionState>('idle')
|
||||||
|
// The administrator can switch sections off for each profile; admin sessions see them all.
|
||||||
|
const hiddenSections: string[] = sessionRole === 'user' ? (config.preferences.hiddenSections[config.jellyfin.userId] ?? []) : []
|
||||||
|
const isSectionHidden = (sectionRoute: AppRoute) => hiddenSections.includes(sectionRoute)
|
||||||
|
const routeHidden = isSectionHidden(route)
|
||||||
|
|
||||||
async function transitionEntryStage(nextStage: EntryStage) {
|
async function transitionEntryStage(nextStage: EntryStage) {
|
||||||
if (nextStage === entryStage) {
|
if (nextStage === entryStage) {
|
||||||
@@ -148,6 +175,11 @@ function App() {
|
|||||||
setEntryTransitionState('idle')
|
setEntryTransitionState('idle')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyServerConfig(next: AppConfig) {
|
||||||
|
savedConfigJson.current = JSON.stringify(next)
|
||||||
|
setConfig(next)
|
||||||
|
}
|
||||||
|
|
||||||
async function refreshBaseData() {
|
async function refreshBaseData() {
|
||||||
const [settings, serviceOptions, dashboard, storage, savedWishlist] = await Promise.all([
|
const [settings, serviceOptions, dashboard, storage, savedWishlist] = await Promise.all([
|
||||||
api.getSettings(),
|
api.getSettings(),
|
||||||
@@ -158,7 +190,10 @@ function App() {
|
|||||||
])
|
])
|
||||||
|
|
||||||
setWishlist(savedWishlist.items)
|
setWishlist(savedWishlist.items)
|
||||||
setConfig(settings)
|
// Edits that are not saved yet are not replaced by the periodic refresh.
|
||||||
|
if (JSON.stringify(configRef.current) === savedConfigJson.current) {
|
||||||
|
applyServerConfig(settings)
|
||||||
|
}
|
||||||
setOptions(serviceOptions)
|
setOptions(serviceOptions)
|
||||||
setDownloads(dashboard.downloads)
|
setDownloads(dashboard.downloads)
|
||||||
setProcessingItems(dashboard.processing || [])
|
setProcessingItems(dashboard.processing || [])
|
||||||
@@ -237,6 +272,11 @@ function App() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (routeHidden) {
|
||||||
|
setRoute('home')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (route === 'settings' || route === 'calendar' || route === 'search' || route === 'wishlist') {
|
if (route === 'settings' || route === 'calendar' || route === 'search' || route === 'wishlist') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -270,7 +310,7 @@ function App() {
|
|||||||
return () => {
|
return () => {
|
||||||
cancelled = true
|
cancelled = true
|
||||||
}
|
}
|
||||||
}, [authState, entryStage, route])
|
}, [authState, entryStage, route, routeHidden])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -346,7 +386,7 @@ function App() {
|
|||||||
// connection stays configured after this screen.
|
// connection stays configured after this screen.
|
||||||
if (sessionRole === 'admin') {
|
if (sessionRole === 'admin') {
|
||||||
const saved = await api.saveSettings(config)
|
const saved = await api.saveSettings(config)
|
||||||
setConfig(saved.config)
|
applyServerConfig(saved.config)
|
||||||
setConnections(saved.connections)
|
setConnections(saved.connections)
|
||||||
}
|
}
|
||||||
await transitionEntryStage(response.jellyfinUsers.length ? 'profiles' : 'onboarding')
|
await transitionEntryStage(response.jellyfinUsers.length ? 'profiles' : 'onboarding')
|
||||||
@@ -387,7 +427,7 @@ function App() {
|
|||||||
setNotice('')
|
setNotice('')
|
||||||
try {
|
try {
|
||||||
const response = await api.saveSettings(config)
|
const response = await api.saveSettings(config)
|
||||||
setConfig(response.config)
|
applyServerConfig(response.config)
|
||||||
setConnections(response.connections)
|
setConnections(response.connections)
|
||||||
await refreshBaseData()
|
await refreshBaseData()
|
||||||
setNotice('Settings saved and services refreshed.')
|
setNotice('Settings saved and services refreshed.')
|
||||||
@@ -505,7 +545,7 @@ function App() {
|
|||||||
throw new Error('This file is not an OmniArr backup.')
|
throw new Error('This file is not an OmniArr backup.')
|
||||||
}
|
}
|
||||||
const response = await api.importBackup(backup)
|
const response = await api.importBackup(backup)
|
||||||
setConfig(response.config)
|
applyServerConfig(response.config)
|
||||||
setConnections(response.connections)
|
setConnections(response.connections)
|
||||||
await refreshBaseData()
|
await refreshBaseData()
|
||||||
setNotice('Backup restored.')
|
setNotice('Backup restored.')
|
||||||
@@ -608,6 +648,7 @@ function App() {
|
|||||||
<AdministrationScreen
|
<AdministrationScreen
|
||||||
busy={busy}
|
busy={busy}
|
||||||
config={config}
|
config={config}
|
||||||
|
savedConfig={JSON.parse(savedConfigJson.current) as AppConfig}
|
||||||
connections={connections}
|
connections={connections}
|
||||||
error={error}
|
error={error}
|
||||||
notice={notice}
|
notice={notice}
|
||||||
@@ -666,10 +707,11 @@ function App() {
|
|||||||
const currentHub = isHubRoute(route) ? hubPages[route as HubPageResponse['page']] : undefined
|
const currentHub = isHubRoute(route) ? hubPages[route as HubPageResponse['page']] : undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WishlistContext.Provider value={wishlistContext}>
|
<WishlistContext.Provider value={isSectionHidden('wishlist') ? null : wishlistContext}>
|
||||||
<div className={`omniarr-app ${getEntryTransitionClassName(entryTransitionState)}`}>
|
<div className={`omniarr-app ${getEntryTransitionClassName(entryTransitionState)}`}>
|
||||||
<Sidebar
|
<Sidebar
|
||||||
busy={busy}
|
busy={busy}
|
||||||
|
isSectionHidden={isSectionHidden}
|
||||||
connections={connections}
|
connections={connections}
|
||||||
currentUser={currentJellyfinUser}
|
currentUser={currentJellyfinUser}
|
||||||
diskSpace={diskSpace}
|
diskSpace={diskSpace}
|
||||||
@@ -693,7 +735,7 @@ function App() {
|
|||||||
title="Nothing to track yet"
|
title="Nothing to track yet"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{route === 'calendar' && isRouteAvailable(route, connections) ? <CalendarPage onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} /> : null}
|
{route === 'calendar' && !routeHidden && isRouteAvailable(route, connections) ? <CalendarPage onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} /> : null}
|
||||||
{route === 'downloads' && isRouteAvailable(route, connections) ? <DownloadsPage busyId={downloadDeleteId} completedDownloads={completedDownloads} downloads={downloads} onDelete={handleDeleteDownload} onDismissAllCompleted={handleDismissAllCompleted} onDismissCompleted={handleDismissCompleted} onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} processingItems={processingItems} /> : null}
|
{route === 'downloads' && isRouteAvailable(route, connections) ? <DownloadsPage busyId={downloadDeleteId} completedDownloads={completedDownloads} downloads={downloads} onDelete={handleDeleteDownload} onDismissAllCompleted={handleDismissAllCompleted} onDismissCompleted={handleDismissCompleted} onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} processingItems={processingItems} /> : null}
|
||||||
{route === 'search' ? (
|
{route === 'search' ? (
|
||||||
<SearchPage
|
<SearchPage
|
||||||
@@ -710,6 +752,7 @@ function App() {
|
|||||||
<SettingsView
|
<SettingsView
|
||||||
busy={busy}
|
busy={busy}
|
||||||
config={config}
|
config={config}
|
||||||
|
savedConfig={JSON.parse(savedConfigJson.current) as AppConfig}
|
||||||
connections={connections}
|
connections={connections}
|
||||||
onCheck={saveSettings}
|
onCheck={saveSettings}
|
||||||
onExportBackup={handleExportBackup}
|
onExportBackup={handleExportBackup}
|
||||||
@@ -775,6 +818,7 @@ function Sidebar(props: {
|
|||||||
connections: ConnectionStatus[]
|
connections: ConnectionStatus[]
|
||||||
busy: boolean
|
busy: boolean
|
||||||
canManage: boolean
|
canManage: boolean
|
||||||
|
isSectionHidden: (route: AppRoute) => boolean
|
||||||
onExitProfile: () => void
|
onExitProfile: () => void
|
||||||
}) {
|
}) {
|
||||||
const [menuOpen, setMenuOpen] = useState(false)
|
const [menuOpen, setMenuOpen] = useState(false)
|
||||||
@@ -835,7 +879,7 @@ function Sidebar(props: {
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div className="sidebar-links">
|
<div className="sidebar-links">
|
||||||
{topSidebarItems.filter((item) => isRouteAvailable(item.route, props.connections)).map((item) => (
|
{topSidebarItems.filter((item) => isRouteAvailable(item.route, props.connections) && !props.isSectionHidden(item.route)).map((item) => (
|
||||||
<button
|
<button
|
||||||
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
||||||
key={item.route}
|
key={item.route}
|
||||||
@@ -851,7 +895,7 @@ function Sidebar(props: {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="sidebar-links">
|
<div className="sidebar-links">
|
||||||
{sidebarItems.map((item) => (
|
{sidebarItems.filter((item) => !props.isSectionHidden(item.route)).map((item) => (
|
||||||
<button
|
<button
|
||||||
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
||||||
key={item.route}
|
key={item.route}
|
||||||
@@ -867,7 +911,7 @@ function Sidebar(props: {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="sidebar-links">
|
<div className="sidebar-links">
|
||||||
{networkSidebarItems.map((item) => (
|
{networkSidebarItems.filter((item) => !props.isSectionHidden(item.route)).map((item) => (
|
||||||
<button
|
<button
|
||||||
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
||||||
key={item.route}
|
key={item.route}
|
||||||
@@ -1786,7 +1830,7 @@ function MediaTile(props: {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{props.card.hoverLabel && !continueEpisodeMeta ? <div className="media-hover-label">{props.card.hoverLabel}</div> : null}
|
{props.card.hoverLabel && !continueEpisodeMeta ? <div className="media-hover-label">{props.card.hoverLabel}</div> : null}
|
||||||
{props.card.progress ? <div className="tile-progress"><div className="tile-progress-fill" style={{ width: `${props.card.progress}%` }} /></div> : null}
|
{props.isContinueWatching && props.card.progress ? <div className="tile-progress"><div className="tile-progress-fill" style={{ width: `${props.card.progress}%` }} /></div> : null}
|
||||||
</button>
|
</button>
|
||||||
{!props.isContinueWatching && (props.styleType === 'landscape' || props.styleType === 'poster') ? <WishlistHeart card={props.card} className="media-wishlist-button" /> : null}
|
{!props.isContinueWatching && (props.styleType === 'landscape' || props.styleType === 'poster') ? <WishlistHeart card={props.card} className="media-wishlist-button" /> : null}
|
||||||
</article>
|
</article>
|
||||||
@@ -2108,6 +2152,26 @@ function TitleDetailsModal(props: {
|
|||||||
const backgroundImage = details?.backdropUrl || props.card.backdropUrl || props.card.posterUrl
|
const backgroundImage = details?.backdropUrl || props.card.backdropUrl || props.card.posterUrl
|
||||||
const logoUrl = details?.logoUrl || props.card.logoUrl
|
const logoUrl = details?.logoUrl || props.card.logoUrl
|
||||||
const displayTitle = details?.title || props.card.title
|
const displayTitle = details?.title || props.card.title
|
||||||
|
// Titles opened from Continue Watching arrive as a Jellyfin episode card, which
|
||||||
|
// cannot be wishlisted; the series the details resolved to can.
|
||||||
|
const wishlistCard: MediaCard = props.card.mediaType === 'episode' && details?.mediaType === 'series'
|
||||||
|
? {
|
||||||
|
...props.card,
|
||||||
|
id: details.providerId ? `jellyfin-${details.providerId}` : details.id,
|
||||||
|
tmdbId: details.tmdbId ?? props.card.tmdbId,
|
||||||
|
providerId: details.providerId ?? props.card.providerId,
|
||||||
|
title: details.title,
|
||||||
|
subtitle: '',
|
||||||
|
overview: details.overview,
|
||||||
|
mediaType: 'series',
|
||||||
|
posterUrl: details.posterUrl,
|
||||||
|
backdropUrl: details.backdropUrl,
|
||||||
|
logoUrl: details.logoUrl ?? props.card.logoUrl,
|
||||||
|
progress: undefined,
|
||||||
|
secondaryValue: undefined,
|
||||||
|
hoverLabel: undefined
|
||||||
|
}
|
||||||
|
: props.card
|
||||||
const displaySubtitle = details?.subtitle || props.card.subtitle
|
const displaySubtitle = details?.subtitle || props.card.subtitle
|
||||||
const displayOverview = details?.overview || props.card.overview || 'No details available yet.'
|
const displayOverview = details?.overview || props.card.overview || 'No details available yet.'
|
||||||
const displayYear = props.card.releaseDate?.slice(0, 4)
|
const displayYear = props.card.releaseDate?.slice(0, 4)
|
||||||
@@ -2716,7 +2780,7 @@ function TitleDetailsModal(props: {
|
|||||||
</p>
|
</p>
|
||||||
<div className="title-details-summary-header">
|
<div className="title-details-summary-header">
|
||||||
{details?.mediaType !== 'series' ? (
|
{details?.mediaType !== 'series' ? (
|
||||||
<WishlistHeart card={props.card} className="title-season-action title-wishlist-button" divider="after" />
|
<WishlistHeart card={wishlistCard} className="title-season-action title-wishlist-button" divider="after" />
|
||||||
) : null}
|
) : null}
|
||||||
{canPlay && details?.mediaType !== 'series' ? (
|
{canPlay && details?.mediaType !== 'series' ? (
|
||||||
<ActionButton className="title-summary-header-play" onClick={() => setPlayerTarget({ id: playId!, title: playLabel })} variant="play">
|
<ActionButton className="title-summary-header-play" onClick={() => setPlayerTarget({ id: playId!, title: playLabel })} variant="play">
|
||||||
@@ -2838,7 +2902,7 @@ function TitleDetailsModal(props: {
|
|||||||
</div>
|
</div>
|
||||||
<>
|
<>
|
||||||
<div className="title-season-actions">
|
<div className="title-season-actions">
|
||||||
<WishlistHeart card={props.card} className="title-season-action title-wishlist-button" divider="before" />
|
<WishlistHeart card={wishlistCard} className="title-season-action title-wishlist-button" divider="before" />
|
||||||
{shouldShowDownloadSeasonAction || activeSeasonMeta?.isDownloading ? <div className="title-season-divider title-season-action-divider" aria-hidden="true" /> : null}
|
{shouldShowDownloadSeasonAction || activeSeasonMeta?.isDownloading ? <div className="title-season-divider title-season-action-divider" aria-hidden="true" /> : null}
|
||||||
{shouldShowDownloadSeasonAction || activeSeasonMeta?.isDownloading ? (
|
{shouldShowDownloadSeasonAction || activeSeasonMeta?.isDownloading ? (
|
||||||
activeSeasonDownloadStatus === 'downloading' ? (
|
activeSeasonDownloadStatus === 'downloading' ? (
|
||||||
@@ -4149,6 +4213,7 @@ function GlobeGlyph() {
|
|||||||
|
|
||||||
function AdministrationScreen(props: {
|
function AdministrationScreen(props: {
|
||||||
config: AppConfig
|
config: AppConfig
|
||||||
|
savedConfig: AppConfig
|
||||||
connections: ConnectionStatus[]
|
connections: ConnectionStatus[]
|
||||||
error: string
|
error: string
|
||||||
notice: string
|
notice: string
|
||||||
@@ -4179,6 +4244,7 @@ function AdministrationScreen(props: {
|
|||||||
<SettingsView
|
<SettingsView
|
||||||
busy={props.busy}
|
busy={props.busy}
|
||||||
config={props.config}
|
config={props.config}
|
||||||
|
savedConfig={props.savedConfig}
|
||||||
connections={props.connections}
|
connections={props.connections}
|
||||||
onCheck={props.onCheck}
|
onCheck={props.onCheck}
|
||||||
onExportBackup={props.onExportBackup}
|
onExportBackup={props.onExportBackup}
|
||||||
@@ -4194,6 +4260,7 @@ function AdministrationScreen(props: {
|
|||||||
|
|
||||||
function SettingsView(props: {
|
function SettingsView(props: {
|
||||||
config: AppConfig
|
config: AppConfig
|
||||||
|
savedConfig: AppConfig
|
||||||
connections: ConnectionStatus[]
|
connections: ConnectionStatus[]
|
||||||
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
|
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
|
||||||
options: ServiceOptionsResponse
|
options: ServiceOptionsResponse
|
||||||
@@ -4205,11 +4272,13 @@ function SettingsView(props: {
|
|||||||
formId?: string
|
formId?: string
|
||||||
}) {
|
}) {
|
||||||
const check = { busy: props.busy, onCheck: props.onCheck }
|
const check = { busy: props.busy, onCheck: props.onCheck }
|
||||||
|
// Each card lights up only for the fields it owns.
|
||||||
|
const changed = (pick: (config: AppConfig) => unknown) => JSON.stringify(pick(props.config)) !== JSON.stringify(pick(props.savedConfig))
|
||||||
const importInputRef = useRef<HTMLInputElement | null>(null)
|
const importInputRef = useRef<HTMLInputElement | null>(null)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="settings-page" id={props.formId} onSubmit={(event) => void props.onSave(event)}>
|
<form className="settings-page" id={props.formId} onSubmit={(event) => void props.onSave(event)}>
|
||||||
<SettingsCard title="Connections">
|
<SettingsCard title="Connections" {...check} dirty={changed((c) => [c.preferences.language, c.preferences.region])}>
|
||||||
<div className="settings-connections">
|
<div className="settings-connections">
|
||||||
{SERVICE_KEYS.map((key) => getServiceStatus(props.connections, key) ?? notCheckedYet(key)).map((connection) => (
|
{SERVICE_KEYS.map((key) => getServiceStatus(props.connections, key) ?? notCheckedYet(key)).map((connection) => (
|
||||||
<div className="settings-connection" key={connection.key} title={connection.message}>
|
<div className="settings-connection" key={connection.key} title={connection.message}>
|
||||||
@@ -4221,20 +4290,43 @@ function SettingsView(props: {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="settings-preferences">
|
||||||
|
<label>
|
||||||
|
Language
|
||||||
|
<select
|
||||||
|
className="input"
|
||||||
|
onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, language: event.target.value })}
|
||||||
|
value={props.config.preferences.language}
|
||||||
|
>
|
||||||
|
{withCurrentOption(LANGUAGE_OPTIONS, props.config.preferences.language).map((option) => (
|
||||||
|
<option key={option.id} value={option.id}>{option.label}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Region
|
||||||
|
<select
|
||||||
|
className="input"
|
||||||
|
onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, region: event.target.value })}
|
||||||
|
value={props.config.preferences.region}
|
||||||
|
>
|
||||||
|
{withCurrentOption(REGION_OPTIONS, props.config.preferences.region).map((option) => (
|
||||||
|
<option key={option.id} value={option.id}>{option.label}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
|
|
||||||
<SettingsCard title="Preferences" {...check}>
|
<SettingsCard side title="Profiles" {...check} dirty={changed((c) => c.preferences.hiddenSections)}>
|
||||||
<label>
|
<ProfilesAccess
|
||||||
Language
|
config={props.config}
|
||||||
<input className="input" onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, language: event.target.value })} value={props.config.preferences.language} />
|
updateConfig={props.updateConfig}
|
||||||
</label>
|
users={props.options.jellyfinUsers}
|
||||||
<label>
|
/>
|
||||||
Region
|
|
||||||
<input className="input" maxLength={2} onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, region: event.target.value })} value={props.config.preferences.region} />
|
|
||||||
</label>
|
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
|
|
||||||
<SettingsCard status={getServiceStatus(props.connections, 'jellyfin') ?? notCheckedYet('jellyfin')} title="Jellyfin" {...check}>
|
<SettingsCard status={getServiceStatus(props.connections, 'jellyfin') ?? notCheckedYet('jellyfin')} title="Jellyfin" {...check} dirty={changed((c) => [c.jellyfin.baseUrl, c.jellyfin.apiKey])}>
|
||||||
<ServiceFields
|
<ServiceFields
|
||||||
apiKey={props.config.jellyfin.apiKey}
|
apiKey={props.config.jellyfin.apiKey}
|
||||||
baseUrl={props.config.jellyfin.baseUrl}
|
baseUrl={props.config.jellyfin.baseUrl}
|
||||||
@@ -4243,7 +4335,7 @@ function SettingsView(props: {
|
|||||||
/>
|
/>
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
|
|
||||||
<SettingsCard status={getServiceStatus(props.connections, 'sonarr') ?? notCheckedYet('sonarr')} title="Sonarr" {...check}>
|
<SettingsCard status={getServiceStatus(props.connections, 'sonarr') ?? notCheckedYet('sonarr')} title="Sonarr" {...check} dirty={changed((c) => [c.sonarr, c.preferences.sonarrDownloadQualityProfileIds])}>
|
||||||
<ServiceFields
|
<ServiceFields
|
||||||
apiKey={props.config.sonarr.apiKey}
|
apiKey={props.config.sonarr.apiKey}
|
||||||
baseUrl={props.config.sonarr.baseUrl}
|
baseUrl={props.config.sonarr.baseUrl}
|
||||||
@@ -4260,7 +4352,7 @@ function SettingsView(props: {
|
|||||||
/>
|
/>
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
|
|
||||||
<SettingsCard status={getServiceStatus(props.connections, 'radarr') ?? notCheckedYet('radarr')} title="Radarr" {...check}>
|
<SettingsCard status={getServiceStatus(props.connections, 'radarr') ?? notCheckedYet('radarr')} title="Radarr" {...check} dirty={changed((c) => [c.radarr, c.preferences.radarrDownloadQualityProfileIds])}>
|
||||||
<ServiceFields
|
<ServiceFields
|
||||||
apiKey={props.config.radarr.apiKey}
|
apiKey={props.config.radarr.apiKey}
|
||||||
baseUrl={props.config.radarr.baseUrl}
|
baseUrl={props.config.radarr.baseUrl}
|
||||||
@@ -4277,14 +4369,14 @@ function SettingsView(props: {
|
|||||||
/>
|
/>
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
|
|
||||||
<SettingsCard status={getServiceStatus(props.connections, 'tmdb') ?? notCheckedYet('tmdb')} title="TMDb" {...check}>
|
<SettingsCard status={getServiceStatus(props.connections, 'tmdb') ?? notCheckedYet('tmdb')} title="TMDb" {...check} dirty={changed((c) => c.tmdb)}>
|
||||||
<label>
|
<label>
|
||||||
API key or Read Access Token
|
API key or Read Access Token
|
||||||
<input className="input" onChange={(event) => props.updateConfig('tmdb', { bearerToken: event.target.value })} placeholder="API key or API Read Access Token" value={props.config.tmdb.bearerToken} />
|
<input className="input" onChange={(event) => props.updateConfig('tmdb', { bearerToken: event.target.value })} placeholder="API key or API Read Access Token" value={props.config.tmdb.bearerToken} />
|
||||||
</label>
|
</label>
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
|
|
||||||
<SettingsCard status={getServiceStatus(props.connections, 'tvdb') ?? notCheckedYet('tvdb')} title="TVDB" {...check}>
|
<SettingsCard status={getServiceStatus(props.connections, 'tvdb') ?? notCheckedYet('tvdb')} title="TVDB" {...check} dirty={changed((c) => c.tvdb)}>
|
||||||
<label>
|
<label>
|
||||||
API key
|
API key
|
||||||
<input className="input" onChange={(event) => props.updateConfig('tvdb', { apiKey: event.target.value })} placeholder="Optional if already provided via TVDB_API_KEY" value={props.config.tvdb.apiKey} />
|
<input className="input" onChange={(event) => props.updateConfig('tvdb', { apiKey: event.target.value })} placeholder="Optional if already provided via TVDB_API_KEY" value={props.config.tvdb.apiKey} />
|
||||||
@@ -4332,13 +4424,20 @@ function notCheckedYet(key: ConnectionStatus['key']): ConnectionStatus {
|
|||||||
return { key, label: SERVICE_LABELS[key], ok: false, message: 'Not configured', configured: false, optional: key !== 'jellyfin' }
|
return { key, label: SERVICE_LABELS[key], ok: false, message: 'Not configured', configured: false, optional: key !== 'jellyfin' }
|
||||||
}
|
}
|
||||||
|
|
||||||
function SettingsCard({ title, status, busy, onCheck, children }: { title: string; status?: ConnectionStatus; busy?: boolean; onCheck?: () => Promise<void>; children: ReactNode }) {
|
function SettingsCard({ title, status, busy, dirty, side, onCheck, children }: { title: string; status?: ConnectionStatus; busy?: boolean; dirty?: boolean; side?: boolean; onCheck?: () => Promise<void>; children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<section className="settings-card">
|
<section className={side ? 'settings-card is-side' : 'settings-card'}>
|
||||||
<div className="settings-card-header">
|
<div className="settings-card-header">
|
||||||
<h2>{title}</h2>
|
<h2>{title}</h2>
|
||||||
{onCheck ? (
|
{onCheck ? (
|
||||||
<button aria-label={`Save and check ${title}`} className="settings-card-check" disabled={busy} onClick={() => void onCheck()} title="Save and check" type="button">
|
<button
|
||||||
|
aria-label={dirty ? `Save changes and check ${title}` : `Save and check ${title}`}
|
||||||
|
className={dirty ? 'settings-card-check is-dirty' : 'settings-card-check'}
|
||||||
|
disabled={busy}
|
||||||
|
onClick={() => void onCheck()}
|
||||||
|
title={dirty ? 'You have unsaved changes: click to save and apply them' : 'Save and check'}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
<CheckGlyph />
|
<CheckGlyph />
|
||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -4412,6 +4511,225 @@ function QualityProfileVisibility(props: {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ProfilesAccess(props: {
|
||||||
|
users: SelectOption[]
|
||||||
|
config: AppConfig
|
||||||
|
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
|
||||||
|
}) {
|
||||||
|
const [access, setAccess] = useState<ProfileLibraryAccess[]>([])
|
||||||
|
const [accessError, setAccessError] = useState('')
|
||||||
|
const [openUserId, setOpenUserId] = useState('')
|
||||||
|
const [query, setQuery] = useState('')
|
||||||
|
const [moreBelow, setMoreBelow] = useState(false)
|
||||||
|
const listRef = useRef<HTMLUListElement | null>(null)
|
||||||
|
const preferences = props.config.preferences
|
||||||
|
const openUser = props.users.find((user) => user.id === openUserId)
|
||||||
|
const visibleUsers = props.users.filter((user) => user.label.toLowerCase().includes(query.trim().toLowerCase()))
|
||||||
|
|
||||||
|
function updateMoreBelow() {
|
||||||
|
const list = listRef.current
|
||||||
|
setMoreBelow(Boolean(list) && list!.scrollHeight - list!.scrollTop - list!.clientHeight > 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The list is as tall as the card next to it, so tell whether more rows hide below.
|
||||||
|
useEffect(() => {
|
||||||
|
const list = listRef.current
|
||||||
|
updateMoreBelow()
|
||||||
|
if (!list) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const observer = new ResizeObserver(updateMoreBelow)
|
||||||
|
observer.observe(list)
|
||||||
|
return () => observer.disconnect()
|
||||||
|
}, [visibleUsers.length, props.users.length])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!props.users.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let cancelled = false
|
||||||
|
api.getProfileAccess()
|
||||||
|
.then((response) => {
|
||||||
|
if (cancelled) return
|
||||||
|
setAccess(response.profiles)
|
||||||
|
setAccessError('')
|
||||||
|
})
|
||||||
|
.catch((loadError) => {
|
||||||
|
if (cancelled) return
|
||||||
|
setAccessError(loadError instanceof Error ? loadError.message : 'Could not read the Jellyfin libraries.')
|
||||||
|
})
|
||||||
|
return () => {
|
||||||
|
cancelled = true
|
||||||
|
}
|
||||||
|
}, [props.users.length])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!openUser) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const closeOnEscape = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === 'Escape') setOpenUserId('')
|
||||||
|
}
|
||||||
|
window.addEventListener('keydown', closeOnEscape)
|
||||||
|
return () => window.removeEventListener('keydown', closeOnEscape)
|
||||||
|
}, [openUser])
|
||||||
|
|
||||||
|
function setSectionVisible(userId: string, section: HideableSection, visible: boolean) {
|
||||||
|
const current = preferences.hiddenSections[userId] ?? []
|
||||||
|
const next = visible ? current.filter((id) => id !== section) : [...current.filter((id) => id !== section), section]
|
||||||
|
const hiddenSections = { ...preferences.hiddenSections }
|
||||||
|
if (next.length) {
|
||||||
|
hiddenSections[userId] = next
|
||||||
|
} else {
|
||||||
|
delete hiddenSections[userId]
|
||||||
|
}
|
||||||
|
props.updateConfig('preferences', { ...preferences, hiddenSections })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!props.users.length) {
|
||||||
|
return <p className="profiles-access-note">Connect Jellyfin first to load its profiles.</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="profiles-access">
|
||||||
|
<p className="profiles-access-note">
|
||||||
|
Pick a profile to choose which sections it sees and review the libraries Jellyfin gives it.
|
||||||
|
Upcoming also leaves out releases stored in libraries a profile cannot open.
|
||||||
|
</p>
|
||||||
|
<input
|
||||||
|
aria-label="Search profiles"
|
||||||
|
className="input profiles-access-search"
|
||||||
|
onChange={(event) => setQuery(event.target.value)}
|
||||||
|
placeholder="Search profiles"
|
||||||
|
type="search"
|
||||||
|
value={query}
|
||||||
|
/>
|
||||||
|
<div className="profiles-access-scroll">
|
||||||
|
<ul className="profiles-access-list" onScroll={updateMoreBelow} ref={listRef}>
|
||||||
|
{visibleUsers.map((user) => {
|
||||||
|
const hidden = preferences.hiddenSections[user.id] ?? []
|
||||||
|
return (
|
||||||
|
<li key={user.id}>
|
||||||
|
<button className="profiles-access-summary" onClick={() => setOpenUserId(user.id)} type="button">
|
||||||
|
<ProfileAvatar user={user} />
|
||||||
|
<span className="profiles-access-name">{user.label}</span>
|
||||||
|
<span className="profiles-access-meta">
|
||||||
|
{hidden.length ? `${hidden.length} hidden` : 'All sections'}
|
||||||
|
</span>
|
||||||
|
<span aria-hidden="true" className="profiles-access-chevron" />
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
{!visibleUsers.length ? <li className="profiles-access-note">No profiles match “{query.trim()}”.</li> : null}
|
||||||
|
</ul>
|
||||||
|
{moreBelow ? (
|
||||||
|
<button
|
||||||
|
aria-label="Show more profiles"
|
||||||
|
className="profiles-access-more"
|
||||||
|
onClick={() => listRef.current?.scrollBy({ top: listRef.current.clientHeight * 0.8, behavior: 'smooth' })}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<span aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
{openUser ? createPortal(
|
||||||
|
<div className="profile-dialog-backdrop" onClick={() => setOpenUserId('')}>
|
||||||
|
<div
|
||||||
|
aria-label={`${openUser.label} settings`}
|
||||||
|
aria-modal="true"
|
||||||
|
className="profile-dialog"
|
||||||
|
onClick={(event) => event.stopPropagation()}
|
||||||
|
role="dialog"
|
||||||
|
>
|
||||||
|
<header className="profile-dialog-header">
|
||||||
|
<ProfileAvatar user={openUser} />
|
||||||
|
<div>
|
||||||
|
<h2>{openUser.label}</h2>
|
||||||
|
<p>Changes are saved with the check button of the Profiles card.</p>
|
||||||
|
</div>
|
||||||
|
<button aria-label="Close" className="profile-dialog-close" onClick={() => setOpenUserId('')} type="button">×</button>
|
||||||
|
</header>
|
||||||
|
<div className="profile-dialog-body">
|
||||||
|
<section>
|
||||||
|
<h3>Sections</h3>
|
||||||
|
<div className="profile-sections">
|
||||||
|
{HIDEABLE_SECTIONS.map((section) => (
|
||||||
|
<label className="profile-section-row" key={section.id}>
|
||||||
|
<span className="profile-section-icon">{renderSectionIcon(section.id)}</span>
|
||||||
|
<span className="profile-section-label">{section.label}</span>
|
||||||
|
<ToggleSwitch
|
||||||
|
checked={!(preferences.hiddenSections[openUser.id] ?? []).includes(section.id)}
|
||||||
|
label={`${section.label} for ${openUser.label}`}
|
||||||
|
onChange={(visible) => setSectionVisible(openUser.id, section.id, visible)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h3>Libraries</h3>
|
||||||
|
{(() => {
|
||||||
|
const profileAccess = access.find((entry) => entry.userId === openUser.id)
|
||||||
|
if (!profileAccess) {
|
||||||
|
return <p className="profiles-access-note">{accessError || 'Loading libraries…'}</p>
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ul className="profile-libraries">
|
||||||
|
{profileAccess.libraries.map((library) => (
|
||||||
|
<li className={library.access ? 'profile-library-row has-access' : 'profile-library-row no-access'} key={library.id}>
|
||||||
|
<span className="profile-library-name">{library.name}</span>
|
||||||
|
<span className="profile-library-state">{library.access ? 'Has access' : 'No access'}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<p className="profiles-access-note">{profileAccess.allLibraries ? 'Can open every library. ' : ''}Managed in Jellyfin.</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
})()}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
document.body
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The icon each section has in the sidebar, for the profile settings.
|
||||||
|
function renderSectionIcon(section: HideableSection) {
|
||||||
|
switch (section) {
|
||||||
|
case 'search': return <SearchGlyph />
|
||||||
|
case 'calendar': return <CalendarGlyph />
|
||||||
|
case 'downloads': return <DownloadGlyph />
|
||||||
|
case 'wishlist': return <HeartGlyph />
|
||||||
|
case 'library': return <LibraryGlyph />
|
||||||
|
case 'dorama': return <span className="profile-section-letter">아</span>
|
||||||
|
case 'anime': return <span className="profile-section-letter">あ</span>
|
||||||
|
default: {
|
||||||
|
const network = networkSidebarItems.find((item) => item.route === section)
|
||||||
|
return network ? <img alt="" className={network.iconClassName || 'sidebar-network-icon-image'} src={network.icon} /> : null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToggleSwitch(props: { checked: boolean; label: string; onChange: (checked: boolean) => void }) {
|
||||||
|
return (
|
||||||
|
<span className="toggle-switch">
|
||||||
|
<input
|
||||||
|
aria-label={props.label}
|
||||||
|
checked={props.checked}
|
||||||
|
onChange={(event) => props.onChange(event.target.checked)}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
<span aria-hidden="true" className="toggle-switch-track" />
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function EmptyState({ title, copy, className }: { title: string; copy: string; className?: string }) {
|
function EmptyState({ title, copy, className }: { title: string; copy: string; className?: string }) {
|
||||||
return (
|
return (
|
||||||
<div className={className ? `empty-state ${className}` : 'empty-state'}>
|
<div className={className ? `empty-state ${className}` : 'empty-state'}>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import type {
|
|||||||
JellyfinLoginPayload,
|
JellyfinLoginPayload,
|
||||||
MediaCard,
|
MediaCard,
|
||||||
MovieDeletePayload,
|
MovieDeletePayload,
|
||||||
|
ProfileLibraryAccess,
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
ServiceOptionsResponse,
|
ServiceOptionsResponse,
|
||||||
SessionResponse,
|
SessionResponse,
|
||||||
@@ -103,6 +104,7 @@ export const api = {
|
|||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
}),
|
}),
|
||||||
exportBackup: () => request<BackupFile>('/api/admin/backup'),
|
exportBackup: () => request<BackupFile>('/api/admin/backup'),
|
||||||
|
getProfileAccess: () => request<{ profiles: ProfileLibraryAccess[] }>('/api/admin/profile-access'),
|
||||||
importBackup: (backup: unknown) =>
|
importBackup: (backup: unknown) =>
|
||||||
request<{ config: AppConfig; connections: ConnectionStatus[] }>('/api/admin/backup', {
|
request<{ config: AppConfig; connections: ConnectionStatus[] }>('/api/admin/backup', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
+452
-3
@@ -3991,6 +3991,23 @@ img {
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unsaved changes: the button turns amber and pulses until they are applied. */
|
||||||
|
.settings-card-check.is-dirty {
|
||||||
|
background: #f6ad55;
|
||||||
|
animation: settings-check-pulse 1.8s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes settings-check-pulse {
|
||||||
|
0%, 100% { box-shadow: 0 0 0 0 rgba(246, 173, 85, 0.5); }
|
||||||
|
50% { box-shadow: 0 0 0 0.45rem rgba(246, 173, 85, 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.settings-card-check.is-dirty {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.settings-card label,
|
.settings-card label,
|
||||||
.auth-form label {
|
.auth-form label {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -6041,10 +6058,11 @@ img {
|
|||||||
color: #ff5c7a;
|
color: #ff5c7a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Touch screens have no hover, so the heart is always visible there. */
|
/* Phones and touch screens have no hover, and a heart on every poster is noise;
|
||||||
@media (hover: none) {
|
the wishlist stays reachable from the title details. */
|
||||||
|
@media (hover: none), (max-width: 980px) {
|
||||||
.media-wishlist-button {
|
.media-wishlist-button {
|
||||||
opacity: 1;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6072,3 +6090,434 @@ img {
|
|||||||
max-width: 76rem;
|
max-width: 76rem;
|
||||||
margin: 0 auto 1rem;
|
margin: 0 auto 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Profiles: who sees which sections, and which libraries Jellyfin gives them. */
|
||||||
|
.visually-hidden {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
margin: -1px;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
white-space: nowrap;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-note {
|
||||||
|
margin: 0;
|
||||||
|
color: #9ba9c2;
|
||||||
|
font-size: 0.86rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-scroll {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-list {
|
||||||
|
display: grid;
|
||||||
|
flex: 1;
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
align-content: start;
|
||||||
|
gap: 0.6rem;
|
||||||
|
min-height: 0;
|
||||||
|
max-height: 26rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
list-style: none;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A hint that more profiles wait below: a fade with an arrow that scrolls down. */
|
||||||
|
.profiles-access-more {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
display: grid;
|
||||||
|
place-items: end center;
|
||||||
|
height: 3.6rem;
|
||||||
|
padding: 0 0 0.35rem;
|
||||||
|
border: 0;
|
||||||
|
background: linear-gradient(to top, rgba(10, 12, 18, 0.96) 15%, rgba(10, 12, 18, 0));
|
||||||
|
color: #dfe7f7;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-more span {
|
||||||
|
width: 0.55rem;
|
||||||
|
height: 0.55rem;
|
||||||
|
border-right: 2px solid currentColor;
|
||||||
|
border-bottom: 2px solid currentColor;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
animation: profiles-access-nudge 1.6s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes profiles-access-nudge {
|
||||||
|
0%, 100% { translate: 0 0; }
|
||||||
|
50% { translate: 0 0.25rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.profiles-access-more span {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next to the Connections card, the card takes that card's height instead of
|
||||||
|
stretching the row, and its list scrolls inside it. */
|
||||||
|
.settings-card.is-side {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card.is-side .settings-fields {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card.is-side .profiles-access {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 981px) {
|
||||||
|
.settings-card.is-side {
|
||||||
|
min-height: 20rem;
|
||||||
|
contain: size;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card.is-side .profiles-access-list {
|
||||||
|
max-height: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-summary {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.85rem;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.7rem 0.95rem;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
border-radius: 1rem;
|
||||||
|
background: rgba(255, 255, 255, 0.025);
|
||||||
|
color: #f4f7ff;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 160ms ease, border-color 160ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-summary:hover,
|
||||||
|
.profiles-access-summary:focus-visible {
|
||||||
|
border-color: rgba(255, 255, 255, 0.2);
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-summary .profile-avatar,
|
||||||
|
.profile-dialog-header .profile-avatar {
|
||||||
|
flex: none;
|
||||||
|
width: 2.4rem;
|
||||||
|
height: 2.4rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
font-size: 1rem;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-header .profile-avatar {
|
||||||
|
width: 3.2rem;
|
||||||
|
height: 3.2rem;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-name {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-meta {
|
||||||
|
color: #9ba9c2;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profiles-access-chevron {
|
||||||
|
width: 0.5rem;
|
||||||
|
height: 0.5rem;
|
||||||
|
border-top: 2px solid #9ba9c2;
|
||||||
|
border-right: 2px solid #9ba9c2;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-backdrop {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 200;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: rgba(3, 5, 10, 0.72);
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog {
|
||||||
|
display: grid;
|
||||||
|
gap: 1.6rem;
|
||||||
|
width: min(46rem, 100%);
|
||||||
|
max-height: calc(100vh - 3rem);
|
||||||
|
padding: 1.8rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||||
|
border-radius: 1.4rem;
|
||||||
|
background: #0b0e16;
|
||||||
|
box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-body {
|
||||||
|
display: grid;
|
||||||
|
gap: 1.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-header > div {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-header h2 {
|
||||||
|
margin: 0;
|
||||||
|
color: #f4f7ff;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-header p {
|
||||||
|
margin: 0.15rem 0 0;
|
||||||
|
color: #9ba9c2;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-close {
|
||||||
|
display: grid;
|
||||||
|
flex: none;
|
||||||
|
place-items: center;
|
||||||
|
width: 2.2rem;
|
||||||
|
height: 2.2rem;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: #f4f7ff;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-close:hover,
|
||||||
|
.profile-dialog-close:focus-visible {
|
||||||
|
background: rgba(255, 255, 255, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-dialog-body h3 {
|
||||||
|
margin: 0 0 0.7rem;
|
||||||
|
color: #e8efff;
|
||||||
|
font-size: 0.84rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-sections {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.9rem;
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||||
|
border-radius: 1rem;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
color: #dfe7f7;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-row:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-icon {
|
||||||
|
display: grid;
|
||||||
|
flex: none;
|
||||||
|
place-items: center;
|
||||||
|
width: 2.4rem;
|
||||||
|
height: 2.4rem;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: #f4f7ff;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-icon svg {
|
||||||
|
width: 1.15rem;
|
||||||
|
height: 1.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-icon img {
|
||||||
|
width: 1.5rem;
|
||||||
|
height: 1.5rem;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-letter {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-section-label {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-libraries {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.6rem;
|
||||||
|
margin: 0 0 0.8rem;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-library-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||||
|
border-radius: 1rem;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-library-state {
|
||||||
|
padding: 0.2rem 0.7rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-library-row.has-access .profile-library-state {
|
||||||
|
background: rgba(104, 211, 145, 0.16);
|
||||||
|
color: #68d391;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-library-row.no-access {
|
||||||
|
color: #7d89a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-library-row.no-access .profile-library-state {
|
||||||
|
background: rgba(255, 107, 129, 0.16);
|
||||||
|
color: #ff6b81;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
flex: none;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 1.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch input {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 1;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
opacity: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch-track {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(255, 255, 255, 0.16);
|
||||||
|
transition: background 160ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch-track::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0.2rem;
|
||||||
|
left: 0.2rem;
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #f4f7ff;
|
||||||
|
transition: transform 160ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch input:checked + .toggle-switch-track {
|
||||||
|
background: #68d391;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch input:checked + .toggle-switch-track::after {
|
||||||
|
transform: translateX(1.1rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch input:focus-visible + .toggle-switch-track {
|
||||||
|
outline: 2px solid #dfe7f7;
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 760px) {
|
||||||
|
.profile-sections {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-preferences {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.9rem;
|
||||||
|
margin-top: 0.4rem;
|
||||||
|
padding-top: 1.1rem;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
select.input {
|
||||||
|
appearance: none;
|
||||||
|
padding-right: 2.6rem;
|
||||||
|
background-image: linear-gradient(45deg, transparent 50%, #9ba9c2 50%), linear-gradient(135deg, #9ba9c2 50%, transparent 50%);
|
||||||
|
background-position: calc(100% - 1.3rem) 50%, calc(100% - 0.95rem) 50%;
|
||||||
|
background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.input option {
|
||||||
|
background: #0b0e16;
|
||||||
|
color: #f4f7ff;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user