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__ <<
" " << std::endl;
101 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << environment().headerValue(
"X-Forwarded-For" ) << std::endl;
102 for(
const auto & kvp : environment().getParameterMap() )
103 for(
const auto vvv : kvp.second )
104 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << kvp.first <<
" " << vvv << std::endl;
108 std::cout << __FILE__ <<
":" << __LINE__ << std::endl << __FILE__ <<
":" << __LINE__ <<
" [" <<
Wt::WDateTime::currentDateTime().toString() <<
"] " << environment().clientAddress() <<
" " << sessionId() <<
" " << url() << std::endl << __FILE__ <<
":" << __LINE__ << std::endl;
111 #ifdef USE_GNUCASH_ENGINE
112 gnucash_session() .open(
g_dbName );
115 #ifdef USE_GNUCASHEW_SESSION
127 auto bootstrapTheme = std::make_shared<Wt::WBootstrapTheme>();
128 bootstrapTheme-> setVersion( Wt::BootstrapVersion::v3 );
129 bootstrapTheme-> setResponsive(
true );
130 setTheme( bootstrapTheme );
131 useStyleSheet(
"resources/themes/bootstrap/3/bootstrap-theme.min.css" );
132 useStyleSheet(
"styles/gcw.css" );
151 messageResourceBundle().use( docRoot() +
"/styles/gcw" );
152 messageResourceBundle().use( docRoot() +
"/styles/gcw_gui" );
160 auto tz = date::locate_zone( environment().timeZoneName() );
161 loc.setTimeZone( tz );
165 auto lw = root()-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
169 m_mainContainer = lw-> addWidget( std::make_unique< Wt::WContainerWidget >(), 1 );
187 std::cout << __FILE__ <<
":" << __LINE__
188 <<
" \t" << commodity.isocode
189 <<
" \t" << commodity.unitname
190 <<
" \t" << commodity.partname
191 <<
" \t" << commodity.nameSpace
192 <<
" \t" << commodity.exchangeCode
193 <<
" \t" << commodity.partsPerUnit
194 <<
" \t" << commodity.smallestFraction
195 <<
" \t" << commodity.localSymbol
196 <<
" \t" << commodity.fullname
207 Wt::WDialog dialog(
TR(
"gcw.welcome.title" ) );
208 dialog.rejectWhenEscapePressed(
true );
209 dialog.setClosable(
true );
210 dialog.contents()-> addNew< Wt::WText >(
TR(
"gcw.welcome.body" ) );
219 auto retVal = std::make_unique< Wt::Auth::AuthWidget >
222 gnucashew_session().users(),
223 gnucashew_session().login()
228 retVal-> setRegistrationEnabled(
true );
229 retVal-> processEnvironment();
231 return std::move( retVal );
241 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << gnucashew_session().login().loggedIn() << std::endl;
244 m_mainContainer-> removeWidget( m_mainWidget );
247 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << gnucashew_session().login().loggedIn() << std::endl;
251 if( bookmarkUrl() ==
"demo" || gnucashew_session().login().loggedIn() )
281 auto lw = m_mainContainer-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
282 lw-> setSpacing( 0 );
288 m_mainWidget = lw-> addWidget( std::make_unique< GCW::Gui::MainWidget >() );
297 auto lw = root()-> setLayout( std::make_unique< Wt::WVBoxLayout >() );
298 lw-> setSpacing( 0 );
304 m_mainWidget = lw-> addWidget( std::make_unique< GCW::Gui::MainWidget >() );
320 if(
g_dbName.find(
"LorimarkSolutions" ) == std::string::npos )
auto buildLogin() -> void
Dbo::GnuCashew::Session & gnucashew_session()
Wt::WContainerWidget * m_mainContainer
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 * >