From 7246b7a9694cfa43be544ad3618ef7f72a35ca53 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Mon, 5 May 2025 12:19:44 +0200 Subject: [PATCH] feat: highlight the already requested entries, closes #5 --- src/app.py | 9 +++++++++ src/static/style.css | 13 +++++++++++++ src/templates/index.html | 12 +++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/app.py b/src/app.py index 11f2a9a..51efd62 100644 --- a/src/app.py +++ b/src/app.py @@ -70,6 +70,14 @@ async def fetch_data(data: Dict[str, Any]) -> List[Dict[str, Any]]: in_komga = komga.getSeries( manga.title.english if manga.title.english else manga.title.romaji ) + requested = cache.fetch_one( + query="SELECT manga_id, grabbed FROM manga_requests WHERE manga_id = ?", + args=(manga.id,), + ) + komga_request = False + if requested: + komga_request = True + results.append( { "id": manga.id, @@ -88,6 +96,7 @@ async def fetch_data(data: Dict[str, Any]) -> List[Dict[str, Any]]: else "No description available", "isAdult": manga.isAdult, "in_komga": in_komga, + "requested": komga_request, } ) diff --git a/src/static/style.css b/src/static/style.css index 4291f69..7ce6d90 100644 --- a/src/static/style.css +++ b/src/static/style.css @@ -167,6 +167,19 @@ body.nsfw-disabled .image-container.nsfw:hover img { } +.card.requested { + border: 3px solid orange; + box-sizing: border-box; + /* disable the request button for entries in Komga */ + /* only allow the info button to be clicked */ + opacity: 0.3; +} + +.card.manga.requested .request { + pointer-events: none; + opacity: 0.5; +} + .card.komga .request { pointer-events: none; opacity: 0.5; diff --git a/src/templates/index.html b/src/templates/index.html index 4086836..58f617e 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -51,7 +51,9 @@
{% for result in results %} -
+
+
Cover @@ -255,11 +257,11 @@ body: JSON.stringify(query) }) .then(res => res.json()) - .then(data => { + .then((data) => { displayResults(data); loadingElement.style.display = "none"; // Hide loading animation }) - .catch(err => { + .catch((err) => { console.error("Search failed", err); loadingElement.style.display = "none"; // Hide loading animation }); @@ -273,6 +275,7 @@ const card = document.createElement('div'); card.className = `card ${result.in_komga ? 'komga' : ''}`; card.className += ` ${result.type.toLowerCase()}`; + card.className += ` ${result.requested ? 'requested' : ''}`; const imageContainer = document.createElement('div'); imageContainer.className = `image-container ${result.isAdult ? 'nsfw' : ''}`; @@ -307,6 +310,9 @@ if (result.in_komga) { requestButton.disabled = true; } + if (result.requested) { + requestButton.disabled = true; + } actions.appendChild(infoButton); actions.appendChild(requestButton);