mirror of
https://github.com/WonderAliceUwU/OmniArr.git
synced 2026-11-25 11:35:56 +00:00
⭐️ feat: filter upcoming by library folder, profile settings dialog, tests and docs
This commit is contained in:
1 parent
1376d75ed8
commit
9ed8260a10
8 files changed
+433
-138
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" />
|
||||
|
||||
- A download manager to see what's cooking.
|
||||
- Per-profile control of which sections each person sees (see [Profiles](#profiles)).
|
||||
|
||||
And many things more!
|
||||
|
||||
@@ -122,6 +123,48 @@ npm run lint
|
||||
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`). 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
|
||||
|
||||
OmniArr keeps critical state under `OMNIARR_DATA_DIR` (by default
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview",
|
||||
"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": {
|
||||
"react": "^19.2.5",
|
||||
|
||||
+52
-12
@@ -193,6 +193,7 @@ interface SonarrCalendarRecord {
|
||||
series?: {
|
||||
title?: string;
|
||||
tmdbId?: number;
|
||||
path?: string;
|
||||
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
||||
year?: number;
|
||||
status?: string;
|
||||
@@ -243,6 +244,7 @@ interface RadarrCalendarRecord {
|
||||
digitalRelease?: string;
|
||||
monitored?: boolean;
|
||||
hasFile?: boolean;
|
||||
path?: string;
|
||||
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
||||
}
|
||||
|
||||
@@ -405,8 +407,7 @@ export function sanitizeConfig(input: AppConfig): AppConfig {
|
||||
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
|
||||
? input.preferences.radarrDownloadQualityProfileIds.map(String)
|
||||
: [],
|
||||
hiddenSections: sanitizeHiddenSections(input.preferences.hiddenSections),
|
||||
filterUpcomingByLibrary: Boolean(input.preferences.filterUpcomingByLibrary)
|
||||
hiddenSections: sanitizeHiddenSections(input.preferences.hiddenSections)
|
||||
},
|
||||
jellyfin: {
|
||||
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
|
||||
@@ -772,19 +773,16 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr
|
||||
// tell which episodes are already in the library.
|
||||
const library = await getLibrarySnapshot(config).catch(() => null);
|
||||
|
||||
// With the setting on, a profile's calendar is the releases of the titles in the
|
||||
// libraries it can open: Jellyfin answers per user with exactly those titles.
|
||||
const ownTitles = config.preferences.filterUpcomingByLibrary && config.jellyfin.userId && library
|
||||
? new Set(library.allItems.map(getTmdbTitleKey).filter(Boolean))
|
||||
: 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) => !ownTitles || ownTitles.has(`series:${Number(item.series?.tmdbId)}`))
|
||||
.filter((item) => !isInFolders(item.series?.path, hiddenFolders))
|
||||
.map((item) => mapSonarrCalendarEntry(item))
|
||||
: []
|
||||
const radarrItems = radarrResult.status === 'fulfilled'
|
||||
? radarrResult.value
|
||||
.filter((item) => !ownTitles || ownTitles.has(`movie:${Number(item.tmdbId)}`))
|
||||
.filter((item) => !isInFolders(item.path, hiddenFolders))
|
||||
.map((item) => mapRadarrCalendarEntry(item))
|
||||
: []
|
||||
const libraryProviderIds = new Map<string, string>();
|
||||
@@ -827,9 +825,51 @@ function normalizeLibraryId(id: string | undefined): string {
|
||||
return String(id || '').replace(/-/g, '').toLowerCase();
|
||||
}
|
||||
|
||||
function getTmdbTitleKey(item: JellyfinItem): string {
|
||||
const tmdbId = Number(item.ProviderIds?.Tmdb);
|
||||
return tmdbId ? `${item.Type === 'Movie' ? 'movie' : 'series'}:${tmdbId}` : '';
|
||||
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
|
||||
|
||||
@@ -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,86 @@
|
||||
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) => unknown): Server {
|
||||
return createServer((request, response) => {
|
||||
const url = new URL(request.url || '/', 'http://localhost');
|
||||
response.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
response.end(JSON.stringify(handler(url.pathname, url.searchParams)));
|
||||
});
|
||||
}
|
||||
|
||||
export async function startMockServices() {
|
||||
const jellyfin = jsonServer((path, query) => {
|
||||
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.');
|
||||
}
|
||||
+1
-4
@@ -76,8 +76,6 @@ export interface AppPreferences {
|
||||
radarrDownloadQualityProfileIds: string[];
|
||||
/** Sections switched off for each Jellyfin profile, by user id; a profile that is not listed sees everything. */
|
||||
hiddenSections: Record<string, HideableSection[]>;
|
||||
/** Upcoming only lists releases for titles in the Jellyfin libraries the signed-in profile can open. */
|
||||
filterUpcomingByLibrary: boolean;
|
||||
}
|
||||
|
||||
export interface ProfileLibraryAccess {
|
||||
@@ -422,8 +420,7 @@ export const defaultConfig: AppConfig = {
|
||||
animationLevel: 'smooth',
|
||||
sonarrDownloadQualityProfileIds: [],
|
||||
radarrDownloadQualityProfileIds: [],
|
||||
hiddenSections: {},
|
||||
filterUpcomingByLibrary: false
|
||||
hiddenSections: {}
|
||||
},
|
||||
jellyfin: {
|
||||
baseUrl: '',
|
||||
|
||||
+79
-59
@@ -12,6 +12,7 @@ import {
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { api } from './api'
|
||||
import {
|
||||
type CalendarEntry,
|
||||
@@ -4463,6 +4464,7 @@ function ProfilesAccess(props: {
|
||||
const [accessError, setAccessError] = useState('')
|
||||
const [openUserId, setOpenUserId] = useState('')
|
||||
const preferences = props.config.preferences
|
||||
const openUser = props.users.find((user) => user.id === openUserId)
|
||||
|
||||
useEffect(() => {
|
||||
if (!props.users.length) {
|
||||
@@ -4484,6 +4486,17 @@ function ProfilesAccess(props: {
|
||||
}
|
||||
}, [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]
|
||||
@@ -4503,32 +4516,15 @@ function ProfilesAccess(props: {
|
||||
return (
|
||||
<div className="profiles-access">
|
||||
<p className="profiles-access-note">
|
||||
Pick a profile to choose which sections it sees. Libraries come from its Jellyfin permissions and are managed there.
|
||||
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>
|
||||
<label className="profiles-access-option">
|
||||
<span>
|
||||
<strong>Separate Upcoming for each profile</strong>
|
||||
<small>Each profile only sees upcoming releases for the titles in the libraries it can open. Releases not in Jellyfin yet are left out.</small>
|
||||
</span>
|
||||
<ToggleSwitch
|
||||
checked={preferences.filterUpcomingByLibrary}
|
||||
label="Separate Upcoming for each profile"
|
||||
onChange={(filterUpcomingByLibrary) => props.updateConfig('preferences', { ...preferences, filterUpcomingByLibrary })}
|
||||
/>
|
||||
</label>
|
||||
<ul className="profiles-access-list">
|
||||
{props.users.map((user) => {
|
||||
const open = openUserId === user.id
|
||||
const hidden = preferences.hiddenSections[user.id] ?? []
|
||||
const profileAccess = access.find((entry) => entry.userId === user.id)
|
||||
return (
|
||||
<li className={open ? 'profiles-access-item is-open' : 'profiles-access-item'} key={user.id}>
|
||||
<button
|
||||
aria-expanded={open}
|
||||
className="profiles-access-summary"
|
||||
onClick={() => setOpenUserId(open ? '' : user.id)}
|
||||
type="button"
|
||||
>
|
||||
<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">
|
||||
@@ -4536,48 +4532,72 @@ function ProfilesAccess(props: {
|
||||
</span>
|
||||
<span aria-hidden="true" className="profiles-access-chevron" />
|
||||
</button>
|
||||
{open ? (
|
||||
<div className="profiles-access-detail">
|
||||
<div>
|
||||
<h3>Sections</h3>
|
||||
<div className="profiles-access-sections">
|
||||
{HIDEABLE_SECTIONS.map((section) => (
|
||||
<label className="profiles-access-section" key={section.id}>
|
||||
<span>{section.label}</span>
|
||||
<ToggleSwitch
|
||||
checked={!hidden.includes(section.id)}
|
||||
label={`${section.label} for ${user.label}`}
|
||||
onChange={(visible) => setSectionVisible(user.id, section.id, visible)}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>Libraries</h3>
|
||||
{profileAccess ? (
|
||||
<>
|
||||
{profileAccess.allLibraries ? <p className="profiles-access-note">Can open every library.</p> : null}
|
||||
<ul className="profiles-access-libraries">
|
||||
{profileAccess.libraries.map((library) => (
|
||||
<li className={library.access ? 'has-access' : 'no-access'} key={library.id}>
|
||||
<span aria-hidden="true">{library.access ? '✓' : '✕'}</span>
|
||||
<span>{library.name}</span>
|
||||
<span className="visually-hidden">{library.access ? 'has access' : 'no access'}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : (
|
||||
<p className="profiles-access-note">{accessError || 'Loading libraries…'}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
{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="profiles-access-sections">
|
||||
{HIDEABLE_SECTIONS.map((section) => (
|
||||
<label className="profiles-access-section" key={section.id}>
|
||||
<span>{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 (
|
||||
<>
|
||||
{profileAccess.allLibraries ? <p className="profiles-access-note">Can open every library.</p> : null}
|
||||
<ul className="profiles-access-libraries">
|
||||
{profileAccess.libraries.map((library) => (
|
||||
<li className={library.access ? 'has-access' : 'no-access'} key={library.id}>
|
||||
<span aria-hidden="true">{library.access ? '✓' : '✕'}</span>
|
||||
<span>{library.name}</span>
|
||||
<span className="visually-hidden">{library.access ? 'has access' : 'no access'}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="profiles-access-note">Managed in Jellyfin.</p>
|
||||
</>
|
||||
)
|
||||
})()}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+91
-62
@@ -6102,68 +6102,38 @@ img {
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.profiles-access-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 0.85rem 0.95rem;
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
border-radius: 1rem;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
|
||||
.profiles-access-option > span:first-child {
|
||||
display: grid;
|
||||
gap: 0.2rem;
|
||||
min-width: 0;
|
||||
color: #e8efff;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.profiles-access-option small {
|
||||
color: #9ba9c2;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.profiles-access-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
|
||||
gap: 0.6rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.profiles-access-item {
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 1rem;
|
||||
background: rgba(255, 255, 255, 0.025);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.profiles-access-item.is-open {
|
||||
border-color: rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
|
||||
.profiles-access-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.85rem;
|
||||
width: 100%;
|
||||
padding: 0.7rem 0.95rem;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
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 {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.profiles-access-summary .profile-avatar {
|
||||
.profiles-access-summary .profile-avatar,
|
||||
.profile-dialog-header .profile-avatar {
|
||||
flex: none;
|
||||
width: 2.4rem;
|
||||
height: 2.4rem;
|
||||
@@ -6172,10 +6142,10 @@ img {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.profiles-access-summary .profile-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
.profile-dialog-header .profile-avatar {
|
||||
width: 3.2rem;
|
||||
height: 3.2rem;
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
.profiles-access-name {
|
||||
@@ -6190,28 +6160,88 @@ img {
|
||||
}
|
||||
|
||||
.profiles-access-chevron {
|
||||
width: 0.55rem;
|
||||
height: 0.55rem;
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-top: 2px solid #9ba9c2;
|
||||
border-right: 2px solid #9ba9c2;
|
||||
border-bottom: 2px solid #9ba9c2;
|
||||
transform: rotate(45deg);
|
||||
transition: transform 160ms ease;
|
||||
}
|
||||
|
||||
.profiles-access-item.is-open .profiles-access-chevron {
|
||||
transform: rotate(225deg);
|
||||
.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);
|
||||
}
|
||||
|
||||
.profiles-access-detail {
|
||||
.profile-dialog {
|
||||
display: grid;
|
||||
gap: 1.2rem;
|
||||
width: min(44rem, 100%);
|
||||
max-height: calc(100vh - 3rem);
|
||||
padding: 1.4rem;
|
||||
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-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 {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
|
||||
gap: 1.4rem;
|
||||
padding: 0.4rem 0.95rem 1.1rem;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
gap: 1.6rem;
|
||||
}
|
||||
|
||||
.profiles-access-detail h3 {
|
||||
margin: 0.8rem 0 0.6rem;
|
||||
.profile-dialog-body h3 {
|
||||
margin: 0 0 0.7rem;
|
||||
color: #e8efff;
|
||||
font-size: 0.84rem;
|
||||
font-weight: 700;
|
||||
@@ -6221,8 +6251,7 @@ img {
|
||||
|
||||
.profiles-access-sections {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
||||
gap: 0.5rem 1rem;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.profiles-access-section {
|
||||
@@ -6231,13 +6260,13 @@ img {
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
color: #dfe7f7;
|
||||
font-size: 0.9rem;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.profiles-access-libraries {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
margin: 0;
|
||||
gap: 0.45rem;
|
||||
margin: 0 0 0.7rem;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
@@ -6246,7 +6275,7 @@ img {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
font-size: 0.9rem;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.profiles-access-libraries li.has-access {
|
||||
@@ -6318,7 +6347,7 @@ img {
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.profiles-access-detail {
|
||||
.profile-dialog-body {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user