From d7d68b9ab0130b1473f53433de8d3a88f9f01bfc Mon Sep 17 00:00:00 2001 From: droideparanoico Date: Wed, 15 Jul 2026 10:46:22 +0200 Subject: [PATCH] Static path, search dropdown, async follow --- .../io/discdrop/persistence/AppSetting.java | 4 ++- .../io/discdrop/resource/ArtistResource.java | 22 +++++++----- .../io/discdrop/resource/PageResource.java | 4 ++- .../io/discdrop/service/SettingsService.java | 3 ++ .../resources/META-INF/resources/css/app.css | 12 +++++++ .../resources}/img/favicon.svg | 0 .../resources}/img/logo.svg | 0 .../resources}/img/no-cover.svg | 0 .../{static => META-INF/resources}/js/app.js | 0 src/main/resources/static/css/app.css | 3 -- src/main/resources/templates/artists.html | 8 ++--- .../templates/fragments/feed-list.html | 7 ++++ .../templates/fragments/feed-row.html | 2 +- src/main/resources/templates/index.html | 35 +++++++++---------- 14 files changed, 64 insertions(+), 36 deletions(-) create mode 100644 src/main/resources/META-INF/resources/css/app.css rename src/main/resources/{static => META-INF/resources}/img/favicon.svg (100%) rename src/main/resources/{static => META-INF/resources}/img/logo.svg (100%) rename src/main/resources/{static => META-INF/resources}/img/no-cover.svg (100%) rename src/main/resources/{static => META-INF/resources}/js/app.js (100%) delete mode 100644 src/main/resources/static/css/app.css diff --git a/src/main/java/io/discdrop/persistence/AppSetting.java b/src/main/java/io/discdrop/persistence/AppSetting.java index ee8a5a9..b93d93e 100644 --- a/src/main/java/io/discdrop/persistence/AppSetting.java +++ b/src/main/java/io/discdrop/persistence/AppSetting.java @@ -29,8 +29,10 @@ public class AppSetting extends PanacheEntity { if (s == null) { s = new AppSetting(); s.key = key; + s.value = value; s.persist(); + } else { + s.value = value; } - s.value = value; } } diff --git a/src/main/java/io/discdrop/resource/ArtistResource.java b/src/main/java/io/discdrop/resource/ArtistResource.java index 148a17c..297b3c6 100644 --- a/src/main/java/io/discdrop/resource/ArtistResource.java +++ b/src/main/java/io/discdrop/resource/ArtistResource.java @@ -19,6 +19,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import java.util.List; +import java.util.concurrent.CompletableFuture; @Path("/artists") public class ArtistResource { @@ -36,6 +37,10 @@ public class ArtistResource { @Location("fragments/feed-list.html") Template fragments_feed_list; + @Inject + @Location("fragments/feed-row.html") + Template fragments_feed_row; + @Inject @Location("fragments/artist-row.html") Template fragments_artist_row; @@ -61,16 +66,16 @@ public class ArtistResource { dto.area = new ArtistSearchResult.ArtistDto.Area(); dto.area.name = area; } - FollowedArtist artist = artistService.follow(dto); - syncService.syncArtist(artist.mbid); - return feedFragment(0); + artistService.follow(dto); + CompletableFuture.runAsync(() -> syncService.syncArtist(mbid)); + return feedFragment(0, true); } @DELETE @Path("/{mbid}") public TemplateInstance unfollow(@PathParam("mbid") String mbid) { artistService.unfollow(mbid); - return feedFragment(0); + return feedFragment(0, false); } @GET @@ -96,12 +101,12 @@ public class ArtistResource { FollowedArtist artist = artistService.findArtist(mbid); if (artist != null) { artistService.setTypeEnabled(artist, primaryType, enabled); - syncService.resyncArtist(mbid); + CompletableFuture.runAsync(() -> syncService.resyncArtist(mbid)); } - return feedFragment(0); + return feedFragment(0, true); } - private TemplateInstance feedFragment(int offset) { + private TemplateInstance feedFragment(int offset, boolean autoRefresh) { if (offset < 0) { offset = 0; } @@ -111,6 +116,7 @@ public class ArtistResource { return fragments_feed_list.data("rows", rows) .data("nextOffset", nextOffset) .data("hasMore", hasMore) - .data("pageSize", feedService.pageSize()); + .data("pageSize", feedService.pageSize()) + .data("autoRefresh", autoRefresh); } } diff --git a/src/main/java/io/discdrop/resource/PageResource.java b/src/main/java/io/discdrop/resource/PageResource.java index 686d43a..cf227fa 100644 --- a/src/main/java/io/discdrop/resource/PageResource.java +++ b/src/main/java/io/discdrop/resource/PageResource.java @@ -40,7 +40,8 @@ public class PageResource { return fragments_feed_list.data("rows", rows) .data("nextOffset", nextOffset) .data("hasMore", hasMore) - .data("pageSize", feedService.pageSize()); + .data("pageSize", feedService.pageSize()) + .data("autoRefresh", false); } @GET @@ -52,6 +53,7 @@ public class PageResource { .data("nextOffset", rows.size()) .data("hasMore", hasMore) .data("pageSize", feedService.pageSize()) + .data("autoRefresh", false) .data("followedCount", FollowedArtist.count()) .data("feedCount", ReleaseGroupEntity.count()); } diff --git a/src/main/java/io/discdrop/service/SettingsService.java b/src/main/java/io/discdrop/service/SettingsService.java index 5a4e38e..a12ac77 100644 --- a/src/main/java/io/discdrop/service/SettingsService.java +++ b/src/main/java/io/discdrop/service/SettingsService.java @@ -2,6 +2,7 @@ package io.discdrop.service; import io.discdrop.persistence.AppSetting; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.transaction.Transactional; import java.util.Arrays; import java.util.LinkedHashSet; @@ -22,6 +23,7 @@ public class SettingsService { return parseTypes(raw); } + @Transactional public void setDefaultPrimaryTypes(Set types) { AppSetting.set(KEY_DEFAULT_PRIMARY_TYPES, String.join(",", types)); } @@ -35,6 +37,7 @@ public class SettingsService { } } + @Transactional public void setSyncScheduleHours(int hours) { AppSetting.set(KEY_SYNC_SCHEDULE_HOURS, String.valueOf(hours)); } diff --git a/src/main/resources/META-INF/resources/css/app.css b/src/main/resources/META-INF/resources/css/app.css new file mode 100644 index 0000000..2606cb4 --- /dev/null +++ b/src/main/resources/META-INF/resources/css/app.css @@ -0,0 +1,12 @@ +/* DiscDrop custom styles */ +html { scroll-behavior: smooth; } + +/* Hide empty search dropdown */ +#search-dropdown:empty { display: none; } + +/* Remove native search input artifacts */ +input[type="text"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; + appearance: none; +} diff --git a/src/main/resources/static/img/favicon.svg b/src/main/resources/META-INF/resources/img/favicon.svg similarity index 100% rename from src/main/resources/static/img/favicon.svg rename to src/main/resources/META-INF/resources/img/favicon.svg diff --git a/src/main/resources/static/img/logo.svg b/src/main/resources/META-INF/resources/img/logo.svg similarity index 100% rename from src/main/resources/static/img/logo.svg rename to src/main/resources/META-INF/resources/img/logo.svg diff --git a/src/main/resources/static/img/no-cover.svg b/src/main/resources/META-INF/resources/img/no-cover.svg similarity index 100% rename from src/main/resources/static/img/no-cover.svg rename to src/main/resources/META-INF/resources/img/no-cover.svg diff --git a/src/main/resources/static/js/app.js b/src/main/resources/META-INF/resources/js/app.js similarity index 100% rename from src/main/resources/static/js/app.js rename to src/main/resources/META-INF/resources/js/app.js diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css deleted file mode 100644 index 0f2d769..0000000 --- a/src/main/resources/static/css/app.css +++ /dev/null @@ -1,3 +0,0 @@ -/* DiscDrop custom styles */ -html { scroll-behavior: smooth; } -#search-dropdown:empty { display: none; } diff --git a/src/main/resources/templates/artists.html b/src/main/resources/templates/artists.html index ea74d84..267ae33 100644 --- a/src/main/resources/templates/artists.html +++ b/src/main/resources/templates/artists.html @@ -4,18 +4,18 @@ DiscDrop – Artists - + - - + +