10#include <Wt/Date/tz.h>
11#include <Wt/WBootstrapTheme.h>
12#include <Wt/Auth/AuthWidget.h>
14#include <Wt/WDialog.h>
15#include <Wt/WCheckBox.h>
16#include <Wt/WEnvironment.h>
17#include <Wt/WHBoxLayout.h>
18#include <Wt/WVBoxLayout.h>
19#include <Wt/WLocale.h>
20#include <Wt/WServer.h>
22#include <Wt/WVBoxLayout.h>
37 std::cout << __FILE__ <<
":" << __LINE__
38 <<
"\n title: " <<
app-> title()
39 <<
"\n appRoot: " <<
app-> appRoot()
40 <<
"\n docRoot: " <<
app-> docRoot()
41 <<
"\n sessionId: " <<
app-> sessionId()
42 <<
"\n metaHeader: " <<
app-> metaHeader( Wt::MetaHeaderType::Meta,
"*" )
43 <<
"\n bodyClass: " <<
app-> bodyClass()
44 <<
"\n htmlClass: " <<
app-> htmlClass()
45 <<
"\n url: " <<
app-> url()
46 <<
"\n bookmarkUrl: " <<
app-> bookmarkUrl()
47 <<
"\n internalPath: " <<
app-> internalPath()
48 <<
"\n javaScriptClass: " <<
app-> javaScriptClass()
49 <<
"\n resourcesUrl: " <<
app-> resourcesUrl()
50 <<
"\n r-resourcesUrl: " <<
app-> relativeResourcesUrl()
51 <<
"\n referrer: " <<
app-> environment().referer()
52 <<
"\n accept: " <<
app-> environment().accept()
53 <<
"\n Host: " <<
app-> environment().headerValue(
"Host" )
54 <<
"\n Referrer: " <<
app-> environment().headerValue(
"Referrer" )
55 <<
"\n Accept: " <<
app-> environment().headerValue(
"Accept" )
56 <<
"\n Origin: " <<
app-> environment().headerValue(
"Origin" )
57 <<
"\n Content-Type: " <<
app-> environment().headerValue(
"Content-Type" )
58 <<
"\n Content-Length: " <<
app-> environment().headerValue(
"Content-Length" )
59 <<
"\n X-Forwarded-For: " <<
app-> environment().headerValue(
"X-Forwarded-For" )
60 <<
"\n X-Forwarded-Client: " <<
app-> environment().headerValue(
"X-Forwarded-Client" )
61 <<
"\n X-Forwarded-Xyz: " <<
app-> environment().headerValue(
"X-Forwarded-Xyz" )
62 <<
"\n clientAddress: " <<
app-> environment().clientAddress()
66 std::cout << __FILE__ <<
":" << __LINE__ <<
" parameterMapSize: " <<
app-> environment().getParameterMap().size() << std::endl;
67 for(
const auto & pair :
app-> environment().getParameterMap() )
68 for( const auto & value : pair.second )
69 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << pair.first <<
"=" << value <<
std::endl;
77 return static_cast< GCW::App*
>( Wt::WApplication::instance() );
81:
Wt::WApplication( env )
83 root()-> addStyleClass(
"GnuCashewRoot" );
108 std::cout << __FILE__ <<
":" << __LINE__ <<
" " <<
environment().
headerValue(
"X-Forwarded-For" ) << std::endl;
110 for(
const auto vvv : kvp.second )
111 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << kvp.first <<
" " << vvv << std::endl;
116 << __FILE__ <<
":" << __LINE__ << std::endl
117 << __FILE__ <<
":" << __LINE__
121 <<
" " <<
url() << std::endl
122 << __FILE__ <<
":" << __LINE__
126#ifdef USE_GNUCASH_ENGINE
130#ifdef USE_GNUCASHEW_SESSION
142 auto bootstrapTheme = std::make_shared<Wt::WBootstrapTheme>();
143 bootstrapTheme-> setVersion( Wt::BootstrapVersion::v3 );
144 bootstrapTheme-> setResponsive(
true );
146 useStyleSheet(
"resources/themes/bootstrap/3/bootstrap-theme.min.css" );
175 auto tz = date::locate_zone(
environment().timeZoneName() );
176 loc.setTimeZone( tz );
180 auto lw =
root()-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
184 m_mainContainer = lw-> addWidget( std::make_unique< Wt::WContainerWidget >(), 1 );
200 std::cout << __FILE__ <<
":" << __LINE__
201 <<
" \tcommodity.isocode"
202 <<
" \tcommodity.unitname"
203 <<
" \tcommodity.partname"
204 <<
" \tcommodity.nameSpace"
205 <<
" \tcommodity.exchangeCode"
206 <<
" \tcommodity.partsPerUnit"
207 <<
" \tcommodity.smallestFraction"
208 <<
" \tcommodity.localSymbol"
209 <<
" \tcommodity.fullname"
213 std::cout << __FILE__ <<
":" << __LINE__
214 <<
" \t" << commodity.isocode
215 <<
" \t" << commodity.unitname
216 <<
" \t" << commodity.partname
217 <<
" \t" << commodity.nameSpace
218 <<
" \t" << commodity.exchangeCode
219 <<
" \t" << commodity.partsPerUnit
220 <<
" \t" << commodity.smallestFraction
221 <<
" \t" << commodity.localSymbol
222 <<
" \t" << commodity.fullname
227#ifdef SIMPLE_REPEATING_TIMER_FOR_TESTING_THINGS
228 m_timer = std::make_unique< Wt::WTimer >();
229 m_timer-> setInterval( std::chrono::seconds(1) );
234 std::cout << __FILE__ <<
":" << __LINE__ <<
" testing something..." << std::endl;
255 auto config = configItem(
"welcome" );
256 if( config-> getVarString(
"suppress" ) !=
"yes" )
259 dialog.rejectWhenEscapePressed(
true );
260 dialog.setClosable(
true );
261 dialog.contents()-> addNew< Wt::WText >(
TR(
"gcw.welcome.body" ) );
262 auto cbxSuppress =
dialog.contents()-> addNew< Wt::WCheckBox >(
"do not show this message again" );
266 config.modify()-> setVar(
"suppress", cbxSuppress-> valueText().toUTF8() );
275 auto retVal = std::make_unique< Wt::Auth::AuthWidget >
278 gnucashew_session().users(),
279 gnucashew_session().login()
284 retVal-> setRegistrationEnabled(
true );
285 retVal-> processEnvironment();
287 return std::move( retVal );
297 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << gnucashew_session().login().loggedIn() << std::endl;
300 m_mainContainer-> removeWidget( m_mainWidget );
303 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << gnucashew_session().login().loggedIn() << std::endl;
307 if( bookmarkUrl() ==
"demo" || gnucashew_session().login().loggedIn() )
337 auto lw = m_mainContainer-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
338 lw-> setSpacing( 0 );
344 m_mainWidget = lw-> addWidget( std::make_unique< GCW::Gui::MainWidget >() );
353 auto lw = root()-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
354 lw-> setSpacing( 0 );
360 m_mainWidget = lw-> addWidget( std::make_unique< GCW::Gui::MainWidget >() );
auto buildLogin() -> void
auto configItem(const std::string &_cfy) -> GCW::Dbo::Vars::Item::Ptr
Wt::WContainerWidget * m_mainContainer
std::unique_ptr< Wt::WTimer > m_timer
Dbo::GnuCashew::Session & gnucashew_session()
auto createAuthWidget() -> std::unique_ptr< Wt::Auth::AuthWidget >
App(const Wt::WEnvironment &env)
GCW::Eng::Engine & engine()
auto showWelcome() -> void
auto buildLoggedIn() -> void
auto login() -> Wt::Auth::Login &
bool open(const std::string &_path)
Open a database.
bool open(const std::string &_filePath)
Open the Database.
std::string sessionId() const
std::string docRoot() const
WMessageResourceBundle & messageResourceBundle()
WContainerWidget * root() const
const WLocale & locale() const
void setTheme(const std::shared_ptr< WTheme > &theme)
void setTitle(const WString &title)
void useStyleSheet(const WLink &link, const std::string &media="all")
std::string url(const std::string &internalPath=std::string()) const
const WEnvironment & environment() const
static WDateTime currentDateTime()
const Http::ParameterMap & getParameterMap() const
const std::string headerValue(const std::string &field) const
const std::string & clientAddress() const
void use(const std::string &path, bool loadInMemory=true)
static void singleShot(std::chrono::milliseconds interval, T *receiver, void(V::*method)())
auto getIso4217Commodities() -> std::vector< Commodity_t >
Get Commodities.
auto passwordService() -> const Wt::Auth::PasswordService &
auto service() -> const Wt::Auth::AuthService &
auto oService() -> const std::vector< const Wt::Auth::OAuthService * >
auto get(const std::string &_keyValue, const std::string &_cfyValue="*", bool _add=true) -> GCW::Dbo::Vars::Item::Ptr