Hide header actions when signed out
This commit is contained in:
@@ -56,6 +56,9 @@ class QBittorrentClient(ApiClient):
|
||||
async def get_torrents_by_hashes(self, hashes: str) -> Optional[Any]:
|
||||
return await self._get("/api/v2/torrents/info", params={"hashes": hashes})
|
||||
|
||||
async def get_torrents_by_category(self, category: str) -> Optional[Any]:
|
||||
return await self._get("/api/v2/torrents/info", params={"category": category})
|
||||
|
||||
async def get_app_version(self) -> Optional[Any]:
|
||||
return await self._get_text("/api/v2/app/version")
|
||||
|
||||
|
||||
@@ -1591,7 +1591,7 @@ async def action_grab(
|
||||
if not qbit.configured():
|
||||
raise HTTPException(status_code=400, detail="qBittorrent not configured")
|
||||
try:
|
||||
await qbit.add_torrent_url(str(download_url))
|
||||
await qbit.add_torrent_url(str(download_url), category=f"magent-{request_id}")
|
||||
except httpx.HTTPStatusError as qbit_exc:
|
||||
raise HTTPException(status_code=502, detail=str(qbit_exc)) from qbit_exc
|
||||
await asyncio.to_thread(
|
||||
@@ -1625,7 +1625,7 @@ async def action_grab(
|
||||
if not qbit.configured():
|
||||
raise HTTPException(status_code=400, detail="qBittorrent not configured")
|
||||
try:
|
||||
await qbit.add_torrent_url(str(download_url))
|
||||
await qbit.add_torrent_url(str(download_url), category=f"magent-{request_id}")
|
||||
except httpx.HTTPStatusError as qbit_exc:
|
||||
raise HTTPException(status_code=502, detail=str(qbit_exc)) from qbit_exc
|
||||
await asyncio.to_thread(
|
||||
|
||||
@@ -465,9 +465,14 @@ async def build_snapshot(request_id: str) -> Snapshot:
|
||||
try:
|
||||
download_ids = _download_ids(_queue_records(arr_queue))
|
||||
torrent_list: List[Dict[str, Any]] = []
|
||||
if download_ids and qbittorrent.configured():
|
||||
torrents = await qbittorrent.get_torrents_by_hashes("|".join(download_ids))
|
||||
torrent_list = torrents if isinstance(torrents, list) else []
|
||||
if qbittorrent.configured():
|
||||
if download_ids:
|
||||
torrents = await qbittorrent.get_torrents_by_hashes("|".join(download_ids))
|
||||
torrent_list = torrents if isinstance(torrents, list) else []
|
||||
else:
|
||||
category = f"magent-{request_id}"
|
||||
torrents = await qbittorrent.get_torrents_by_category(category)
|
||||
torrent_list = torrents if isinstance(torrents, list) else []
|
||||
summary = _summarize_qbit(torrent_list)
|
||||
qbit_state = summary.get("state")
|
||||
qbit_message = summary.get("message")
|
||||
|
||||
@@ -40,19 +40,19 @@ export default function HeaderActions() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!signedIn) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="header-actions">
|
||||
<a href="/">Requests</a>
|
||||
<a href="/how-it-works">How it works</a>
|
||||
{signedIn && <a href="/profile">My profile</a>}
|
||||
<a href="/profile">My profile</a>
|
||||
{role === 'admin' && <a href="/admin">Settings</a>}
|
||||
{signedIn ? (
|
||||
<button type="button" className="header-link" onClick={signOut}>
|
||||
Sign out
|
||||
</button>
|
||||
) : (
|
||||
<a href="/login">Sign in</a>
|
||||
)}
|
||||
<button type="button" className="header-link" onClick={signOut}>
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user