Added basic UI to display shared playlists, ref #391

This commit is contained in:
emeric
2024-12-18 20:20:39 +01:00
parent d49d718922
commit 5c73b5bb97
13 changed files with 154 additions and 48 deletions
+7
View File
@@ -38,6 +38,8 @@ namespace lms::db
template<typename ResultType>
Wt::Dbo::Query<ResultType> createQuery(Session& session, std::string_view itemToSelect, const TrackList::FindParameters& params)
{
assert(!params.user.isValid() || !params.excludedUser.isValid());
auto query{ session.getDboSession()->query<ResultType>("SELECT " + std::string{ itemToSelect } + " FROM tracklist t_l") };
if (!params.clusters.empty() || params.mediaLibrary.isValid())
@@ -46,6 +48,9 @@ namespace lms::db
query.groupBy("t_l.id");
}
for (std::string_view keyword : params.keywords)
query.where("t_l.name LIKE ? ESCAPE '" ESCAPE_CHAR_STR "'").bind("%" + utils::escapeLikeKeyword(keyword) + "%");
if (params.mediaLibrary.isValid())
query.join("track t ON t.id = t_l_e.track_id");
@@ -54,6 +59,8 @@ namespace lms::db
if (params.user.isValid())
query.where("t_l.user_id = ?").bind(params.user);
else if (params.excludedUser.isValid())
query.where("t_l.user_id <> ? OR t_l.user_id IS NULL").bind(params.excludedUser);
if (params.type)
query.where("t_l.type = ?").bind(*params.type);
@@ -62,10 +62,12 @@ namespace lms::db
// Search utility
struct FindParameters
{
std::vector<ClusterId> clusters; // if non empty, tracklists that have tracks that belong to these clusters
std::vector<ClusterId> clusters; // if non empty, tracklists that have tracks that belong to these clusters
std::vector<std::string_view> keywords; // if non empty, name must match all of these keywords (on either name field OR sort name field)
std::optional<Range> range;
std::optional<TrackListType> type;
UserId user; // only tracklists owned by this user
UserId excludedUser; // only tracklists *not* owned by this user
MediaLibraryId mediaLibrary; // only tracklists that have songs in this media library
TrackListSortMethod sortMethod{ TrackListSortMethod::None };
std::optional<Visibility> visibility;
@@ -75,6 +77,11 @@ namespace lms::db
clusters.assign(std::cbegin(_clusters), std::cend(_clusters));
return *this;
}
FindParameters& setKeywords(const std::vector<std::string_view>& _keywords)
{
keywords = _keywords;
return *this;
}
FindParameters& setRange(std::optional<Range> _range)
{
range = _range;
@@ -90,6 +97,12 @@ namespace lms::db
user = _user;
return *this;
}
FindParameters& setExcludedUser(UserId _user)
{
excludedUser = _user;
return *this;
}
FindParameters& setMediaLibrary(MediaLibraryId _mediaLibrary)
{
mediaLibrary = _mediaLibrary;