Adding tags in the releases view
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
<h4 class="media-heading">${release-name}</h4>
|
||||
${<if-has-artist>}${artist-name}${</if-has-artist>}
|
||||
</div>
|
||||
${clusters}
|
||||
${play-btn}${add-btn}
|
||||
</div>
|
||||
</message>
|
||||
|
||||
@@ -240,7 +240,7 @@ Release::getClusterGroups(std::vector<ClusterType::pointer> clusterTypes, std::s
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << "SELECT c from cluster c INNER JOIN track t ON c.id = t_c.cluster_id INNER JOIN track_cluster t_c ON t_c.track_id = t.id INNER JOIN cluster_type c_type ON c.cluster_type_id = c_type.id INNER JOIN release r ON t.release_id = r.id";
|
||||
oss << "SELECT c from cluster c INNER JOIN track t ON c.id = t_c.cluster_id INNER JOIN track_cluster t_c ON t_c.track_id = t.id INNER JOIN cluster_type c_type ON c.cluster_type_id = c_type.id INNER JOIN release r ON t.release_id = r.id ";
|
||||
|
||||
where.And(WhereClause("r.id = ?")).bind(std::to_string(self()->id()));
|
||||
{
|
||||
@@ -250,7 +250,7 @@ Release::getClusterGroups(std::vector<ClusterType::pointer> clusterTypes, std::s
|
||||
where.And(clusterClause);
|
||||
}
|
||||
oss << " " << where.get();
|
||||
oss << "GROUP BY c.id ORDER BY COUNT(c.id) DESC";
|
||||
oss << " GROUP BY c.id ORDER BY COUNT(c.id) DESC";
|
||||
|
||||
Wt::Dbo::Query<Cluster::pointer> query = session()->query<Cluster::pointer>( oss.str() );
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Release.hpp"
|
||||
#include "database/Setting.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
@@ -35,14 +36,43 @@
|
||||
#include "LmsApplication.hpp"
|
||||
#include "Filters.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
using namespace Database;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::string releasesClusterTypesSetting = "releases_cluster_types";
|
||||
const std::vector<std::string> defaultReleasesClusterTypes =
|
||||
{
|
||||
"GENRE",
|
||||
"ALBUMGROUPING",
|
||||
};
|
||||
|
||||
std::vector<ClusterType::pointer> getReleasesClusterTypes(Wt::Dbo::Session& session)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(session);
|
||||
|
||||
std::vector<ClusterType::pointer> res;
|
||||
for (auto clusterTypeName : splitString(Setting::getString(session, releasesClusterTypesSetting), " "))
|
||||
{
|
||||
auto clusterType = ClusterType::getByName(session, clusterTypeName);
|
||||
if (clusterType)
|
||||
res.push_back(clusterType);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
Releases::Releases(Filters* filters)
|
||||
: Wt::WTemplate(Wt::WString::tr("Lms.Explore.Releases.template")),
|
||||
_filters(filters)
|
||||
{
|
||||
if (!Setting::exists(LmsApp->getDboSession(), releasesClusterTypesSetting))
|
||||
Setting::setString(LmsApp->getDboSession(), releasesClusterTypesSetting, joinStrings(defaultReleasesClusterTypes, " "));
|
||||
|
||||
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
_search = bindNew<Wt::WLineEdit>("search");
|
||||
@@ -108,6 +138,25 @@ Releases::addSome()
|
||||
entry->bindWidget("artist-name", LmsApplication::createArtistAnchor(artists.front()));
|
||||
}
|
||||
|
||||
Wt::WContainerWidget* clusterContainers = entry->bindNew<Wt::WContainerWidget>("clusters");
|
||||
{
|
||||
auto clusterTypes = getReleasesClusterTypes(LmsApp->getDboSession());
|
||||
auto clusterGroups = release->getClusterGroups(clusterTypes, 1);
|
||||
|
||||
for (auto clusters : clusterGroups)
|
||||
{
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
auto clusterId = cluster.id();
|
||||
auto entry = clusterContainers->addWidget(LmsApp->createCluster(cluster));
|
||||
entry->clicked().connect([=]
|
||||
{
|
||||
_filters->add(clusterId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Releases.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user