Added an option ui-allow-downloads in lms.conf to enable/disable downloads, fixes #776
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
${<if-has-mbid>}
|
||||
<li><a href="${mbid-link}" target="_blank" class="dropdown-item">${tr:Lms.Explore.musicbrainz-artist}</a></li>
|
||||
${</if-has-mbid>}
|
||||
${<if-has-download>}
|
||||
<li>${download class="dropdown-item"}</li>
|
||||
${</if-has-download>}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -65,7 +65,9 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="${id:more-btn}">
|
||||
<li>${play class="dropdown-item"}</li>
|
||||
<li>${star class="dropdown-item"}</li>
|
||||
${<if-has-download>}
|
||||
<li>${download class="dropdown-item"}</li>
|
||||
${</if-has-download>}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
${<if-has-mbid>}
|
||||
<li><a href="${mbid-link}" target="_blank" class="dropdown-item">${tr:Lms.Explore.musicbrainz-release}</a></li>
|
||||
${</if-has-mbid>}
|
||||
${<if-has-download>}
|
||||
<li>${download class="dropdown-item"}</li>
|
||||
${</if-has-download>}
|
||||
<li>${release-info class="dropdown-item"}</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -109,7 +111,9 @@
|
||||
<li>${play-next class="dropdown-item"}</li>
|
||||
<li>${play-last class="dropdown-item"}</li>
|
||||
<li>${star class="dropdown-item"}</li>
|
||||
${<if-has-download>}
|
||||
<li>${download class="dropdown-item"}</li>
|
||||
${</if-has-download>}
|
||||
<li>${track-info class="dropdown-item"}</li>
|
||||
${<if-has-lyrics>}<li>${track-lyrics class="dropdown-item"}</li>${</if-has-lyrics>}
|
||||
</ul>
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li>${play-shuffled class="dropdown-item"}</li>
|
||||
<li>${play-last class="dropdown-item"}</li>
|
||||
${<if-has-download>}
|
||||
<li>${download class="dropdown-item"}</li>
|
||||
${</if-has-download>}
|
||||
${<if-has-delete>}
|
||||
<li>${delete class="dropdown-item"}</li>
|
||||
${</if-has-delete>}
|
||||
|
||||
@@ -59,7 +59,9 @@
|
||||
<li>${play-next class="dropdown-item"}</li>
|
||||
<li>${play-last class="dropdown-item"}</li>
|
||||
<li>${star class="dropdown-item"}</li>
|
||||
${<if-has-download>}
|
||||
<li>${download class="dropdown-item"}</li>
|
||||
${</if-has-download>}
|
||||
<li>${track-info class="dropdown-item"}</li>
|
||||
${<if-has-lyrics>}<li>${track-lyrics class="dropdown-item"}</li>${</if-has-lyrics>}
|
||||
</ul>
|
||||
|
||||
+6
-3
@@ -113,9 +113,6 @@ artist-image-file-names = ("artist");
|
||||
# Note: files named after the disc itself are always searched before the names in this list.
|
||||
medium-image-file-names = ("discsubtitle");
|
||||
|
||||
# Playqueue max entry count
|
||||
playqueue-max-entry-count = 1000;
|
||||
|
||||
# Internal tracing for profiling purposes. Enable only if necessary, as it incurs some runtime overhead!
|
||||
# Possible values are "disabled", "overview" or "detailed".
|
||||
# If enabled, data has to be dumped in the tracing view located in the admin menu
|
||||
@@ -140,3 +137,9 @@ podcast-auto-download-episodes = true;
|
||||
|
||||
# Max age in days for auto-downloaded episodes before deletion
|
||||
podcast-auto-download-episodes-max-age-days = 30;
|
||||
|
||||
# Playqueue max entry count
|
||||
ui-playqueue-max-entry-count = 1000;
|
||||
|
||||
# Allow downloads
|
||||
ui-allow-downloads = true;
|
||||
@@ -26,9 +26,11 @@
|
||||
#include <Wt/WServer.h>
|
||||
#include <Wt/WStackedWidget.h>
|
||||
|
||||
#include "core/IConfig.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
#include "core/Service.hpp"
|
||||
|
||||
#include "database/IDb.hpp"
|
||||
#include "database/IQueryPlanRecorder.hpp"
|
||||
#include "database/Session.hpp"
|
||||
@@ -198,6 +200,31 @@ namespace lms::ui
|
||||
return static_cast<LmsApplication*>(Wt::WApplication::instance());
|
||||
}
|
||||
|
||||
LmsApplication::LmsApplication(const Wt::WEnvironment& env, db::IDb& db, LmsApplicationManager& appManager, AuthenticationBackend authBackend)
|
||||
: Wt::WApplication{ env }
|
||||
, _db{ db }
|
||||
, _appManager{ appManager }
|
||||
, _authBackend{ authBackend }
|
||||
, _areDownloadsEnabled(core::Service<core::IConfig>::get()->getBool("ui-allow-downloads", true))
|
||||
{
|
||||
try
|
||||
{
|
||||
init();
|
||||
}
|
||||
catch (LmsApplicationException& e)
|
||||
{
|
||||
LMS_LOG(UI, WARNING, "Caught a LmsApplication exception: " << e.what());
|
||||
handleException(e);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LMS_LOG(UI, ERROR, "Caught exception: " << e.what());
|
||||
throw core::LmsException{ "Internal error" }; // Do not put details here at it may appear on the user rendered html
|
||||
}
|
||||
}
|
||||
|
||||
LmsApplication::~LmsApplication() = default;
|
||||
|
||||
db::IDb& LmsApplication::getDb()
|
||||
{
|
||||
return _db;
|
||||
@@ -240,29 +267,10 @@ namespace lms::ui
|
||||
return _user->userLoginName;
|
||||
}
|
||||
|
||||
LmsApplication::LmsApplication(const Wt::WEnvironment& env, db::IDb& db, LmsApplicationManager& appManager, AuthenticationBackend authBackend)
|
||||
: Wt::WApplication{ env }
|
||||
, _db{ db }
|
||||
, _appManager{ appManager }
|
||||
, _authBackend{ authBackend }
|
||||
bool LmsApplication::areDownloadsEnabled() const
|
||||
{
|
||||
try
|
||||
{
|
||||
init();
|
||||
return _areDownloadsEnabled;
|
||||
}
|
||||
catch (LmsApplicationException& e)
|
||||
{
|
||||
LMS_LOG(UI, WARNING, "Caught a LmsApplication exception: " << e.what());
|
||||
handleException(e);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LMS_LOG(UI, ERROR, "Caught exception: " << e.what());
|
||||
throw core::LmsException{ "Internal error" }; // Do not put details here at it may appear on the user rendered html
|
||||
}
|
||||
}
|
||||
|
||||
LmsApplication::~LmsApplication() = default;
|
||||
|
||||
void LmsApplication::init()
|
||||
{
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace lms::ui
|
||||
db::UserType getUserType() const; // user must be logged in prior this call
|
||||
std::string_view getUserLoginName() const; // user must be logged in prior this call
|
||||
|
||||
bool areDownloadsEnabled() const;
|
||||
|
||||
// Proxified scanner events
|
||||
scanner::Events& getScannerEvents() { return _scannerEvents; }
|
||||
|
||||
@@ -109,6 +111,7 @@ namespace lms::ui
|
||||
Wt::Signal<> _preQuit;
|
||||
LmsApplicationManager& _appManager;
|
||||
const AuthenticationBackend _authBackend;
|
||||
const bool _areDownloadsEnabled;
|
||||
scanner::Events _scannerEvents;
|
||||
struct UserAuthInfo
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace lms::ui
|
||||
|
||||
PlayQueue::PlayQueue()
|
||||
: Template{ Wt::WString::tr("Lms.PlayQueue.template") }
|
||||
, _capacity{ core::Service<core::IConfig>::get()->getULong("playqueue-max-entry-count", 1000) }
|
||||
, _capacity{ core::Service<core::IConfig>::get()->getULong("ui-playqueue-max-entry-count", 1000) }
|
||||
{
|
||||
initTrackLists();
|
||||
|
||||
@@ -578,9 +578,13 @@ namespace lms::ui
|
||||
}
|
||||
});
|
||||
|
||||
if (LmsApp->areDownloadsEnabled())
|
||||
{
|
||||
entry->setCondition("if-has-download", true);
|
||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) });
|
||||
}
|
||||
}
|
||||
|
||||
void PlayQueue::enqueueRadioTracksIfNeeded()
|
||||
{
|
||||
|
||||
@@ -168,8 +168,13 @@ namespace lms::ui
|
||||
.connect([this] {
|
||||
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _artistId });
|
||||
});
|
||||
|
||||
if (LmsApp->areDownloadsEnabled())
|
||||
{
|
||||
setCondition("if-has-download", true);
|
||||
bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink{ std::make_unique<DownloadArtistResource>(_artistId) });
|
||||
}
|
||||
|
||||
{
|
||||
auto isStarred{ [this] { return core::Service<feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), _artistId); } };
|
||||
|
||||
@@ -359,8 +359,12 @@ namespace lms::ui
|
||||
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _releaseId });
|
||||
});
|
||||
|
||||
if (LmsApp->areDownloadsEnabled())
|
||||
{
|
||||
setCondition("if-has-download", true);
|
||||
bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink{ std::make_unique<DownloadReleaseResource>(_releaseId) });
|
||||
}
|
||||
|
||||
bindNew<Wt::WPushButton>("release-info", Wt::WString::tr("Lms.Explore.release-info"))
|
||||
->clicked()
|
||||
@@ -527,8 +531,12 @@ namespace lms::ui
|
||||
starBtn->clicked().connect([=] { toggle(); });
|
||||
}
|
||||
|
||||
if (LmsApp->areDownloadsEnabled())
|
||||
{
|
||||
entry->setCondition("if-has-download", true);
|
||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) });
|
||||
}
|
||||
|
||||
entry->bindNew<Wt::WPushButton>("track-info", Wt::WString::tr("Lms.Explore.track-info"))
|
||||
->clicked()
|
||||
|
||||
@@ -299,8 +299,12 @@ namespace lms::ui::TrackListHelpers
|
||||
starBtn->clicked().connect([=] { toggle(); });
|
||||
}
|
||||
|
||||
if (LmsApp->areDownloadsEnabled())
|
||||
{
|
||||
entry->setCondition("if-has-download", true);
|
||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) });
|
||||
}
|
||||
|
||||
entry->bindNew<Wt::WPushButton>("track-info", Wt::WString::tr("Lms.Explore.track-info"))
|
||||
->clicked()
|
||||
|
||||
@@ -135,8 +135,12 @@ namespace lms::ui
|
||||
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, *trackListId);
|
||||
});
|
||||
|
||||
if (LmsApp->areDownloadsEnabled())
|
||||
{
|
||||
setCondition("if-has-download", true);
|
||||
bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink{ std::make_unique<DownloadTrackListResource>(*trackListId) });
|
||||
}
|
||||
|
||||
if (trackList->getUserId() == LmsApp->getUserId())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user