ORE Studio 0.0.4
Loading...
Searching...
No Matches
AppVersionDetailDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_APP_VERSION_DETAIL_DIALOG_HPP
21#define ORES_QT_APP_VERSION_DETAIL_DIALOG_HPP
22
23#include <QUrl>
24#include <QString>
25#include <functional>
26#include <vector>
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/DetailDialogBase.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.compute.api/domain/app.hpp"
31#include "ores.compute.api/domain/app_version.hpp"
32#include "ores.compute.api/domain/app_version_platform.hpp"
33#include "ores.compute.api/messaging/platform_protocol.hpp"
34
35class QNetworkAccessManager;
36
37namespace Ui {
38class AppVersionDetailDialog;
39}
40
41namespace ores::qt {
42
51 Q_OBJECT
52
53private:
54 inline static std::string_view logger_name =
55 "ores.qt.app_version_detail_dialog";
56
57 [[nodiscard]] static auto& lg() {
58 using namespace ores::logging;
59 static auto instance = make_logger(logger_name);
60 return instance;
61 }
62
63public:
64 explicit AppVersionDetailDialog(QWidget* parent = nullptr);
65 ~AppVersionDetailDialog() override;
66
67 void setClientManager(ClientManager* clientManager);
68 void setUsername(const std::string& username);
69 void setVersion(const compute::domain::app_version& app_version);
70 void setCreateMode(bool createMode);
71 void setReadOnly(bool readOnly);
72 void setHttpBaseUrl(const std::string& url);
73
74signals:
75 void app_versionSaved(const QString& code);
76 void app_versionDeleted(const QString& code);
77
78private slots:
79 void onSaveClicked();
80 void onDeleteClicked();
81 void onCodeChanged(const QString& text);
82 void onFieldChanged();
83 void onAddPlatformClicked();
84 void onRemovePlatformClicked();
85 void onBrowsePackageRowClicked();
86 void onRetryPackageRowClicked();
87
88protected:
89 QTabWidget* tabWidget() const override;
90 QWidget* provenanceTab() const override;
91 ProvenanceWidget* provenanceWidget() const override;
92 bool hasUnsavedChanges() const override { return hasChanges_; }
93
94private:
95 struct AppEntry {
96 std::string id; // UUID string
97 std::string name;
98 };
99
100 struct PlatformEntry {
101 std::string id; // UUID string
102 std::string code;
103 std::string display_name;
104 };
105
114 struct PackageRow {
115 enum class State { NoFile, Selected, Uploading, Uploaded, Failed };
116
117 std::string platform_id;
118 std::string platform_code;
119 std::string platform_name;
120 QString local_file; // selected local path, empty until Browse
121 QString remote_uri; // set after successful PUT or on preload
122 State state = State::NoFile;
123 QString error;
124 };
125
126 void setupUi();
127 void setupConnections();
128 void loadApps();
129 void loadPlatforms();
130 void loadAssignedPlatforms(const std::string& app_version_id);
131 void populateAppCombo();
132 void populatePlatformsTab();
133 void syncPackagesTab();
134 void updatePackagesTableRow(int row);
135 void setPackageRowState(int row, PackageRow::State state,
136 const QString& error = {});
137 void updateUiFromVersion();
138 void updateVersionFromUi();
139 void updateSaveButtonState();
140 bool validateInput();
141
142 void uploadPendingPackages(std::function<void(bool, QString)> done);
143 void submitSave();
144
145 Ui::AppVersionDetailDialog* ui_;
146 ClientManager* clientManager_;
147 QNetworkAccessManager* networkManager_;
148 std::string username_;
149 QUrl httpBaseUrl_;
150 compute::domain::app_version app_version_;
151 std::vector<PackageRow> package_rows_;
152 std::vector<AppEntry> appEntries_;
153 std::vector<PlatformEntry> availablePlatforms_;
154 bool createMode_{true};
155 bool readOnly_{false};
156 bool hasChanges_{false};
157 bool saveInProgress_{false};
158};
159
160}
161
162#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
A versioned wrapper+engine bundle for a compute grid application.
Definition app_version.hpp:37
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:75
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:40
Detail dialog for viewing and editing app version records.
Definition AppVersionDetailDialog.hpp:50
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition AppVersionDetailDialog.cpp:80
bool hasUnsavedChanges() const override
Definition AppVersionDetailDialog.hpp:92
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition AppVersionDetailDialog.cpp:72
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition AppVersionDetailDialog.cpp:76