Build 2502262321: fix auto-search quality and per-user toggle
This commit is contained in:
@@ -24,6 +24,7 @@ type AdminUser = {
|
||||
auth_provider?: string | null
|
||||
last_login_at?: string | null
|
||||
is_blocked?: boolean
|
||||
auto_search_enabled?: boolean
|
||||
jellyseerr_user_id?: number | null
|
||||
}
|
||||
|
||||
@@ -130,6 +131,28 @@ export default function UserDetailPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const updateAutoSearchEnabled = async (enabled: boolean) => {
|
||||
if (!user) return
|
||||
try {
|
||||
const baseUrl = getApiBase()
|
||||
const response = await authFetch(
|
||||
`${baseUrl}/admin/users/${encodeURIComponent(user.username)}/auto-search`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ enabled }),
|
||||
}
|
||||
)
|
||||
if (!response.ok) {
|
||||
throw new Error('Update failed')
|
||||
}
|
||||
await loadUser()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
setError('Could not update auto search access.')
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!getToken()) {
|
||||
router.push('/login')
|
||||
@@ -178,6 +201,15 @@ export default function UserDetailPage() {
|
||||
/>
|
||||
<span>Make admin</span>
|
||||
</label>
|
||||
<label className="toggle">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={Boolean(user.auto_search_enabled ?? true)}
|
||||
disabled={user.role === 'admin'}
|
||||
onChange={(event) => updateAutoSearchEnabled(event.target.checked)}
|
||||
/>
|
||||
<span>Allow auto search/download</span>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="ghost-button"
|
||||
@@ -187,6 +219,11 @@ export default function UserDetailPage() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{user.role === 'admin' && (
|
||||
<div className="user-detail-meta">
|
||||
<span className="meta">Admins always have auto search/download access.</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="user-detail-grid">
|
||||
<div>
|
||||
<span className="label">Total</span>
|
||||
|
||||
Reference in New Issue
Block a user