WIP. new layout on the audio view
This commit is contained in:
@@ -41,7 +41,6 @@ lms_SOURCES = \
|
|||||||
$(srcdir)/transcode/Parameters.cpp \
|
$(srcdir)/transcode/Parameters.cpp \
|
||||||
$(srcdir)/transcode/InputMediaFile.cpp \
|
$(srcdir)/transcode/InputMediaFile.cpp \
|
||||||
$(srcdir)/ui/LmsApplication.cpp \
|
$(srcdir)/ui/LmsApplication.cpp \
|
||||||
$(srcdir)/ui/LmsHome.cpp \
|
|
||||||
$(srcdir)/ui/auth/LmsAuth.cpp \
|
$(srcdir)/ui/auth/LmsAuth.cpp \
|
||||||
$(srcdir)/ui/audio/AudioWidget.cpp \
|
$(srcdir)/ui/audio/AudioWidget.cpp \
|
||||||
$(srcdir)/ui/audio/AudioMediaPlayerWidget.cpp \
|
$(srcdir)/ui/audio/AudioMediaPlayerWidget.cpp \
|
||||||
|
|||||||
+93
-39
@@ -27,18 +27,20 @@
|
|||||||
#include <Wt/WPopupMenu>
|
#include <Wt/WPopupMenu>
|
||||||
#include <Wt/WPopupMenuItem>
|
#include <Wt/WPopupMenuItem>
|
||||||
#include <Wt/WVBoxLayout>
|
#include <Wt/WVBoxLayout>
|
||||||
|
#include <Wt/WLineEdit>
|
||||||
#include <Wt/Auth/Identity>
|
#include <Wt/Auth/Identity>
|
||||||
|
|
||||||
#include "settings/Settings.hpp"
|
#include "settings/Settings.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include "auth/LmsAuth.hpp"
|
#include "auth/LmsAuth.hpp"
|
||||||
|
|
||||||
#include "logger/Logger.hpp"
|
#include "logger/Logger.hpp"
|
||||||
|
|
||||||
#include "LmsHome.hpp"
|
|
||||||
#include "settings/SettingsFirstConnectionFormView.hpp"
|
#include "settings/SettingsFirstConnectionFormView.hpp"
|
||||||
|
|
||||||
|
#include "audio/AudioWidget.hpp"
|
||||||
|
#include "video/VideoWidget.hpp"
|
||||||
|
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
|
|
||||||
namespace skeletons {
|
namespace skeletons {
|
||||||
@@ -66,8 +68,7 @@ LmsApplication::create(const Wt::WEnvironment& env, boost::filesystem::path dbPa
|
|||||||
*/
|
*/
|
||||||
LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::path dbPath)
|
LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::path dbPath)
|
||||||
: Wt::WApplication(env),
|
: Wt::WApplication(env),
|
||||||
_sessionData(dbPath),
|
_sessionData(dbPath)
|
||||||
_home(nullptr)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(this);
|
Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(this);
|
||||||
@@ -78,54 +79,107 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::p
|
|||||||
// Add a resource bundle
|
// Add a resource bundle
|
||||||
messageResourceBundle().use(appRoot() + "templates");
|
messageResourceBundle().use(appRoot() + "templates");
|
||||||
|
|
||||||
setTitle("LMS"); // application title
|
setTitle("LMS");
|
||||||
|
|
||||||
// Create a Vertical layout: top is the nav bar, bottom is the contents
|
bool firstConnection;
|
||||||
Wt::WVBoxLayout *layout = new Wt::WVBoxLayout(this->root());
|
{
|
||||||
// Create a navigation bar with a link to a web page.
|
Wt::Dbo::Transaction transaction(_sessionData.getDatabaseHandler().getSession());
|
||||||
Wt::WNavigationBar *navigation = new Wt::WNavigationBar();
|
|
||||||
navigation->setTitle("LMS");
|
|
||||||
navigation->setResponsive(true);
|
|
||||||
navigation->addStyleClass("main-nav");
|
|
||||||
|
|
||||||
Wt::WStackedWidget *contentsStack = new Wt::WStackedWidget();
|
firstConnection = (Database::User::getAll(_sessionData.getDatabaseHandler().getSession()).size() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup a Left-aligned menu.
|
// If here is no account in the database, launch the first connection wizard
|
||||||
Wt::WMenu *leftMenu = new Wt::WMenu(contentsStack);
|
if (firstConnection)
|
||||||
navigation->addMenu(leftMenu);
|
{
|
||||||
|
// Hack, use the auth widget builtin strings
|
||||||
|
builtinLocalizedStrings().useBuiltin(skeletons::AuthStrings_xml1);
|
||||||
|
|
||||||
_audioWidget = new AudioWidget(_sessionData);
|
root()->addWidget( new Settings::FirstConnectionFormView(_sessionData));
|
||||||
_videoWidget = new VideoWidget(_sessionData);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sessionData.getDatabaseHandler().getLogin().changed().connect(this, &LmsApplication::handleAuthEvent);
|
||||||
|
|
||||||
leftMenu->addItem("Audio", _audioWidget);
|
LmsAuth *authWidget = new LmsAuth(_sessionData.getDatabaseHandler());
|
||||||
leftMenu->addItem("Video", _videoWidget);
|
|
||||||
// leftMenu->addItem("Settings", new Settings::Settings(_sessionData));
|
|
||||||
|
|
||||||
// Setup a Right-aligned menu.
|
authWidget->model()->addPasswordAuth(&Database::Handler::getPasswordService());
|
||||||
Wt::WMenu *rightMenu = new Wt::WMenu();
|
authWidget->setRegistrationEnabled(false);
|
||||||
|
|
||||||
navigation->addMenu(rightMenu, Wt::AlignRight);
|
authWidget->processEnvironment();
|
||||||
|
|
||||||
Wt::WPopupMenu *popup = new Wt::WPopupMenu();
|
root()->addWidget(authWidget);
|
||||||
popup->addItem("Logout");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// popup->itemSelected().connect(this, &LmsHome::handleUserMenuSelected);
|
|
||||||
|
|
||||||
/* Wt::WMenuItem *item = new Wt::WMenuItem( user.identity(Wt::Auth::Identity::LoginName) );
|
void
|
||||||
item->setMenu(popup);
|
LmsApplication::handleAuthEvent(void)
|
||||||
rightMenu->addItem(item);*/
|
{
|
||||||
|
if (_sessionData.getDatabaseHandler().getLogin().loggedIn())
|
||||||
|
{
|
||||||
|
Wt::Auth::User user(_sessionData.getDatabaseHandler().getLogin().user());
|
||||||
|
|
||||||
// Add a Search control.
|
// Create a Vertical layout: top is the nav bar, bottom is the contents
|
||||||
/* _searchEdit = new Wt::WLineEdit();
|
Wt::WVBoxLayout *layout = new Wt::WVBoxLayout(this->root());
|
||||||
_searchEdit->setEmptyText("Search...");
|
// Create a navigation bar with a link to a web page.
|
||||||
|
Wt::WNavigationBar *navigation = new Wt::WNavigationBar();
|
||||||
|
navigation->setTitle("LMS");
|
||||||
|
navigation->setResponsive(true);
|
||||||
|
navigation->addStyleClass("main-nav");
|
||||||
|
|
||||||
_searchEdit->enterPressed().connect(this, &LmsHome::handleSearch);
|
Wt::WStackedWidget *contentsStack = new Wt::WStackedWidget();
|
||||||
*/
|
|
||||||
// navigation->addSearch(_searchEdit, Wt::AlignLeft);
|
|
||||||
|
|
||||||
layout->addWidget(navigation);
|
// Setup a Left-aligned menu.
|
||||||
layout->addWidget(contentsStack, 1);
|
Wt::WMenu *leftMenu = new Wt::WMenu(contentsStack);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
navigation->addMenu(leftMenu);
|
||||||
|
|
||||||
|
AudioWidget *audioWidget = new AudioWidget(_sessionData);
|
||||||
|
VideoWidget *videoWidget = new VideoWidget(_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();
|
||||||
|
|
||||||
|
navigation->addMenu(rightMenu, Wt::AlignRight);
|
||||||
|
|
||||||
|
Wt::WPopupMenu *popup = new Wt::WPopupMenu();
|
||||||
|
popup->addItem("Logout");
|
||||||
|
|
||||||
|
Wt::WMenuItem *item = new Wt::WMenuItem( user.identity(Wt::Auth::Identity::LoginName) );
|
||||||
|
item->setMenu(popup);
|
||||||
|
rightMenu->addItem(item);
|
||||||
|
|
||||||
|
popup->itemSelected().connect(std::bind([=] (Wt::WMenuItem* item)
|
||||||
|
{
|
||||||
|
if (item && item->text() == "Logout")
|
||||||
|
_sessionData.getDatabaseHandler().getLogin().logout();
|
||||||
|
}, std::placeholders::_1));
|
||||||
|
|
||||||
|
// Add a Search control.
|
||||||
|
Wt::WLineEdit *searchEdit = new Wt::WLineEdit();
|
||||||
|
searchEdit->setEmptyText("Search...");
|
||||||
|
|
||||||
|
searchEdit->enterPressed().connect(std::bind([=] ()
|
||||||
|
{
|
||||||
|
audioWidget->search(searchEdit->text().toUTF8());
|
||||||
|
}));
|
||||||
|
|
||||||
|
navigation->addSearch(searchEdit, Wt::AlignLeft);
|
||||||
|
|
||||||
|
layout->addWidget(navigation);
|
||||||
|
layout->addWidget(contentsStack, 1);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LMS_LOG(MOD_UI, SEV_NOTICE) << "User logged out";
|
||||||
|
|
||||||
|
quit("");
|
||||||
|
redirect("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "common/SessionData.hpp"
|
#include "common/SessionData.hpp"
|
||||||
|
|
||||||
#include "LmsHome.hpp"
|
|
||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
|
|
||||||
@@ -43,10 +41,6 @@ class LmsApplication : public Wt::WApplication
|
|||||||
|
|
||||||
SessionData _sessionData;
|
SessionData _sessionData;
|
||||||
|
|
||||||
LmsHome* _home;
|
|
||||||
AudioWidget* _audioWidget;
|
|
||||||
VideoWidget* _videoWidget;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Emeric Poupon
|
|
||||||
*
|
|
||||||
* This file is part of LMS.
|
|
||||||
*
|
|
||||||
* LMS is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LMS is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <Wt/WStackedWidget>
|
|
||||||
#include <Wt/WMenu>
|
|
||||||
#include <Wt/WNavigationBar>
|
|
||||||
#include <Wt/WPopupMenu>
|
|
||||||
#include <Wt/WPopupMenuItem>
|
|
||||||
#include <Wt/WVBoxLayout>
|
|
||||||
#include <Wt/Auth/Identity>
|
|
||||||
|
|
||||||
#include "settings/Settings.hpp"
|
|
||||||
|
|
||||||
#include "LmsHome.hpp"
|
|
||||||
|
|
||||||
namespace UserInterface {
|
|
||||||
|
|
||||||
LmsHome::LmsHome(SessionData& sessionData, Wt::WContainerWidget* parent)
|
|
||||||
: Wt::WContainerWidget(parent),
|
|
||||||
_sessionData(sessionData)
|
|
||||||
{
|
|
||||||
const Wt::Auth::User& user = sessionData.getDatabaseHandler().getLogin().user();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
LmsHome::handleUserMenuSelected( Wt::WMenuItem* item)
|
|
||||||
{
|
|
||||||
if (item && item->text() == "Logout") {
|
|
||||||
_sessionData.getDatabaseHandler().getLogin().logout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
LmsHome::handleSearch(void)
|
|
||||||
{
|
|
||||||
// TODO Check currently selected menu item and search it
|
|
||||||
_audioWidget->search( _searchEdit->text().toUTF8() );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace UserInterface
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Emeric Poupon
|
|
||||||
*
|
|
||||||
* This file is part of LMS.
|
|
||||||
*
|
|
||||||
* LMS is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LMS is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LMS_HOME_HPP
|
|
||||||
#define LMS_HOME_HPP
|
|
||||||
|
|
||||||
#include <Wt/WContainerWidget>
|
|
||||||
#include <Wt/WLineEdit>
|
|
||||||
|
|
||||||
#include "common/SessionData.hpp"
|
|
||||||
|
|
||||||
#include "audio/AudioWidget.hpp"
|
|
||||||
#include "video/VideoWidget.hpp"
|
|
||||||
|
|
||||||
namespace UserInterface {
|
|
||||||
|
|
||||||
class LmsHome : public Wt::WContainerWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
LmsHome(SessionData& sessionData, Wt::WContainerWidget* parent = 0);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void handleSearch(void);
|
|
||||||
void handleUserMenuSelected( Wt::WMenuItem* item );
|
|
||||||
|
|
||||||
SessionData& _sessionData;
|
|
||||||
|
|
||||||
Wt::WLineEdit* _searchEdit;
|
|
||||||
AudioWidget* _audioWidget;
|
|
||||||
VideoWidget* _videoWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace UserInterface
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user