Add and use m_updateSteps.

This commit is contained in:
Gerhard Hoffmann 2025-02-24 16:16:00 +01:00
parent b5067ce044
commit 3069c3bd65
2 changed files with 119 additions and 123 deletions

View File

@ -16,6 +16,15 @@
#include <QColor>
#include <QColorDialog>
#define CHECK_BACKEND_CONNECTION 0
#define CHECK_UPDATE_REQUEST 1
#define UPDATE_CUSTOMER_REPOSITORY 2
#define INSTALL_SW_PACKETS_DRY_RUN 3
#define INSTALL_SW_PACKETS 4
#define INSTALL_DC_CONFIGURATION 5
#define SYNCHRONIZE_REPOSITORY 6
#define UPDATE_DC 7
MainWindow::MainWindow(Worker *worker, QWidget *parent)
: QMainWindow(parent)
@ -27,6 +36,25 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
ui->setupUi(this);
m_updateSteps.resize(8);
m_updateSteps[CHECK_BACKEND_CONNECTION] = "Check backend connection (ISMAS) ";
m_updateSteps[CHECK_UPDATE_REQUEST] = "Check update request ";
m_updateSteps[UPDATE_CUSTOMER_REPOSITORY] = "Update customer repository ";
m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN] = "Install SW packets (dry run) ";
m_updateSteps[INSTALL_SW_PACKETS] = "Install SW packets ";
m_updateSteps[INSTALL_DC_CONFIGURATION] = "Install DC configuration ";
m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem ";
m_updateSteps[UPDATE_DC] = "Update DC";
for (int i = 0; i < m_updateSteps.size(); ++i) {
QString &tmp = m_updateSteps[i];
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
ui->stepLabel->setText(tmp + "\n");
}
this->setStatusBar(new QStatusBar(this));
QFont f;
f.setStyleHint(QFont::Monospace);
@ -149,81 +177,68 @@ void MainWindow::onShowTariffUpdate(QString) {
}
void MainWindow::onShowISMASConnectivity(QString status) {
// ausgabe: connected, not connected, connecting
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
m_stepLabelChopCount = 0;
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
QString tmp("Check backend connection (ISMAS) ");
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = m_updateSteps[CHECK_BACKEND_CONNECTION].trimmed();
bool const custRepoExists = internal::customerRepoExists();
if (status.contains(UpdateCommand::ISMAS_CONNECTED, Qt::CaseInsensitive)) {
if (custRepoExists) {
s += QString("%1 <font color='Green'>connected</font><br />").arg(tmp);
s += " <font color='Green'>connected</font>";
} else {
s += QString("%1 <font color='Green'>connected&nbsp;(initial configuration)</font><br />").arg(tmp);
s += " <font color='Green'>connected&nbsp;(initial configuration)</font>";
}
} else
if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Blue'>NOT CONNECTED</font><br />").arg(tmp);
s += " <font color='Blue'>NOT CONNECTED</font>";
} else
if (status.contains(UpdateCommand::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>connecting</font><br />").arg(tmp);
s += " <font color='Green'>connecting</font>";
} else
if (status.contains(UpdateCommand::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) {
if (custRepoExists) {
s += QString( "%1 <font color='Red'>NOT CONNECTED. STOP</font><br />").arg(tmp);
s += " <font color='Red'>NOT CONNECTED. STOP</font>";
} else {
s += QString( "%1 <font color='Red'>not connected.&nbsp;(initial configuration)</font><br />").arg(tmp);
s += " <font color='Red'>not connected.&nbsp;(initial configuration)</font>";
}
} else {
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN STATUS</font>";
}
m_stepLabelChopCount = -s.length();
s += "Check update request";
m_stepLabelChopCount += s.length();
m_updateSteps[CHECK_BACKEND_CONNECTION] = s;
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
s += m_updateSteps[i] + "<br />";
}
ui->stepLabel->setText(s);
}
void MainWindow::onShowCustRepoStatus(QString status) {
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
s.chop(m_stepLabelChopCount);
QString tmp("Update customer repository ");
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = m_updateSteps[UPDATE_CUSTOMER_REPOSITORY].trimmed();
if (status.contains(internal::GIT_CUSTOMER_REPO_UP_TO_DATE, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>%2</font><br />").arg(tmp).arg(internal::GIT_CUSTOMER_REPO_UP_TO_DATE);
s += QString(" <font color='Green'>%1</font>").arg(internal::GIT_CUSTOMER_REPO_UP_TO_DATE);
} else
if (status.contains(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>%2</font><br />").arg(tmp).arg(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY);
s += QString(" <font color='Green'>%1</font>").arg(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY);
} else {
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN STATUS</font>";
}
m_stepLabelChopCount = -s.length();
s += "Install SW packets (dry run)";
m_stepLabelChopCount += s.length();
m_updateSteps[UPDATE_CUSTOMER_REPOSITORY] = s;
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
s += m_updateSteps[i] + "<br />";
}
ui->stepLabel->setText(s);
}
void MainWindow::onShowExecOpkgStatus(QString status) {
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
return;
QString s = ui->stepLabel->text();
@ -245,6 +260,7 @@ void MainWindow::onShowExecOpkgStatus(QString status) {
void MainWindow::onShowExecOpkgCommand(QString cmd) {
qCritical() << __func__ << ":" << __LINE__ << "cmd" << cmd;
return;
if (cmd.back() != QChar('\n')) {
cmd += "\n";
@ -253,158 +269,132 @@ void MainWindow::onShowExecOpkgCommand(QString cmd) {
}
void MainWindow::onShowExecOpkgOverallResult(QString status, bool noaction) {
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
//qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
s.chop(m_stepLabelChopCount);
QString tmp = noaction ? "Install SW packets (dry run) " : "Install SW packets ";
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = noaction ?
m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN].trimmed() :
m_updateSteps[INSTALL_SW_PACKETS].trimmed();
if (status.contains(internal::EXEC_OPKG_COMMANDS_SUCCESS, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>success</font><br />").arg(tmp);
s += " <font color='Green'>success</font>";
} else
if (status.contains(internal::EXEC_OPKG_COMMANDS_FAIL, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Red'>%2</font><br />").arg(tmp).arg(internal::EXEC_OPKG_COMMANDS_FAIL);
s += QString(" <font color='Red'>%1</font>").arg(internal::EXEC_OPKG_COMMANDS_FAIL);
} else {
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN STATUS</font>";
}
if (noaction) {
m_stepLabelChopCount = -s.length();
s += "Install SW packets";
m_stepLabelChopCount += s.length();
m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN] = s;
} else {
m_stepLabelChopCount = -s.length();
s += "Install DC configuration";
m_stepLabelChopCount += s.length();
m_updateSteps[INSTALL_SW_PACKETS] = s;
}
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
s += m_updateSteps[i] + "<br />";
}
ui->stepLabel->setText(s);
}
void MainWindow::onShowDownloadDCJsonFilesStatus(QString status) {
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
//qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
s.chop(m_stepLabelChopCount);
QString tmp = "Install DC configuration ";
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = m_updateSteps[INSTALL_DC_CONFIGURATION].trimmed();
if (status.contains(UpdateCommand::UPDATE_DC_JSON_FILES_SUCCESS, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>success</font><br />").arg(tmp);
s += " <font color='Green'>success</font>";
} else {
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN STATUS</font>";
}
m_stepLabelChopCount = -s.length();
s += "Synchronize repository/filesystem";
m_stepLabelChopCount += s.length();
m_updateSteps[INSTALL_DC_CONFIGURATION] = s;
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
s += m_updateSteps[i] + "<br />";
}
ui->stepLabel->setText(s);
}
void MainWindow::onShowSyncCustRepoStatus(QString status) {
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
//qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
s.chop(m_stepLabelChopCount);
QString tmp = "Synchronize repository/filesystem ";
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = m_updateSteps[SYNCHRONIZE_REPOSITORY].trimmed();
if (status.contains(UpdateCommand::SYNC_CUSTOMER_REPO_FILES_SUCCESS, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>success</font><br />").arg(tmp);
s += " <font color='Green'>success</font>";
} else {
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN STATUS</font>";
}
m_stepLabelChopCount = -s.length();
s += "Update DC";
m_stepLabelChopCount += s.length();
m_updateSteps[SYNCHRONIZE_REPOSITORY] = s;
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
s += m_updateSteps[i] + "<br />";
}
ui->stepLabel->setText(s);
}
void MainWindow::onShowUpdateDCFirmware(QString status) {
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
s.chop(m_stepLabelChopCount);
QString tmp = "Update DC ";
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = m_updateSteps[UPDATE_DC].trimmed();
if (status.contains(UpdateCommand::UPDATE_DC_FIRMARE_SUCCESS, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>success</font><br />").arg(tmp);
s += " <font color='Green'>success</font>";
} else {
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN STATUS</font>";
}
m_updateSteps[UPDATE_DC] = s;
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
if (i != UPDATE_DC) {
s += m_updateSteps[i] + "<br />";
} else {
s += m_updateSteps[i];
}
}
ui->stepLabel->setText(s);
}
void MainWindow::onShowUpdateRequest(QString status) {
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
qCritical() << __func__ << ":" << __LINE__ << "status" << status;
QString s = ui->stepLabel->text();
s.chop(m_stepLabelChopCount);
QString tmp = "Check update request ";
int len = m_showLineLength - tmp.length();
while (--len > 0) {
tmp += "&nbsp;";
}
QString s = m_updateSteps[CHECK_UPDATE_REQUEST].trimmed();
bool const custRepoExists = internal::customerRepoExists();
if (status.contains(UpdateCommand::UPDATE_NOT_REQUESTED, Qt::CaseInsensitive)) {
if (custRepoExists) {
s += QString( "%1 <font color='Red'>NOT REQUESTED. STOP.</font><br />").arg(tmp);
s += " <font color='Red'>NOT REQUESTED. STOP.</font>";
} else {
s += QString("%1 <font color='Blue'>not requested&nbsp;(initial configuration)</font><br />").arg(tmp);
s += " <font color='Blue'>not requested&nbsp;(initial configuration)</font>";
}
} else
if (status.contains(UpdateCommand::UPDATE_REQUESTED, Qt::CaseInsensitive)) {
if (custRepoExists) {
s += QString("%1 <font color='Green'>requested</font><br />").arg(tmp);
s += " <font color='Green'>requested</font>";
} else {
s += QString("%1 <font color='Blue'>requested&nbsp;(initial configuration)</font><br />").arg(tmp);
s += " <font color='Blue'>requested&nbsp;(initial configuration)</font>";
}
} else
if (status.contains(UpdateCommand::UPDATE_NOT_NECESSARY, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Green'>not necessary</font><br />").arg(tmp);
s += " <font color='Green'>not necessary</font>";
} else
if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) {
s += QString("%1 <font color='Blue'>UNKNOWN (ISMAS not connected)</font><br />").arg(tmp);
s += " <font color='Blue'>UNKNOWN (ISMAS not connected)</font>";
} else {
s += QString( "%1 <font color='Red'>UNKNOWN</font><br />").arg(tmp);
s += " <font color='Red'>UNKNOWN</font>";
}
m_stepLabelChopCount = -s.length();
s += "Update customer repository";
m_stepLabelChopCount += s.length();
m_updateSteps[CHECK_UPDATE_REQUEST] = s;
s.clear();
for (int i = 0; i < m_updateSteps.size(); ++i) {
s += m_updateSteps[i] + "<br />";
}
ui->stepLabel->setText(s);
}
@ -412,6 +402,7 @@ void MainWindow::onShowISMASChecks(QString) {
// deprecated
QString s = ui->stepLabel->text();
return;
QString tmp("Check ISMAS connectivity ");
int len = m_showLineLength - tmp.length();

View File

@ -4,6 +4,8 @@
#include <QMainWindow>
#include <QTimer>
#include <QStatusBar>
#include <QVector>
#include <QString>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
@ -97,5 +99,8 @@ private:
QTimer *m_statusTimer;
QString m_targetDcVersion;
int m_stepLabelChopCount{};
QVector<QString> m_updateSteps{};
};
#endif // MAINWINDOW_H