Monitoring checkboxes target #feed-entries directly for instant refresh

This commit is contained in:
2026-07-06 16:00:02 +02:00
parent 3677d55183
commit ab9e686b9f
2 changed files with 13 additions and 11 deletions
@@ -97,7 +97,7 @@ public class ArtistController {
@PATCH @PATCH
@Path("/{mbid}/monitor") @Path("/{mbid}/monitor")
@Produces(MediaType.TEXT_HTML) @Produces(MediaType.TEXT_HTML)
public Response updateMonitoring( public TemplateInstance updateMonitoring(
@PathParam("mbid") String mbid, @PathParam("mbid") String mbid,
@QueryParam("type") String type) { @QueryParam("type") String type) {
var existing = artistService.findByMbid(mbid) var existing = artistService.findByMbid(mbid)
@@ -110,9 +110,11 @@ public class ArtistController {
type.equals("other") ? !existing.otherMonitored() : existing.otherMonitored() type.equals("other") ? !existing.otherMonitored() : existing.otherMonitored()
); );
artistService.updateMonitoring(mbid, flags); artistService.updateMonitoring(mbid, flags);
var allArtists = artistService.findAll(); var result = feedService.getFeedEntries(1);
var listHtml = artistListTemplate.data("artists", allArtists).render(); return feedEntriesTemplate
return Response.ok(listHtml + feedReloadScript()).build(); .data("entries", result.entries())
.data("hasMore", result.hasMore())
.data("nextPage", 2);
} }
@GET @GET
@@ -145,6 +147,6 @@ public class ArtistController {
} }
private String feedReloadScript() { private String feedReloadScript() {
return "<div hx-get=\"/api/artists/feed-table\" hx-trigger=\"load\" hx-target=\"#feed-entries\" hx-swap=\"innerHTML\"></div>"; return "<script>htmx.ajax('GET','/api/artists/feed-table',{target:'#feed-entries',swap:'innerHTML'})<\\/script>";
} }
} }
@@ -1,4 +1,4 @@
<div id="artist-list" hx-swap-oob="true"> <div id="artist-list">
{#if artists.isEmpty()} {#if artists.isEmpty()}
<div class="bg-base-200" style="border:1px solid var(--fallback-b3,oklch(var(--b3)/1));border-radius:0.5rem;padding:2.5rem;text-align:center"> <div class="bg-base-200" style="border:1px solid var(--fallback-b3,oklch(var(--b3)/1));border-radius:0.5rem;padding:2.5rem;text-align:center">
<svg class="icon-lg text-base-content/20" style="margin:0 auto 0.75rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"> <svg class="icon-lg text-base-content/20" style="margin:0 auto 0.75rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
@@ -34,7 +34,7 @@
<input type="checkbox" class="checkbox checkbox-xs checkbox-primary" <input type="checkbox" class="checkbox checkbox-xs checkbox-primary"
{#if artist.albumMonitored}checked{/if} {#if artist.albumMonitored}checked{/if}
hx-patch="/api/artists/{artist.mbid}/monitor?type=album" hx-patch="/api/artists/{artist.mbid}/monitor?type=album"
hx-target="#artist-list" hx-target="#feed-entries"
hx-swap="innerHTML"> hx-swap="innerHTML">
<span class="label-text text-xs" style="color:var(--p)">Album</span> <span class="label-text text-xs" style="color:var(--p)">Album</span>
</label> </label>
@@ -42,7 +42,7 @@
<input type="checkbox" class="checkbox checkbox-xs checkbox-secondary" <input type="checkbox" class="checkbox checkbox-xs checkbox-secondary"
{#if artist.singleMonitored}checked{/if} {#if artist.singleMonitored}checked{/if}
hx-patch="/api/artists/{artist.mbid}/monitor?type=single" hx-patch="/api/artists/{artist.mbid}/monitor?type=single"
hx-target="#artist-list" hx-target="#feed-entries"
hx-swap="innerHTML"> hx-swap="innerHTML">
<span class="label-text text-xs" style="color:var(--s)">Single</span> <span class="label-text text-xs" style="color:var(--s)">Single</span>
</label> </label>
@@ -50,7 +50,7 @@
<input type="checkbox" class="checkbox checkbox-xs checkbox-accent" <input type="checkbox" class="checkbox checkbox-xs checkbox-accent"
{#if artist.epMonitored}checked{/if} {#if artist.epMonitored}checked{/if}
hx-patch="/api/artists/{artist.mbid}/monitor?type=ep" hx-patch="/api/artists/{artist.mbid}/monitor?type=ep"
hx-target="#artist-list" hx-target="#feed-entries"
hx-swap="innerHTML"> hx-swap="innerHTML">
<span class="label-text text-xs" style="color:var(--a)">EP</span> <span class="label-text text-xs" style="color:var(--a)">EP</span>
</label> </label>
@@ -58,7 +58,7 @@
<input type="checkbox" class="checkbox checkbox-xs" <input type="checkbox" class="checkbox checkbox-xs"
{#if artist.broadcastMonitored}checked{/if} {#if artist.broadcastMonitored}checked{/if}
hx-patch="/api/artists/{artist.mbid}/monitor?type=broadcast" hx-patch="/api/artists/{artist.mbid}/monitor?type=broadcast"
hx-target="#artist-list" hx-target="#feed-entries"
hx-swap="innerHTML"> hx-swap="innerHTML">
<span class="label-text text-xs text-base-content/60">Broadcast</span> <span class="label-text text-xs text-base-content/60">Broadcast</span>
</label> </label>
@@ -66,7 +66,7 @@
<input type="checkbox" class="checkbox checkbox-xs" <input type="checkbox" class="checkbox checkbox-xs"
{#if artist.otherMonitored}checked{/if} {#if artist.otherMonitored}checked{/if}
hx-patch="/api/artists/{artist.mbid}/monitor?type=other" hx-patch="/api/artists/{artist.mbid}/monitor?type=other"
hx-target="#artist-list" hx-target="#feed-entries"
hx-swap="innerHTML"> hx-swap="innerHTML">
<span class="label-text text-xs text-base-content/60">Other</span> <span class="label-text text-xs text-base-content/60">Other</span>
</label> </label>