Monitoring checkboxes target #feed-entries directly for instant refresh
This commit is contained in:
@@ -97,7 +97,7 @@ public class ArtistController {
|
||||
@PATCH
|
||||
@Path("/{mbid}/monitor")
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
public Response updateMonitoring(
|
||||
public TemplateInstance updateMonitoring(
|
||||
@PathParam("mbid") String mbid,
|
||||
@QueryParam("type") String type) {
|
||||
var existing = artistService.findByMbid(mbid)
|
||||
@@ -110,9 +110,11 @@ public class ArtistController {
|
||||
type.equals("other") ? !existing.otherMonitored() : existing.otherMonitored()
|
||||
);
|
||||
artistService.updateMonitoring(mbid, flags);
|
||||
var allArtists = artistService.findAll();
|
||||
var listHtml = artistListTemplate.data("artists", allArtists).render();
|
||||
return Response.ok(listHtml + feedReloadScript()).build();
|
||||
var result = feedService.getFeedEntries(1);
|
||||
return feedEntriesTemplate
|
||||
.data("entries", result.entries())
|
||||
.data("hasMore", result.hasMore())
|
||||
.data("nextPage", 2);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -145,6 +147,6 @@ public class ArtistController {
|
||||
}
|
||||
|
||||
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()}
|
||||
<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">
|
||||
@@ -34,7 +34,7 @@
|
||||
<input type="checkbox" class="checkbox checkbox-xs checkbox-primary"
|
||||
{#if artist.albumMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=album"
|
||||
hx-target="#artist-list"
|
||||
hx-target="#feed-entries"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs" style="color:var(--p)">Album</span>
|
||||
</label>
|
||||
@@ -42,7 +42,7 @@
|
||||
<input type="checkbox" class="checkbox checkbox-xs checkbox-secondary"
|
||||
{#if artist.singleMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=single"
|
||||
hx-target="#artist-list"
|
||||
hx-target="#feed-entries"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs" style="color:var(--s)">Single</span>
|
||||
</label>
|
||||
@@ -50,7 +50,7 @@
|
||||
<input type="checkbox" class="checkbox checkbox-xs checkbox-accent"
|
||||
{#if artist.epMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=ep"
|
||||
hx-target="#artist-list"
|
||||
hx-target="#feed-entries"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs" style="color:var(--a)">EP</span>
|
||||
</label>
|
||||
@@ -58,7 +58,7 @@
|
||||
<input type="checkbox" class="checkbox checkbox-xs"
|
||||
{#if artist.broadcastMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=broadcast"
|
||||
hx-target="#artist-list"
|
||||
hx-target="#feed-entries"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs text-base-content/60">Broadcast</span>
|
||||
</label>
|
||||
@@ -66,7 +66,7 @@
|
||||
<input type="checkbox" class="checkbox checkbox-xs"
|
||||
{#if artist.otherMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=other"
|
||||
hx-target="#artist-list"
|
||||
hx-target="#feed-entries"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs text-base-content/60">Other</span>
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user