ORE Studio 0.0.4
Loading...
Searching...
No Matches
SystemProvisionerWizard.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_QT_SYSTEM_PROVISIONER_WIZARD_HPP
21#define ORES_QT_SYSTEM_PROVISIONER_WIZARD_HPP
22
23#include <vector>
24#include <QWizard>
25#include <QWizardPage>
26#include <QLineEdit>
27#include <QLabel>
28#include <QRadioButton>
29#include <QButtonGroup>
30#include <QProgressBar>
31#include <QTextEdit>
32#include <QCheckBox>
33#include <QComboBox>
34#include <boost/uuid/uuid.hpp>
35#include "ores.logging/make_logger.hpp"
36#include "ores.qt/ClientManager.hpp"
37
38namespace ores::qt {
39
40
45 bool success = false;
46 QString error_message;
47 boost::uuids::uuid admin_account_id;
48 QStringList log_messages;
49};
50
62class SystemProvisionerWizard final : public QWizard {
63 Q_OBJECT
64
65private:
66 inline static std::string_view logger_name = "ores.qt.system_provisioner_wizard";
67
68 [[nodiscard]] static auto& lg() {
69 using namespace ores::logging;
70 static auto instance = make_logger(logger_name);
71 return instance;
72 }
73
74public:
75signals:
83 void provisioningCompleted(const QString& username);
84
90 void provisioningFailed(const QString& errorMessage);
91
92public:
93 // Page IDs
94 enum PageId {
95 Page_Welcome,
96 Page_AdminAccount,
97 Page_BundleSelection,
98 Page_Apply
99 };
100
102 ClientManager* clientManager,
103 const std::vector<BootstrapBundleInfo>& bundles,
104 QWidget* parent = nullptr);
105
106 ~SystemProvisionerWizard() override = default;
107
108 // Accessors for wizard pages
109 ClientManager* clientManager() const { return clientManager_; }
110
111 // Admin account data
112 QString adminUsername() const { return adminUsername_; }
113 QString adminEmail() const { return adminEmail_; }
114 QString adminPassword() const { return adminPassword_; }
115 void setAdminCredentials(const QString& username, const QString& email,
116 const QString& password);
117
118 // Bundle selection
119 const std::vector<BootstrapBundleInfo>& bundles() const { return bundles_; }
120 QString selectedBundleCode() const { return selectedBundleCode_; }
121 void setSelectedBundleCode(const QString& code) { selectedBundleCode_ = code; }
122
123 // Created admin account ID (set after successful creation)
124 boost::uuids::uuid adminAccountId() const { return adminAccountId_; }
125 void setAdminAccountId(const boost::uuids::uuid& id) { adminAccountId_ = id; }
126
127private:
128 void setupPages();
129
130 ClientManager* clientManager_;
131 std::vector<BootstrapBundleInfo> bundles_;
132 QString adminUsername_;
133 QString adminEmail_;
134 QString adminPassword_;
135 QString selectedBundleCode_;
136 boost::uuids::uuid adminAccountId_;
137};
138
139// Forward declarations of page classes
140class WelcomePage;
141class AdminAccountPage;
142class BundleSelectionPage;
143class ApplyProvisioningPage;
144
148class WelcomePage final : public QWizardPage {
149 Q_OBJECT
150
151public:
152 explicit WelcomePage(SystemProvisionerWizard* wizard);
153
154private:
155 void setupUI();
156
158};
159
163class AdminAccountPage final : public QWizardPage {
164 Q_OBJECT
165
166public:
168 bool validatePage() override;
169
170private slots:
171 void onShowPasswordToggled(bool checked);
172 void onPasswordChanged();
173
174private:
175 void setupUI();
176 void updatePasswordMatchIndicator();
177
179 QLineEdit* usernameEdit_;
180 QLineEdit* emailEdit_;
181 QLineEdit* passwordEdit_;
182 QLineEdit* confirmPasswordEdit_;
183 QCheckBox* showPasswordCheckbox_;
184 QLabel* passwordMatchLabel_;
185 QLabel* validationLabel_;
186};
187
191class BundleSelectionPage final : public QWizardPage {
192 Q_OBJECT
193
194public:
196 void initializePage() override;
197 bool validatePage() override;
198
199private slots:
200 void onBundleChanged(int index);
201
202private:
203 void setupUI();
204 void populateBundles();
205
207 QComboBox* bundleCombo_;
208 QLabel* descriptionLabel_;
209};
210
214class ApplyProvisioningPage final : public QWizardPage {
215 Q_OBJECT
216
217private:
218 inline static std::string_view logger_name = "ores.qt.apply_provisioning_page";
219
220 [[nodiscard]] static auto& lg() {
221 using namespace ores::logging;
222 static auto instance = make_logger(logger_name);
223 return instance;
224 }
225
226public:
228 void initializePage() override;
229 bool isComplete() const override;
230
231private slots:
232 void onProvisioningResult(const ProvisioningResult& result);
233
234private:
235 void startProvisioning();
236 ProvisioningResult performProvisioning();
237 void appendLog(const QString& message);
238 void setStatus(const QString& status);
239
241 QLabel* statusLabel_;
242 QProgressBar* progressBar_;
243 QTextEdit* logOutput_;
244 bool provisioningComplete_ = false;
245 bool provisioningSuccess_ = false;
246};
247
248}
249
250#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Result of a provisioning operation.
Definition SystemProvisionerWizard.hpp:44
Wizard for initial system provisioning when in bootstrap mode.
Definition SystemProvisionerWizard.hpp:62
void provisioningFailed(const QString &errorMessage)
Emitted when provisioning fails.
void provisioningCompleted(const QString &username)
Emitted when provisioning is successfully completed.
Welcome page explaining bootstrap mode and system initialization.
Definition SystemProvisionerWizard.hpp:148
Page for creating the initial administrator account.
Definition SystemProvisionerWizard.hpp:163
Page for selecting a dataset bundle to provision.
Definition SystemProvisionerWizard.hpp:191
Page for applying provisioning and showing progress.
Definition SystemProvisionerWizard.hpp:214