WIP. Reorganizing things to get settings work. First attempt on Database settings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <Wt/WBootstrapTheme>
|
||||
#include "LmsAuth.hpp"
|
||||
#include "auth/LmsAuth.hpp"
|
||||
#include "LmsHome.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
@@ -35,12 +35,10 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::p
|
||||
|
||||
_sessionData.getDatabaseHandler().getLogin().changed().connect(this, &LmsApplication::handleAuthEvent);
|
||||
|
||||
LmsAuth *authWidget = new LmsAuth(Database::Handler::getAuthService(),
|
||||
_sessionData.getDatabaseHandler().getUserDatabase(),
|
||||
_sessionData.getDatabaseHandler().getLogin());
|
||||
LmsAuth *authWidget = new LmsAuth(_sessionData.getDatabaseHandler());
|
||||
|
||||
authWidget->model()->addPasswordAuth(&Database::Handler::getPasswordService());
|
||||
authWidget->setRegistrationEnabled(true);
|
||||
authWidget->setRegistrationEnabled(false);
|
||||
|
||||
authWidget->processEnvironment();
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include <Wt/Auth/AuthService>
|
||||
#include <Wt/Auth/AbstractUserDatabase>
|
||||
#include <Wt/Auth/Login>
|
||||
#include <Wt/Auth/AuthWidget>
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class LmsAuth : public Wt::Auth::AuthWidget
|
||||
{
|
||||
public:
|
||||
|
||||
LmsAuth(const Wt::Auth::AuthService &baseAuth,
|
||||
Wt::Auth::AbstractUserDatabase &users,
|
||||
Wt::Auth::Login &login,
|
||||
Wt::WContainerWidget *parent=0)
|
||||
: Wt::Auth::AuthWidget(baseAuth, users, login, parent) {}
|
||||
|
||||
// LoggedInView is delegated to LmsHome
|
||||
void createLoggedInView () { hide();}
|
||||
|
||||
void createLoginView () { show(); Wt::Auth::AuthWidget::createLoginView();}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
+3
-2
@@ -5,6 +5,8 @@
|
||||
#include <Wt/WPopupMenuItem>
|
||||
#include <Wt/Auth/Identity>
|
||||
|
||||
#include "settings/Settings.hpp"
|
||||
|
||||
#include "LmsHome.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
@@ -31,6 +33,7 @@ LmsHome::LmsHome(SessionData& sessionData)
|
||||
|
||||
leftMenu->addItem("Audio", _audioWidget);
|
||||
leftMenu->addItem("Video", _videoWidget);
|
||||
leftMenu->addItem("Settings", new Settings::Settings(_sessionData));
|
||||
|
||||
// Setup a Right-aligned menu.
|
||||
Wt::WMenu *rightMenu = new Wt::WMenu();
|
||||
@@ -38,8 +41,6 @@ LmsHome::LmsHome(SessionData& sessionData)
|
||||
navigation->addMenu(rightMenu, Wt::AlignRight);
|
||||
|
||||
Wt::WPopupMenu *popup = new Wt::WPopupMenu();
|
||||
popup->addItem("Parameters");
|
||||
popup->addSeparator();
|
||||
popup->addItem("Logout");
|
||||
|
||||
popup->itemSelected().connect(this, &LmsHome::handleUserMenuSelected);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
#include "LmsAuth.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
LmsAuth::LmsAuth(Database::Handler& db)
|
||||
: Wt::Auth::AuthWidget(db.getAuthService(),
|
||||
db.getUserDatabase(),
|
||||
db.getLogin())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LmsAuth::createLoggedInView()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void
|
||||
LmsAuth::createLoginView()
|
||||
{
|
||||
show();
|
||||
Wt::Auth::AuthWidget::createLoginView();
|
||||
}
|
||||
|
||||
} // namespace UserInterface
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef UI_AUTH_HPP
|
||||
#define UI_AUTH_HPP
|
||||
|
||||
#include <Wt/Auth/AuthService>
|
||||
#include <Wt/Auth/AbstractUserDatabase>
|
||||
#include <Wt/Auth/Login>
|
||||
#include <Wt/Auth/AuthWidget>
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class LmsAuth : public Wt::Auth::AuthWidget
|
||||
{
|
||||
public:
|
||||
|
||||
LmsAuth(Database::Handler& db);
|
||||
|
||||
// LoggedInView is delegated to LmsHome
|
||||
void createLoggedInView () ;
|
||||
void createLoginView ();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "DirectoryValidator.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
DirectoryValidator::DirectoryValidator(bool mandatory, Wt::WObject *parent)
|
||||
: Wt::WValidator(mandatory, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Wt::WValidator::Result
|
||||
DirectoryValidator::validate(const Wt::WString& input) const
|
||||
{
|
||||
boost::filesystem::path p(input.toUTF8());
|
||||
boost::system::error_code ec;
|
||||
|
||||
bool res = boost::filesystem::is_directory(p, ec);
|
||||
if (ec)
|
||||
return Wt::WValidator::Result(Wt::WValidator::Invalid, ec.message());
|
||||
else if (res)
|
||||
return Wt::WValidator::Result(Wt::WValidator::Valid, "Valid");
|
||||
else
|
||||
return Wt::WValidator::Result(Wt::WValidator::Invalid, "Not a directory");
|
||||
}
|
||||
|
||||
|
||||
} // namespace UserInterface
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <Wt/WValidator>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class DirectoryValidator : public Wt::WValidator
|
||||
{
|
||||
public:
|
||||
DirectoryValidator(bool mandatory, Wt::WObject *parent = 0);
|
||||
|
||||
Wt::WValidator::Result validate(const Wt::WString& input) const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef UI_SESSION_DATA_HPP
|
||||
#define UI_SESSION_DATA_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
@@ -15,17 +13,12 @@ class SessionData
|
||||
|
||||
SessionData(boost::filesystem::path dbPath);
|
||||
|
||||
void setAuthenticatedUser(std::string user);
|
||||
|
||||
|
||||
Database::Handler& getDatabaseHandler() { return _db;}
|
||||
const Database::Handler& getDatabaseHandler() const { return _db;}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Database::Handler _db;
|
||||
std::string _authenticatedUser;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include <Wt/WMenu>
|
||||
#include <Wt/WStackedWidget>
|
||||
#include <Wt/WTextArea>
|
||||
|
||||
#include "SettingsDatabase.hpp"
|
||||
|
||||
#include "Settings.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Settings {
|
||||
|
||||
Settings::Settings(SessionData& sessionData, Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_sessionData(sessionData)
|
||||
{
|
||||
// Create a stack where the contents will be located.
|
||||
Wt::WStackedWidget *contents = new Wt::WStackedWidget();
|
||||
|
||||
Wt::WMenu *menu = new Wt::WMenu(contents, Wt::Vertical, this);
|
||||
menu->setStyleClass("nav nav-pills nav-stacked");
|
||||
menu->setWidth(150);
|
||||
|
||||
Wt::Dbo::Transaction transaction( sessionData.getDatabaseHandler().getSession());
|
||||
|
||||
::Database::User::pointer user = sessionData.getDatabaseHandler().getCurrentUser();
|
||||
|
||||
// Must be logged in here
|
||||
assert(user);
|
||||
|
||||
if (user->isAdmin())
|
||||
{
|
||||
// TODO Special admin settings
|
||||
menu->addItem("Database", new Database(sessionData));
|
||||
menu->addItem("Users", new Wt::WTextArea("Users here!"));
|
||||
}
|
||||
|
||||
// User specifics settings
|
||||
menu->addItem("Transcoding", new Wt::WTextArea("User's transcoding settings here!"));
|
||||
menu->addItem("Personal", new Wt::WTextArea("User's password + mail here!"));
|
||||
|
||||
addWidget(contents);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace UserInterface
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "common/SessionData.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Settings {
|
||||
|
||||
class Settings : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
Settings(SessionData& sessionData, Wt::WContainerWidget* parent = 0);
|
||||
|
||||
private:
|
||||
|
||||
SessionData& _sessionData;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace UserInterface
|
||||
@@ -0,0 +1,328 @@
|
||||
#include <map>
|
||||
|
||||
#include <Wt/WTable>
|
||||
#include <Wt/WGroupBox>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WString>
|
||||
#include <Wt/WPushButton>
|
||||
#include <Wt/WCheckBox>
|
||||
#include <Wt/WBreak>
|
||||
#include <Wt/WMessageBox>
|
||||
|
||||
#include "database/MediaDirectory.hpp"
|
||||
#include "service/ServiceManager.hpp"
|
||||
#include "service/DatabaseUpdateService.hpp"
|
||||
|
||||
#include "common/DirectoryValidator.hpp"
|
||||
|
||||
#include "SettingsDatabase.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Settings {
|
||||
|
||||
|
||||
Database::Database(SessionData& sessionData, Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_sessionData(sessionData)
|
||||
{
|
||||
|
||||
// Media directories
|
||||
{
|
||||
Wt::WGroupBox *container = new Wt::WGroupBox("Media directories", this);
|
||||
|
||||
_table = new Wt::WTable(container);
|
||||
|
||||
_table->addStyleClass("table form-inline");
|
||||
_table->toggleStyleClass("table-hover", true);
|
||||
_table->toggleStyleClass("table-striped", true);
|
||||
|
||||
_table->setHeaderCount(1);
|
||||
_table->elementAt(0, 0)->addWidget(new Wt::WText("Path"));
|
||||
_table->elementAt(0, 1)->addWidget(new Wt::WText("Status"));
|
||||
_table->elementAt(0, 2)->addWidget(new Wt::WText("Delete"));
|
||||
|
||||
{
|
||||
Wt::WPushButton* btn = new Wt::WPushButton("Add");
|
||||
container->addWidget(btn);
|
||||
btn->clicked().connect(this, &Database::handleAddDirectory);
|
||||
}
|
||||
{
|
||||
Wt::WPushButton* btn = new Wt::WPushButton("Delete");
|
||||
container->addWidget(btn);
|
||||
btn->clicked().connect(this, &Database::handleDelDirectory);
|
||||
}
|
||||
|
||||
}
|
||||
addWidget(new Wt::WBreak());
|
||||
|
||||
// Refresh settings
|
||||
{
|
||||
Wt::WGroupBox *container = new Wt::WGroupBox("Refresh settings", this);
|
||||
|
||||
Wt::WTable *table = new Wt::WTable(container);
|
||||
table->addStyleClass("table form-inline");
|
||||
|
||||
table->setHeaderCount(1, Wt::Vertical);
|
||||
std::size_t line = 0;
|
||||
table->elementAt(line, 0)->addWidget(new Wt::WText("Update period"));
|
||||
table->elementAt(line, 1)->addWidget(_updatePeriod = new Wt::WComboBox() );
|
||||
// Populate combo
|
||||
_updatePeriodModel = new Wt::WStringListModel(_updatePeriod);
|
||||
|
||||
_updatePeriodModel->addString("Never");
|
||||
_updatePeriodModel->setData(0, 0, boost::posix_time::time_duration( boost::posix_time::hours(0) ), Wt::UserRole);
|
||||
|
||||
_updatePeriodModel->addString("Daily");
|
||||
_updatePeriodModel->setData(1, 0, boost::posix_time::time_duration( boost::posix_time::hours(24) ), Wt::UserRole);
|
||||
|
||||
_updatePeriodModel->addString("Weekly");
|
||||
_updatePeriodModel->setData(2, 0, boost::posix_time::time_duration( boost::posix_time::hours(24*7) ), Wt::UserRole);
|
||||
|
||||
_updatePeriodModel->addString("Monthly");
|
||||
_updatePeriodModel->setData(3, 0, boost::posix_time::time_duration(boost::posix_time::hours(24*30) ), Wt::UserRole);
|
||||
|
||||
_updatePeriod->setModel(_updatePeriodModel);
|
||||
|
||||
line++;
|
||||
|
||||
table->elementAt(line, 0)->addWidget(new Wt::WText("Update start time"));
|
||||
table->elementAt(line, 1)->addWidget(_updateStartTime = new Wt::WComboBox( ));
|
||||
// populate combo
|
||||
_updateStartTimeModel = new Wt::WStringListModel(_updateStartTime);
|
||||
|
||||
for (std::size_t i = 0; i < 24; ++i)
|
||||
{
|
||||
boost::posix_time::time_duration dur = boost::posix_time::hours(i);
|
||||
|
||||
boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%H:%M");
|
||||
facet->time_duration_format("%H:%M");
|
||||
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale(oss.getloc(), facet));
|
||||
|
||||
oss << dur;
|
||||
|
||||
_updateStartTimeModel->addString( oss.str() );
|
||||
_updateStartTimeModel->setData(i, 0, dur, Wt::UserRole);
|
||||
}
|
||||
|
||||
_updateStartTime->setModel(_updateStartTimeModel);
|
||||
|
||||
line++;
|
||||
|
||||
Wt::WPushButton* btn = new Wt::WPushButton("Scan now", container);
|
||||
btn->clicked().connect(this, &Database::handleScanNow);
|
||||
}
|
||||
|
||||
addWidget(new Wt::WBreak());
|
||||
addWidget(new Wt::WBreak());
|
||||
{
|
||||
Wt::WPushButton* btn = new Wt::WPushButton("Apply", this);
|
||||
btn->clicked().connect(this, &Database::handleApply);
|
||||
}
|
||||
{
|
||||
Wt::WPushButton* btn = new Wt::WPushButton("Discard", this);
|
||||
btn->clicked().connect(this, &Database::loadSettings);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
void
|
||||
Database::addDirectory(const std::string& path)
|
||||
{
|
||||
int line = _table->rowCount();
|
||||
|
||||
Wt::WLineEdit* lineEdit = new Wt::WLineEdit( path );
|
||||
_table->elementAt(line, 0)->addWidget( lineEdit );
|
||||
|
||||
DirectoryValidator* validator = new DirectoryValidator(true);
|
||||
lineEdit->setValidator(validator);
|
||||
|
||||
std::string status;
|
||||
|
||||
if (!path.empty())
|
||||
status = validator->validate( path ).message().toUTF8();
|
||||
|
||||
Wt::WText* statusText = new Wt::WText( status );
|
||||
_table->elementAt(line, 1)->addWidget( statusText );
|
||||
_table->elementAt(line, 2)->addWidget( new Wt::WCheckBox() );
|
||||
|
||||
lineEdit->blurred().connect(boost::bind(&Database::handleCheckDirectory, this, lineEdit, statusText));
|
||||
}
|
||||
|
||||
void
|
||||
Database::loadSettings(void)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_sessionData.getDatabaseHandler().getSession());
|
||||
|
||||
// Get directories
|
||||
std::vector<::Database::MediaDirectory::pointer> directories = ::Database::MediaDirectory::getAll(_sessionData.getDatabaseHandler().getSession());
|
||||
|
||||
// delete rows
|
||||
assert(_table->rowCount() > 0 );
|
||||
for (int i = _table->rowCount() - 1; i > 0; --i)
|
||||
_table->deleteRow(i);
|
||||
|
||||
BOOST_FOREACH(::Database::MediaDirectory::pointer directory, directories)
|
||||
addDirectory( directory->getPath().string() );
|
||||
|
||||
// Get refresh settings
|
||||
::Database::MediaDirectorySettings::pointer settings = ::Database::MediaDirectorySettings::get(_sessionData.getDatabaseHandler().getSession());
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < _updatePeriodModel->rowCount(); ++i)
|
||||
{
|
||||
if (boost::any_cast<boost::posix_time::time_duration>
|
||||
(_updatePeriodModel->data(_updatePeriodModel->index(i, 0), Wt::UserRole))
|
||||
>= settings->getUpdatePeriod())
|
||||
break;
|
||||
}
|
||||
_updatePeriod->setCurrentIndex(i);
|
||||
}
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < _updateStartTimeModel->rowCount(); ++i)
|
||||
{
|
||||
if (boost::any_cast<boost::posix_time::time_duration>
|
||||
(_updateStartTimeModel->data(_updateStartTimeModel->index(i, 0), Wt::UserRole))
|
||||
>= settings->getUpdateStartTime())
|
||||
break;
|
||||
}
|
||||
_updateStartTime->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Database::handleAddDirectory(void)
|
||||
{
|
||||
// TODO check if the previous entry is empty too
|
||||
addDirectory();
|
||||
}
|
||||
|
||||
void
|
||||
Database::handleDelDirectory()
|
||||
{
|
||||
assert(_table->rowCount() > 0 );
|
||||
for (int i = _table->rowCount() - 1; i > 0; --i)
|
||||
{
|
||||
assert(_table->elementAt(i, 2)->count() == 1);
|
||||
Wt::WCheckBox *checkBox = dynamic_cast<Wt::WCheckBox*>(_table->elementAt(i, 2)->widget(0));
|
||||
|
||||
if (checkBox->checkState() == Wt::CheckState::Checked)
|
||||
_table->deleteRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Database::handleCheckDirectory(Wt::WLineEdit* edit, Wt::WText* status)
|
||||
{
|
||||
Wt::WValidator* validator = edit->validator();
|
||||
if (validator)
|
||||
status->setText( validator->validate( edit->text().toUTF8() ).message().toUTF8());
|
||||
}
|
||||
|
||||
bool
|
||||
Database::saveSettings(void)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_sessionData.getDatabaseHandler().getSession());
|
||||
|
||||
assert(_table->rowCount() > 0 );
|
||||
// Validate each directory in the table
|
||||
for (int i = 1; i < _table->rowCount(); ++i)
|
||||
{
|
||||
assert(_table->elementAt(i, 0)->count() == 1);
|
||||
|
||||
Wt::WLineEdit* lineEdit = dynamic_cast<Wt::WLineEdit*>(_table->elementAt(i, 0)->widget(0));
|
||||
if (!lineEdit->validate())
|
||||
return false;;
|
||||
|
||||
}
|
||||
|
||||
// erase all directories and add from the table
|
||||
::Database::MediaDirectory::eraseAll( _sessionData.getDatabaseHandler().getSession() );
|
||||
|
||||
for (int i = 1; i < _table->rowCount(); ++i)
|
||||
{
|
||||
Wt::WLineEdit* lineEdit = dynamic_cast<Wt::WLineEdit*>(_table->elementAt(i, 0)->widget(0));
|
||||
|
||||
::Database::MediaDirectory::create( _sessionData.getDatabaseHandler().getSession(), lineEdit->text().toUTF8(), ::Database::MediaDirectory::Audio);
|
||||
}
|
||||
|
||||
::Database::MediaDirectorySettings::pointer settings = ::Database::MediaDirectorySettings::get(_sessionData.getDatabaseHandler().getSession() );
|
||||
{
|
||||
int row = _updateStartTime->currentIndex();
|
||||
settings.modify()->setUpdateStartTime( boost::any_cast<boost::posix_time::time_duration>( _updateStartTimeModel->data(_updateStartTimeModel->index(row, 0), Wt::UserRole)));
|
||||
}
|
||||
{
|
||||
int row = _updatePeriod->currentIndex();
|
||||
settings.modify()->setUpdatePeriod( boost::any_cast<boost::posix_time::time_duration>( _updatePeriodModel->data(_updatePeriodModel->index(row, 0), Wt::UserRole)));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Database::handleApply(void)
|
||||
{
|
||||
if (saveSettings())
|
||||
{
|
||||
boost::lock_guard<boost::mutex> serviceLock (ServiceManager::instance().mutex());
|
||||
|
||||
DatabaseUpdateService::pointer service = ServiceManager::instance().getService<DatabaseUpdateService>();
|
||||
if (service)
|
||||
service->restart();
|
||||
|
||||
// Show a popup to say it's fine!
|
||||
Wt::WMessageBox *messageBox = new Wt::WMessageBox
|
||||
("Status",
|
||||
"New settings applied!",
|
||||
Wt::Information, Wt::Ok);
|
||||
|
||||
messageBox->setModal(true);
|
||||
|
||||
messageBox->buttonClicked().connect(std::bind([=] ()
|
||||
{
|
||||
delete messageBox;
|
||||
}
|
||||
));
|
||||
|
||||
messageBox->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Wt::WMessageBox *messageBox = new Wt::WMessageBox
|
||||
("Error",
|
||||
"Cannot apply settings",
|
||||
Wt::Critical, Wt::Ok);
|
||||
|
||||
messageBox->setModal(true);
|
||||
|
||||
messageBox->buttonClicked().connect(std::bind([=] ()
|
||||
{
|
||||
delete messageBox;
|
||||
}
|
||||
));
|
||||
|
||||
messageBox->show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Database::handleScanNow(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#ifndef UI_SETTINGS_DB_HPP
|
||||
#define UI_SETTINGS_DB_HPP
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WTable>
|
||||
#include <Wt/WComboBox>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WStringListModel>
|
||||
|
||||
#include "common/SessionData.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Settings {
|
||||
|
||||
class Database : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
Database(SessionData& sessionData, Wt::WContainerWidget *parent = 0);
|
||||
|
||||
private:
|
||||
void handleApply();
|
||||
|
||||
void handleCheckDirectory(Wt::WLineEdit* edit, Wt::WText* status);
|
||||
void handleAddDirectory();
|
||||
void handleDelDirectory();
|
||||
|
||||
void handleScanNow(void);
|
||||
|
||||
void loadSettings(void); // load from db
|
||||
bool saveSettings(void); // save into db
|
||||
|
||||
void addDirectory(const std::string& path = "");
|
||||
|
||||
SessionData& _sessionData;
|
||||
|
||||
Wt::WTable* _table;
|
||||
|
||||
Wt::WComboBox* _updatePeriod;
|
||||
Wt::WStringListModel* _updatePeriodModel;
|
||||
|
||||
Wt::WComboBox* _updateStartTime;
|
||||
Wt::WStringListModel* _updateStartTimeModel;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace UserInterface
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user