12 #include "ui_autopublishcomponent.h"
21 using namespace swift::misc::simulation;
26 CAutoPublishComponent::CAutoPublishComponent(QWidget *parent)
30 connect(ui->pb_Analyze, &QPushButton::released,
this, &CAutoPublishComponent::analyzeAgainstDBData,
31 Qt::QueuedConnection);
32 connect(ui->pb_SendToDB, &QPushButton::released,
this, &CAutoPublishComponent::sendToDb, Qt::QueuedConnection);
33 connect(ui->pb_DeleteFiles, &QPushButton::released,
this, &CAutoPublishComponent::deleteAllFiles,
34 Qt::QueuedConnection);
39 connect(w, &CDatabaseWriter::autoPublished,
this, &CAutoPublishComponent::onAutoPublished,
40 Qt::QueuedConnection);
55 void CAutoPublishComponent::analyzeAgainstDBData()
63 void CAutoPublishComponent::sendToDb()
65 using namespace std::chrono_literals;
90 void CAutoPublishComponent::displayData()
96 void CAutoPublishComponent::deleteAllFiles()
98 const int c = CAutoPublishData::deleteAutoPublishFiles();
103 void CAutoPublishComponent::onAutoPublished(
bool success,
const QString &url,
const CStatusMessageList &msgs)
105 using namespace std::chrono_literals;
112 QPointer<CAutoPublishComponent> myself(
this);
114 if (!myself) {
return; }
115 const auto timeout = 5000ms;
116 myself->deleteAllFiles();
117 myself->showOverlayHTMLMessage(
"Cleaned auto publish files after uploading them to DB", timeout);
120 if (!myself) {
return; }
121 myself->closeParentDialog();
124 m_lastAutoPublish.set(QDateTime::currentMSecsSinceEpoch());
129 void CAutoPublishComponent::closeParentDialog()
132 if (d) { d->close(); }
bool hasWebDataServices() const
Web data services available?
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
db::CDatabaseWriter * getDatabaseWriter() const
DB writer class.
swift::misc::CStatusMessageList asyncAutoPublish(const swift::misc::simulation::CAutoPublishData &data) const
Auto publish to database.
swift::misc::simulation::CAircraftModelList getModels() const
Models.
static QDialog * findParentDialog(QWidget *widget)
Find parent dialog if there is any, otherwise null.
bool showOverlayHTMLMessage(const QString &htmlMessage, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
HTML message.
void showOverlayMessages(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages.
void showOverlayMessagesWithConfirmation(const swift::misc::CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function< void()> okLambda, QMessageBox::StandardButton defaultButton=QMessageBox::Cancel, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages with confirmation bar.
Using this class provides a QFrame with the overlay functionality already integrated.
Data automatically collected and be be sent to backend.
bool isEmpty() const
Data empty.
virtual ~CAutoPublishComponent()
Destructor.
int readFiles()
Read the files.
void push_back(const T &value)
Appends an element at the end of the sequence.
Status messages, e.g. from Core -> GUI.
bool hasErrorMessages() const
Error messages.
Value object encapsulating a list of aircraft models.
bool isEmpty() const
Any data?
CStatusMessageList analyzeAgainstDBData(const CAircraftModelList &dbModels)
Analyze against DB data.
int readFromJsonFiles(const QString &dirPath=CSwiftDirectories::logDirectory())
Read all JSON files matching the base name.
QString getSummary() const
Summary.
QString toDatabaseJson() const
Simple database JSON.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Classes interacting with the swift database (aka "datastore").
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...