Made database scan work, added immediate scan option
This commit is contained in:
@@ -46,13 +46,13 @@ namespace skeletons {
|
||||
namespace UserInterface {
|
||||
|
||||
Wt::WApplication*
|
||||
LmsApplication::create(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool)
|
||||
LmsApplication::create(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool, Scanner::MediaScanner& scanner)
|
||||
{
|
||||
/*
|
||||
* You could read information from the environment to decide whether
|
||||
* the user has permission to start a new application
|
||||
*/
|
||||
return new LmsApplication(env, connectionPool);
|
||||
return new LmsApplication(env, connectionPool, scanner);
|
||||
}
|
||||
|
||||
LmsApplication*
|
||||
@@ -67,9 +67,10 @@ LmsApplication::instance()
|
||||
* constructor so it is typically also an argument for your custom
|
||||
* application constructor.
|
||||
*/
|
||||
LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool)
|
||||
LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool, Scanner::MediaScanner& scanner)
|
||||
: Wt::WApplication(env),
|
||||
_db(connectionPool),
|
||||
_scanner(scanner),
|
||||
_imageResource(nullptr),
|
||||
_transcodeResource(nullptr)
|
||||
{
|
||||
@@ -141,6 +142,11 @@ TranscodeResource* SessionTranscodeResource()
|
||||
return LmsApplication::instance()->getTranscodeResource();
|
||||
}
|
||||
|
||||
Scanner::MediaScanner& MediaScanner()
|
||||
{
|
||||
return LmsApplication::instance()->getMediaScanner();
|
||||
}
|
||||
|
||||
void
|
||||
LmsApplication::goHome()
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <Wt/Dbo/SqlConnectionPool>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "scanner/MediaScanner.hpp"
|
||||
|
||||
#include "resource/ImageResource.hpp"
|
||||
#include "resource/TranscodeResource.hpp"
|
||||
|
||||
@@ -34,26 +36,29 @@ namespace UserInterface {
|
||||
class LmsApplication : public Wt::WApplication
|
||||
{
|
||||
public:
|
||||
static Wt::WApplication *create(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool);
|
||||
static Wt::WApplication *create(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool, Scanner::MediaScanner& scanner);
|
||||
static LmsApplication* instance();
|
||||
|
||||
LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool);
|
||||
|
||||
// Session application data
|
||||
ImageResource* getImageResource() { return _imageResource; }
|
||||
TranscodeResource* getTranscodeResource() { return _transcodeResource; }
|
||||
Database::Handler& getDbHandler() { return _db;}
|
||||
|
||||
Scanner::MediaScanner& getMediaScanner() { return _scanner; }
|
||||
|
||||
// Utils
|
||||
void goHome();
|
||||
|
||||
private:
|
||||
|
||||
LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool, Scanner::MediaScanner& scanner);
|
||||
|
||||
void handleAuthEvent(void);
|
||||
void createFirstConnectionUI();
|
||||
void createLmsUI();
|
||||
|
||||
Database::Handler _db;
|
||||
Scanner::MediaScanner& _scanner;
|
||||
ImageResource* _imageResource;
|
||||
TranscodeResource* _transcodeResource;
|
||||
};
|
||||
@@ -70,6 +75,7 @@ Database::User::pointer CurrentUser();
|
||||
ImageResource *SessionImageResource();
|
||||
TranscodeResource *SessionTranscodeResource();
|
||||
|
||||
Scanner::MediaScanner& MediaScanner();
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -258,13 +258,19 @@ DatabaseView::DatabaseView(Wt::WContainerWidget *parent)
|
||||
|
||||
Wt::WPushButton *saveBtn = new Wt::WPushButton(Wt::WString::tr("msg-btn-apply"));
|
||||
bindWidget("apply-btn", saveBtn);
|
||||
saveBtn->setStyleClass("btn-primary");
|
||||
|
||||
Wt::WPushButton *discardBtn = new Wt::WPushButton(Wt::WString::tr("msg-btn-discard"));
|
||||
bindWidget("discard-btn", discardBtn);
|
||||
|
||||
Wt::WPushButton *immScanBtn = new Wt::WPushButton(Wt::WString::tr("msg-btn-immediate-scan"));
|
||||
bindWidget("immediate-scan-btn", immScanBtn);
|
||||
|
||||
saveBtn->clicked().connect(this, &DatabaseView::processSave);
|
||||
discardBtn->clicked().connect(this, &DatabaseView::processDiscard);
|
||||
immScanBtn->clicked().connect(std::bind([=] ()
|
||||
{
|
||||
MediaScanner().scheduleImmediateScan();
|
||||
}));
|
||||
|
||||
updateView(_model);
|
||||
}
|
||||
@@ -285,7 +291,7 @@ DatabaseView::processSave()
|
||||
if (_model->validate()) {
|
||||
_model->saveData();
|
||||
|
||||
// _sigChanged.emit();
|
||||
MediaScanner().reschedule();
|
||||
}
|
||||
// Udate the view: Delete any validation message in the view, etc.
|
||||
updateView(_model);
|
||||
|
||||
Reference in New Issue
Block a user