ORE Studio 0.0.4
Loading...
Searching...
No Matches
ClientJobInstanceModel.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_CLIENT_JOB_INSTANCE_MODEL_HPP
21#define ORES_QT_CLIENT_JOB_INSTANCE_MODEL_HPP
22
23#include <vector>
24#include <QFutureWatcher>
25#include <QAbstractTableModel>
26#include "ores.qt/AbstractClientModel.hpp"
27#include "ores.qt/ClientManager.hpp"
28#include "ores.logging/make_logger.hpp"
29#include "ores.scheduler.api/messaging/scheduler_protocol.hpp"
30
31namespace ores::qt {
32
40 Q_OBJECT
41
42private:
43 inline static std::string_view logger_name =
44 "ores.qt.client_job_instance_model";
45
46 [[nodiscard]] static auto& lg() {
47 using namespace ores::logging;
48 static auto instance = make_logger(logger_name);
49 return instance;
50 }
51
52public:
53 enum Column {
54 JobName,
55 Status,
56 TriggeredAt,
57 StartedAt,
58 Duration,
59 ActionType,
60 ErrorMessage,
61 ColumnCount
62 };
63
64 explicit ClientJobInstanceModel(ClientManager* clientManager,
65 QObject* parent = nullptr);
66 ~ClientJobInstanceModel() override = default;
67
68 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
69 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
70 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
71 QVariant headerData(int section, Qt::Orientation orientation,
72 int role = Qt::DisplayRole) const override;
73
74 void refresh();
75
76 const scheduler::messaging::job_instance_summary* getInstance(int row) const;
77
78private slots:
79 void onInstancesLoaded();
80
81private:
82 struct FetchResult {
83 bool success;
84 std::vector<scheduler::messaging::job_instance_summary> instances;
85 QString error_message;
86 QString error_details;
87 };
88
89 void fetch_instances();
90
91 ClientManager* clientManager_;
92 std::vector<scheduler::messaging::job_instance_summary> instances_;
93 QFutureWatcher<FetchResult>* watcher_;
94 bool is_fetching_{false};
95};
96
97}
98
99#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Base class for all client-side entity models.
Definition AbstractClientModel.hpp:37
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Table model for the global job-instance execution history.
Definition ClientJobInstanceModel.hpp:39
A job_instance enriched with the parent job's display name.
Definition scheduler_protocol.hpp:122