ORE Studio 0.0.4
Loading...
Searching...
No Matches
ore_application.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_WT_SERVICE_APP_ORE_APPLICATION_HPP
21#define ORES_WT_SERVICE_APP_ORE_APPLICATION_HPP
22
23#include <Wt/WApplication.h>
24#include <Wt/WLineEdit.h>
25#include <Wt/WPasswordEdit.h>
26#include <Wt/WPushButton.h>
27#include <Wt/WText.h>
28#include <boost/uuid/uuid.hpp>
29#include "ores.wt.service/app/login_widget.hpp"
30#include "ores.wt.service/service/session_manager.hpp"
31
32namespace ores::wt::service::app {
33
34class currency_list_widget;
35class country_list_widget;
36class account_list_widget;
37
41class ore_application : public Wt::WApplication {
42public:
43 explicit ore_application(const Wt::WEnvironment& env);
44
45 static ore_application* instance();
46
47 service::session_manager& session_manager() { return session_manager_; }
48 bool is_logged_in() const { return session_manager_.is_logged_in(); }
49
50private:
51 void show_login();
52 void show_bootstrap();
53 void show_main_view();
54 void on_login_attempt(const std::string& username, const std::string& password);
55 void on_bootstrap_create(const std::string& username, const std::string& email,
56 const std::string& password);
57 void on_logout();
58 void setup_theme();
59
60 std::string get_current_username() const;
61
62 void setup_currency_handlers();
63 void load_currencies();
64 void show_add_currency_dialog();
65 void show_edit_currency_dialog(const std::string& iso_code);
66 void confirm_delete_currency(const std::string& iso_code);
67
68 void setup_country_handlers();
69 void load_countries();
70 void show_add_country_dialog();
71 void show_edit_country_dialog(const std::string& alpha2_code);
72 void confirm_delete_country(const std::string& alpha2_code);
73
74 void setup_account_handlers();
75 void load_accounts();
76 void show_add_account_dialog();
77 void show_edit_account_dialog(const boost::uuids::uuid& id);
78 void confirm_delete_account(const boost::uuids::uuid& id);
79 void confirm_lock_account(const boost::uuids::uuid& id);
80 void confirm_unlock_account(const boost::uuids::uuid& id);
81
82 service::session_manager session_manager_;
83 login_widget* login_widget_ = nullptr;
84 currency_list_widget* currency_list_widget_ = nullptr;
85 country_list_widget* country_list_widget_ = nullptr;
86 account_list_widget* account_list_widget_ = nullptr;
87
88 // Bootstrap form widgets
89 Wt::WLineEdit* bootstrap_username_ = nullptr;
90 Wt::WLineEdit* bootstrap_email_ = nullptr;
91 Wt::WPasswordEdit* bootstrap_password_ = nullptr;
92 Wt::WPasswordEdit* bootstrap_confirm_ = nullptr;
93 Wt::WPushButton* bootstrap_button_ = nullptr;
94 Wt::WText* bootstrap_status_ = nullptr;
95};
96
97}
98
99#endif
Utilities for reading environment variables.
Definition environment.hpp:31
Widget displaying list of user accounts with CRUD operations.
Definition account_list_widget.hpp:50
Widget displaying list of countries with CRUD operations.
Definition country_list_widget.hpp:47
Widget displaying list of currencies with CRUD operations.
Definition currency_list_widget.hpp:49
Login form widget for user authentication.
Definition login_widget.hpp:35
Main Wt application for ORE Studio web interface.
Definition ore_application.hpp:41
Manages user authentication sessions for a single Wt application.
Definition session_manager.hpp:57