mirror of
https://github.com/WonderAliceUwU/OmniArr.git
synced 2026-11-21 19:35:56 +00:00
⭐️ feat: choose the sections each profile sees and review its Jellyfin libraries from the admin menu
This commit is contained in:
1 parent
2b4119a906
commit
4cea990eb3
6 files changed
+532
-66
No files matched your search
+28
-12
@@ -4,6 +4,7 @@ import { BlockList, isIP } from 'node:net';
|
||||
import { resolve } from 'node:path';
|
||||
import {
|
||||
defaultConfig,
|
||||
HIDEABLE_SECTIONS,
|
||||
type AppConfig,
|
||||
type AuthPayload,
|
||||
type BackupFile,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
type SeriesEpisodeRequestPayload,
|
||||
type EpisodeWatchStateRequest,
|
||||
type DiskSpaceStatus,
|
||||
type HideableSection,
|
||||
type HubPageResponse,
|
||||
type JellyfinLoginPayload,
|
||||
type MovieDeletePayload,
|
||||
@@ -58,6 +60,7 @@ import {
|
||||
setEpisodeWatchState,
|
||||
sanitizeConfig,
|
||||
getDownloadsResponse,
|
||||
getProfileLibraryAccess,
|
||||
dismissCompletedDownload,
|
||||
dismissAllCompletedDownloads
|
||||
} from './lib/services.js';
|
||||
@@ -274,6 +277,23 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
|
||||
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') {
|
||||
const backup: BackupFile = {
|
||||
app: 'omniarr',
|
||||
@@ -394,14 +414,6 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.pathname.startsWith('/api/downloads')) {
|
||||
const config = await readConfig(session!.encryptionKey);
|
||||
if (!canViewDownloads(session!, config)) {
|
||||
sendJson(response, 403, { error: 'You do not have access to downloads.' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (url.pathname === '/api/downloads' && method === 'GET') {
|
||||
const config = await readConfig(session!.encryptionKey);
|
||||
sendJson(response, 200, await getDownloadsResponse(config));
|
||||
@@ -719,10 +731,14 @@ function mergeStoredConfig(stored: Partial<AppConfig>): AppConfig {
|
||||
|
||||
// Profiles keep their own wishlist; the administrator has no Jellyfin profile
|
||||
// and shares a single one.
|
||||
// Profiles the administrator listed cannot open the Downloads page; the admin
|
||||
// session always can.
|
||||
function canViewDownloads(session: SessionRecord, config: AppConfig): boolean {
|
||||
return session.role === 'admin' || !session.userId || !config.preferences.downloadsRestrictedUserIds.includes(session.userId);
|
||||
// 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 {
|
||||
|
||||
+56
-5
@@ -11,10 +11,12 @@ import type {
|
||||
EpisodeRequestPayload,
|
||||
EpisodeWatchStateRequest,
|
||||
HubPageResponse,
|
||||
HideableSection,
|
||||
HubSection,
|
||||
MediaCard,
|
||||
MovieDeletePayload,
|
||||
ProcessingItem,
|
||||
ProfileLibraryAccess,
|
||||
SeasonDeletePayload,
|
||||
SeasonRequestPayload,
|
||||
SeriesEpisodeRequestPayload,
|
||||
@@ -26,6 +28,7 @@ import type {
|
||||
TitleDetailsSeason,
|
||||
TitleDetailsCastMember
|
||||
} from '../../shared/contracts.js';
|
||||
import { HIDEABLE_SECTIONS } from '../../shared/contracts.js';
|
||||
|
||||
const TMDB_IMAGE = 'https://image.tmdb.org/t/p';
|
||||
const TMDB_ARTWORK_TTL_MS = 6 * 60 * 60 * 1000;
|
||||
@@ -373,6 +376,24 @@ let tvdbTokenCache: { token: string; expiresAt: number } | null = null;
|
||||
const tmdbArtworkCache = new Map<string, { expiresAt: number; value: Promise<TmdbArtwork> }>();
|
||||
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 {
|
||||
return {
|
||||
preferences: {
|
||||
@@ -386,9 +407,8 @@ export function sanitizeConfig(input: AppConfig): AppConfig {
|
||||
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
|
||||
? input.preferences.radarrDownloadQualityProfileIds.map(String)
|
||||
: [],
|
||||
downloadsRestrictedUserIds: Array.isArray(input.preferences.downloadsRestrictedUserIds)
|
||||
? input.preferences.downloadsRestrictedUserIds.map(String)
|
||||
: []
|
||||
hiddenSections: sanitizeHiddenSections(input.preferences.hiddenSections),
|
||||
filterUpcomingByLibrary: Boolean(input.preferences.filterUpcomingByLibrary)
|
||||
},
|
||||
jellyfin: {
|
||||
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
|
||||
@@ -754,8 +774,8 @@ 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);
|
||||
|
||||
// A profile only sees upcoming releases that belong to the libraries it can open.
|
||||
const hidden = await getHiddenLibraryScope(config, library?.allItems ?? []);
|
||||
// With the setting on, a profile only sees upcoming releases from the libraries it can open.
|
||||
const hidden = config.preferences.filterUpcomingByLibrary ? await getHiddenLibraryScope(config, library?.allItems ?? []) : null;
|
||||
const sonarrItems = sonarrResult.status === 'fulfilled'
|
||||
? sonarrResult.value
|
||||
.filter((item) => !hidden?.hides('series', Number(item.series?.tmdbId) || undefined, item.series?.path))
|
||||
@@ -869,6 +889,37 @@ async function getHiddenLibraryScope(config: AppConfig, visibleItems: JellyfinIt
|
||||
}
|
||||
}
|
||||
|
||||
// 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(
|
||||
config: AppConfig,
|
||||
rawQuery: string
|
||||
|
||||
+32
-3
@@ -15,6 +15,24 @@ export type AppRoute =
|
||||
| 'wishlist'
|
||||
| '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 {
|
||||
baseUrl: string;
|
||||
}
|
||||
@@ -56,8 +74,18 @@ export interface AppPreferences {
|
||||
animationLevel: 'smooth' | 'reduced';
|
||||
sonarrDownloadQualityProfileIds: string[];
|
||||
radarrDownloadQualityProfileIds: string[];
|
||||
/** Jellyfin profiles that cannot open the Downloads page; empty lets everyone in. */
|
||||
downloadsRestrictedUserIds: string[];
|
||||
/** Sections switched off for each Jellyfin profile, by user id; a profile that is not listed sees everything. */
|
||||
hiddenSections: Record<string, HideableSection[]>;
|
||||
/** Upcoming leaves out releases from Jellyfin libraries the signed-in profile cannot open. */
|
||||
filterUpcomingByLibrary: boolean;
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -394,7 +422,8 @@ export const defaultConfig: AppConfig = {
|
||||
animationLevel: 'smooth',
|
||||
sonarrDownloadQualityProfileIds: [],
|
||||
radarrDownloadQualityProfileIds: [],
|
||||
downloadsRestrictedUserIds: []
|
||||
hiddenSections: {},
|
||||
filterUpcomingByLibrary: false
|
||||
},
|
||||
jellyfin: {
|
||||
baseUrl: '',
|
||||
|
||||
+165
-46
@@ -22,9 +22,11 @@ import {
|
||||
type CompletedDownloadItem,
|
||||
type DownloadItem,
|
||||
type DiskSpaceStatus,
|
||||
type HideableSection,
|
||||
type HubPageResponse,
|
||||
type MediaCard,
|
||||
type ProcessingItem,
|
||||
type ProfileLibraryAccess,
|
||||
type SearchResponse,
|
||||
type SelectOption,
|
||||
type ServiceOptionsResponse,
|
||||
@@ -33,6 +35,7 @@ import {
|
||||
type TitleDetailsResponse,
|
||||
type WishlistEntry,
|
||||
} from '../shared/contracts'
|
||||
import { HIDEABLE_SECTIONS } from '../shared/contracts'
|
||||
|
||||
type AuthState = 'loading' | 'setup' | 'login' | 'profiles' | 'admin' | 'app'
|
||||
type EntryStage = 'onboarding' | 'profiles' | 'dashboard'
|
||||
@@ -125,8 +128,10 @@ function App() {
|
||||
const [downloadDeleteId, setDownloadDeleteId] = useState('')
|
||||
const [wishlist, setWishlist] = useState<WishlistEntry[]>([])
|
||||
const [entryTransitionState, setEntryTransitionState] = useState<EntryTransitionState>('idle')
|
||||
// The administrator can keep some profiles away from Downloads.
|
||||
const canViewDownloads = sessionRole !== 'user' || !config.preferences.downloadsRestrictedUserIds.includes(config.jellyfin.userId)
|
||||
// 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) {
|
||||
if (nextStage === entryStage) {
|
||||
@@ -239,15 +244,16 @@ function App() {
|
||||
return
|
||||
}
|
||||
|
||||
if (routeHidden) {
|
||||
setRoute('home')
|
||||
return
|
||||
}
|
||||
|
||||
if (route === 'settings' || route === 'calendar' || route === 'search' || route === 'wishlist') {
|
||||
return
|
||||
}
|
||||
|
||||
if (route === 'downloads') {
|
||||
if (!canViewDownloads) {
|
||||
setRoute('home')
|
||||
return
|
||||
}
|
||||
void refreshDownloads()
|
||||
const interval = window.setInterval(() => {
|
||||
void refreshDownloads()
|
||||
@@ -276,7 +282,7 @@ function App() {
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [authState, canViewDownloads, entryStage, route])
|
||||
}, [authState, entryStage, route, routeHidden])
|
||||
|
||||
|
||||
|
||||
@@ -672,11 +678,11 @@ function App() {
|
||||
const currentHub = isHubRoute(route) ? hubPages[route as HubPageResponse['page']] : undefined
|
||||
|
||||
return (
|
||||
<WishlistContext.Provider value={wishlistContext}>
|
||||
<WishlistContext.Provider value={isSectionHidden('wishlist') ? null : wishlistContext}>
|
||||
<div className={`omniarr-app ${getEntryTransitionClassName(entryTransitionState)}`}>
|
||||
<Sidebar
|
||||
busy={busy}
|
||||
canViewDownloads={canViewDownloads}
|
||||
isSectionHidden={isSectionHidden}
|
||||
connections={connections}
|
||||
currentUser={currentJellyfinUser}
|
||||
diskSpace={diskSpace}
|
||||
@@ -700,8 +706,8 @@ function App() {
|
||||
title="Nothing to track yet"
|
||||
/>
|
||||
) : null}
|
||||
{route === 'calendar' && isRouteAvailable(route, connections) ? <CalendarPage onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} /> : null}
|
||||
{route === 'downloads' && canViewDownloads && 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 === '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 === 'search' ? (
|
||||
<SearchPage
|
||||
loading={searchLoading}
|
||||
@@ -782,7 +788,7 @@ function Sidebar(props: {
|
||||
connections: ConnectionStatus[]
|
||||
busy: boolean
|
||||
canManage: boolean
|
||||
canViewDownloads: boolean
|
||||
isSectionHidden: (route: AppRoute) => boolean
|
||||
onExitProfile: () => void
|
||||
}) {
|
||||
const [menuOpen, setMenuOpen] = useState(false)
|
||||
@@ -843,7 +849,7 @@ function Sidebar(props: {
|
||||
</button>
|
||||
|
||||
<div className="sidebar-links">
|
||||
{topSidebarItems.filter((item) => isRouteAvailable(item.route, props.connections) && (item.route !== 'downloads' || props.canViewDownloads)).map((item) => (
|
||||
{topSidebarItems.filter((item) => isRouteAvailable(item.route, props.connections) && !props.isSectionHidden(item.route)).map((item) => (
|
||||
<button
|
||||
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
||||
key={item.route}
|
||||
@@ -859,7 +865,7 @@ function Sidebar(props: {
|
||||
</div>
|
||||
|
||||
<div className="sidebar-links">
|
||||
{sidebarItems.map((item) => (
|
||||
{sidebarItems.filter((item) => !props.isSectionHidden(item.route)).map((item) => (
|
||||
<button
|
||||
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
||||
key={item.route}
|
||||
@@ -875,7 +881,7 @@ function Sidebar(props: {
|
||||
</div>
|
||||
|
||||
<div className="sidebar-links">
|
||||
{networkSidebarItems.map((item) => (
|
||||
{networkSidebarItems.filter((item) => !props.isSectionHidden(item.route)).map((item) => (
|
||||
<button
|
||||
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
|
||||
key={item.route}
|
||||
@@ -4260,9 +4266,12 @@ function SettingsView(props: {
|
||||
Region
|
||||
<input className="input" maxLength={2} onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, region: event.target.value })} value={props.config.preferences.region} />
|
||||
</label>
|
||||
<DownloadsAccess
|
||||
onChange={(downloadsRestrictedUserIds) => props.updateConfig('preferences', { ...props.config.preferences, downloadsRestrictedUserIds })}
|
||||
restrictedUserIds={props.config.preferences.downloadsRestrictedUserIds}
|
||||
</SettingsCard>
|
||||
|
||||
<SettingsCard title="Profiles" wide {...check}>
|
||||
<ProfilesAccess
|
||||
config={props.config}
|
||||
updateConfig={props.updateConfig}
|
||||
users={props.options.jellyfinUsers}
|
||||
/>
|
||||
</SettingsCard>
|
||||
@@ -4365,9 +4374,9 @@ function notCheckedYet(key: ConnectionStatus['key']): ConnectionStatus {
|
||||
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, onCheck, wide, children }: { title: string; status?: ConnectionStatus; busy?: boolean; onCheck?: () => Promise<void>; wide?: boolean; children: ReactNode }) {
|
||||
return (
|
||||
<section className="settings-card">
|
||||
<section className={wide ? 'settings-card is-wide' : 'settings-card'}>
|
||||
<div className="settings-card-header">
|
||||
<h2>{title}</h2>
|
||||
{onCheck ? (
|
||||
@@ -4445,35 +4454,145 @@ function QualityProfileVisibility(props: {
|
||||
)
|
||||
}
|
||||
|
||||
function DownloadsAccess(props: {
|
||||
function ProfilesAccess(props: {
|
||||
users: SelectOption[]
|
||||
restrictedUserIds: string[]
|
||||
onChange: (userIds: string[]) => void
|
||||
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 preferences = props.config.preferences
|
||||
|
||||
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])
|
||||
|
||||
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 (
|
||||
<fieldset className="quality-profile-visibility">
|
||||
<legend>Who can see Downloads</legend>
|
||||
<p>Untick the profiles that should not open the Downloads page. The administrator always can.</p>
|
||||
{props.users.length ? (
|
||||
<div className="quality-profile-visibility-list">
|
||||
{props.users.map((user) => {
|
||||
const restricted = props.restrictedUserIds.includes(user.id)
|
||||
return (
|
||||
<label key={user.id}>
|
||||
<input
|
||||
checked={!restricted}
|
||||
onChange={() => props.onChange(restricted
|
||||
? props.restrictedUserIds.filter((id) => id !== user.id)
|
||||
: [...props.restrictedUserIds, user.id])}
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>{user.label}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : <p>Connect Jellyfin first to load its profiles.</p>}
|
||||
</fieldset>
|
||||
<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.
|
||||
</p>
|
||||
<label className="profiles-access-option">
|
||||
<span>
|
||||
<strong>Hide upcoming releases from libraries a profile cannot open</strong>
|
||||
<small>Sonarr and Radarr do not know Jellyfin permissions, so releases are matched to a library by title or by folder.</small>
|
||||
</span>
|
||||
<ToggleSwitch
|
||||
checked={preferences.filterUpcomingByLibrary}
|
||||
label="Hide upcoming releases from libraries a profile cannot open"
|
||||
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"
|
||||
>
|
||||
<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>
|
||||
{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>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
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>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
JellyfinLoginPayload,
|
||||
MediaCard,
|
||||
MovieDeletePayload,
|
||||
ProfileLibraryAccess,
|
||||
SearchResponse,
|
||||
ServiceOptionsResponse,
|
||||
SessionResponse,
|
||||
@@ -103,6 +104,7 @@ export const api = {
|
||||
body: JSON.stringify(payload),
|
||||
}),
|
||||
exportBackup: () => request<BackupFile>('/api/admin/backup'),
|
||||
getProfileAccess: () => request<{ profiles: ProfileLibraryAccess[] }>('/api/admin/profile-access'),
|
||||
importBackup: (backup: unknown) =>
|
||||
request<{ config: AppConfig; connections: ConnectionStatus[] }>('/api/admin/backup', {
|
||||
method: 'POST',
|
||||
|
||||
+249
@@ -6073,3 +6073,252 @@ img {
|
||||
max-width: 76rem;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
/* Profiles: who sees which sections, and which libraries Jellyfin gives them. */
|
||||
.settings-card.is-wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.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-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;
|
||||
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;
|
||||
color: #f4f7ff;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.profiles-access-summary:hover,
|
||||
.profiles-access-summary:focus-visible {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.profiles-access-summary .profile-avatar {
|
||||
flex: none;
|
||||
width: 2.4rem;
|
||||
height: 2.4rem;
|
||||
border-radius: 50%;
|
||||
font-size: 1rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.profiles-access-summary .profile-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.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.55rem;
|
||||
height: 0.55rem;
|
||||
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);
|
||||
}
|
||||
|
||||
.profiles-access-detail {
|
||||
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);
|
||||
}
|
||||
|
||||
.profiles-access-detail h3 {
|
||||
margin: 0.8rem 0 0.6rem;
|
||||
color: #e8efff;
|
||||
font-size: 0.84rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.profiles-access-sections {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
||||
gap: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.profiles-access-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
color: #dfe7f7;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.profiles-access-libraries {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.profiles-access-libraries li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.profiles-access-libraries li.has-access {
|
||||
color: #dfe7f7;
|
||||
}
|
||||
|
||||
.profiles-access-libraries li.has-access > span:first-child {
|
||||
color: #68d391;
|
||||
}
|
||||
|
||||
.profiles-access-libraries li.no-access {
|
||||
color: #7d89a1;
|
||||
}
|
||||
|
||||
.profiles-access-libraries li.no-access > span:first-child {
|
||||
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) {
|
||||
.profiles-access-detail {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user