Added a notify system
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user