diff --git a/approot/messages.xml b/approot/messages.xml index 1ebc8dcf..14e4bc54 100644 --- a/approot/messages.xml +++ b/approot/messages.xml @@ -23,6 +23,7 @@ Media root directory Update period Update start time +Update start time Never Daily Weekly @@ -31,5 +32,8 @@ Apply Discard Scan now! +Scan launched! +New settings saved! +Scan finished, {1} imported file(s), {2} removed file(s)! diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index 2b0d4baa..496df353 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -318,6 +318,21 @@ LmsApplication::handleAuthEvent(void) auto player = new MediaPlayer(); main->bindWidget("player", player); + // Events from MediaScanner + // TODO: only if admin + enableUpdates(true); + std::string sessionId = this->sessionId(); + _scanner.scanComplete().connect(std::bind([=] (Scanner::MediaScanner::Stats stats) + { + Wt::WServer::instance()->post(sessionId, [=] + { + notify(Wt::WString::tr("msg-notify-scan-complete").arg(stats.nbAdded).arg(stats.nbRemoved)); + triggerUpdate(); + }); +// notify("TEST"); + }, std::placeholders::_1)); + + internalPathChanged().connect(std::bind([=] { handlePathChange(mainStack); @@ -326,6 +341,18 @@ LmsApplication::handleAuthEvent(void) handlePathChange(mainStack); } +void +LmsApplication::notify(const Wt::WString& message) +{ + LMS_LOG(UI, INFO) << "Notifying message '" << message.toUTF8() << "'"; + root()->addWidget(new Wt::WText(message)); +} + +void notify(const Wt::WString& message) +{ + LmsApplication::instance()->notify(message); +} + } // namespace UserInterface diff --git a/src/ui/LmsApplication.hpp b/src/ui/LmsApplication.hpp index e36fcbee..f3e4dd2b 100644 --- a/src/ui/LmsApplication.hpp +++ b/src/ui/LmsApplication.hpp @@ -48,6 +48,7 @@ class LmsApplication : public Wt::WApplication // Utils void goHome(); + void notify(const Wt::WString& message); private: @@ -77,6 +78,9 @@ TranscodeResource *SessionTranscodeResource(); Scanner::MediaScanner& MediaScanner(); +void notify(const Wt::WString& message); + + } // namespace UserInterface #endif diff --git a/src/ui/settings/DatabaseView.cpp b/src/ui/settings/DatabaseView.cpp index 712794c8..05dad344 100644 --- a/src/ui/settings/DatabaseView.cpp +++ b/src/ui/settings/DatabaseView.cpp @@ -270,6 +270,8 @@ DatabaseView::DatabaseView(Wt::WContainerWidget *parent) immScanBtn->clicked().connect(std::bind([=] () { MediaScanner().scheduleImmediateScan(); + + notify(Wt::WString::tr("msg-notify-scan-launched")); })); updateView(_model); @@ -288,11 +290,15 @@ DatabaseView::processSave() { updateModel(_model); - if (_model->validate()) { + if (_model->validate()) + { _model->saveData(); MediaScanner().reschedule(); + + notify(Wt::WString::tr("msg-notify-settings-saved")); } + // Udate the view: Delete any validation message in the view, etc. updateView(_model); }