added client side fetching for slow prowlarr sources request

This commit is contained in:
Markbeep
2025-04-12 19:12:35 +02:00
parent f6fc8b7628
commit 004e1ccda6
5 changed files with 84 additions and 26 deletions
+30 -8
View File
@@ -2,21 +2,43 @@
<title>Sources</title>
{% endblock %} {% block body %}
<div class="w-screen p-2 md:p-4 lg:p-8 flex flex-col gap-2">
<a preload href="/wishlist#{{ book.asin }}" class="w-fit btn btn-ghost">
<div class="w-screen p-2 md:p-4 lg:p-8 flex flex-col gap-2" id="sources">
<a
preload
href="/wishlist#{{ result.book.asin }}"
class="w-fit btn btn-ghost"
>
&lt; Back to wishlist
</a>
<h1 class="text-3xl font-bold">Sources for {{ book.title }}</h1>
{% if not sources %}
<h1 class="text-3xl font-bold">Sources for {{ result.book.title }}</h1>
{% if result.state.ok and not result.sources %}
<div role="alert" class="alert">
<span class="stroke-info h-6 w-6 shrink-0">
{% include 'icons/info-circle.html' %}
</span>
<span
>No results found for "{{ book.title }}" by {{book.authors|join(",")}}.
Might have to be looked up manually.</span
>No results found for "{{ result.book.title }}" by
{{result.book.authors|join(",")}}. Might have to be looked up
manually.</span
>
</div>
{% elif not result.ok %}
<div
role="alert"
class="alert"
hx-get="/wishlist/sources/{{ result.book.asin }}?only_body=true"
hx-trigger="load"
hx-target="#sources"
hx-swap="outerHTML"
>
<span class="stroke-info h-6 w-6 shrink-0">
{% include 'icons/info-circle.html' %}
</span>
<span
>Fetching sources from prowlarr
<span class="ml-2 loading loading-dots"></span>
</span>
</div>
{% endif %}
<div class="overflow-x-auto">
<table class="table table-zebra table-pin-rows min-w-[60rem]">
@@ -35,7 +57,7 @@
</tr>
</thead>
<tbody>
{% for source in sources %}
{% for source in (result.sources or []) %}
<tr
class="text-xs lg:text-sm {% if loop.index==1 %}bg-success dark:text-gray-700{% endif %}"
>
@@ -71,7 +93,7 @@
type="checkbox"
hx-trigger="click"
hx-target="this"
hx-post="/wishlist/sources/{{ book.asin }}"
hx-post="/wishlist/sources/{{ result.book.asin }}"
hx-include="#form-{{ loop.index }}"
hx-on::after-request="if (event.detail.successful) this.disabled = true"
/>