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/WEnvironment.h>
16 #include <Wt/WHBoxLayout.h>
17 #include <Wt/WVBoxLayout.h>
18 #include <Wt/WLocale.h>
19 #include <Wt/WServer.h>
21 #include <Wt/WVBoxLayout.h>
32 void showEnvironment()
36 std::cout << __FILE__ <<
":" << __LINE__
37 <<
"\n title: " <<
app-> title()
38 <<
"\n appRoot: " <<
app-> appRoot()
39 <<
"\n docRoot: " <<
app-> docRoot()
40 <<
"\n sessionId: " <<
app-> sessionId()
41 <<
"\n metaHeader: " <<
app-> metaHeader( Wt::MetaHeaderType::Meta,
"*" )
42 <<
"\n bodyClass: " <<
app-> bodyClass()
43 <<
"\n htmlClass: " <<
app-> htmlClass()
44 <<
"\n url: " <<
app-> url()
45 <<
"\n bookmarkUrl: " <<
app-> bookmarkUrl()
46 <<
"\n internalPath: " <<
app-> internalPath()
47 <<
"\n javaScriptClass: " <<
app-> javaScriptClass()
48 <<
"\n resourcesUrl: " <<
app-> resourcesUrl()
49 <<
"\n r-resourcesUrl: " <<
app-> relativeResourcesUrl()
50 <<
"\n referrer: " <<
app-> environment().referer()
51 <<
"\n accept: " <<
app-> environment().accept()
52 <<
"\n X-Forwarded-For: " <<
app-> environment().headerValue(
"X-Forwarded-For" )
53 <<
"\n X-Forwarded-Client: " <<
app-> environment().headerValue(
"X-Forwarded-Client" )
54 <<
"\n X-Forwarded-Xyz: " <<
app-> environment().headerValue(
"X-Forwarded-Xyz" )
55 <<
"\n clientAddress: " <<
app-> environment().clientAddress()
59 for(
const auto & pair :
app-> environment().getParameterMap() )
60 for(
const auto & value : pair.second )
61 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << pair.first <<
"=" << value << std::endl;
69 return static_cast< GCW::App*
>( Wt::WApplication::instance() );
73 :
Wt::WApplication( env )
75 root()-> addStyleClass(
"GnuCashewRoot" );
77 setTitle(
"GnuCashew ~ " +
g_dbName );
100 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << environment().headerValue(
"X-Forwarded-For" ) << std::endl;
101 for(
const auto & kvp : environment().getParameterMap() )
102 for(
const auto vvv : kvp.second )
103 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << kvp.first <<
" " << vvv << std::endl;
108 << __FILE__ <<
":" << __LINE__ << std::endl
109 << __FILE__ <<
":" << __LINE__
111 <<
"] " << environment().clientAddress()
112 <<
" " << sessionId()
113 <<
" " << url() << std::endl
114 << __FILE__ <<
":" << __LINE__
118 #ifdef USE_GNUCASH_ENGINE
119 gnucash_session() .open(
g_dbName );
122 #ifdef USE_GNUCASHEW_SESSION
134 auto bootstrapTheme = std::make_shared<Wt::WBootstrapTheme>();
135 bootstrapTheme-> setVersion( Wt::BootstrapVersion::v3 );
136 bootstrapTheme-> setResponsive(
true );
137 setTheme( bootstrapTheme );
138 useStyleSheet(
"resources/themes/bootstrap/3/bootstrap-theme.min.css" );
139 useStyleSheet(
"styles/gcw.css" );
158 messageResourceBundle().use( docRoot() +
"/styles/gcw" );
159 messageResourceBundle().use( docRoot() +
"/styles/gcw_gui" );
167 auto tz = date::locate_zone( environment().timeZoneName() );
168 loc.setTimeZone( tz );
172 auto lw = root()-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
176 m_mainContainer = lw-> addWidget( std::make_unique< Wt::WContainerWidget >(), 1 );
192 std::cout << __FILE__ <<
":" << __LINE__
193 <<
" \tcommodity.isocode"
194 <<
" \tcommodity.unitname"
195 <<
" \tcommodity.partname"
196 <<
" \tcommodity.nameSpace"
197 <<
" \tcommodity.exchangeCode"
198 <<
" \tcommodity.partsPerUnit"
199 <<
" \tcommodity.smallestFraction"
200 <<
" \tcommodity.localSymbol"
201 <<
" \tcommodity.fullname"
205 std::cout << __FILE__ <<
":" << __LINE__
206 <<
" \t" << commodity.isocode
207 <<
" \t" << commodity.unitname
208 <<
" \t" << commodity.partname
209 <<
" \t" << commodity.nameSpace
210 <<
" \t" << commodity.exchangeCode
211 <<
" \t" << commodity.partsPerUnit
212 <<
" \t" << commodity.smallestFraction
213 <<
" \t" << commodity.localSymbol
214 <<
" \t" << commodity.fullname
219 #ifdef SIMPLE_REPEATING_TIMER_FOR_TESTING_THINGS
220 m_timer = std::make_unique< Wt::WTimer >();
221 m_timer-> setInterval( std::chrono::seconds(1) );
224 timeout().connect( [&]( Wt::WMouseEvent _event )
226 std::cout << __FILE__ <<
":" << __LINE__ <<
" testing something..." << std::endl;
236 Wt::WDialog
dialog(
TR(
"gcw.welcome.title" ) );
237 dialog.rejectWhenEscapePressed(
true );
238 dialog.setClosable(
true );
239 dialog.contents()-> addNew< Wt::WText >(
TR(
"gcw.welcome.body" ) );
248 auto retVal = std::make_unique< Wt::Auth::AuthWidget >
251 gnucashew_session().users(),
252 gnucashew_session().login()
257 retVal-> setRegistrationEnabled(
true );
258 retVal-> processEnvironment();
260 return std::move( retVal );
270 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << gnucashew_session().login().loggedIn() << std::endl;
273 m_mainContainer-> removeWidget( m_mainWidget );
276 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << gnucashew_session().login().loggedIn() << std::endl;
280 if( bookmarkUrl() ==
"demo" || gnucashew_session().login().loggedIn() )
310 auto lw = m_mainContainer-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
311 lw-> setSpacing( 0 );
317 m_mainWidget = lw-> addWidget( std::make_unique< GCW::Gui::MainWidget >() );
326 auto lw = root()-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
327 lw-> setSpacing( 0 );
333 m_mainWidget = lw-> addWidget( std::make_unique< GCW::Gui::MainWidget >() );
349 if(
g_dbName.find(
"LorimarkSolutions" ) == std::string::npos )
auto buildLogin() -> void
Dbo::GnuCashew::Session & gnucashew_session()
Wt::WContainerWidget * m_mainContainer
std::unique_ptr< Wt::WTimer > m_timer
GCW::Eng::Engine & engine()
auto createAuthWidget() -> std::unique_ptr< Wt::Auth::AuthWidget >
App(const Wt::WEnvironment &env)
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.
auto currentDateTime() -> Wt::WDateTime
Current Date/Time.
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 * >