Improvements

Implemented 'refreshLogsList' as thread.
Implemented drawStats as QTimers.
Code improvements.
This commit is contained in:
Valentino Orlandi 2022-08-19 22:42:58 +02:00
parent d9c966704c
commit 095d572029
Signed by: elB4RTO
GPG key ID: 1719E976DB2D4E71
2 changed files with 523 additions and 279 deletions

View file

@ -110,6 +110,14 @@ MainWindow::MainWindow(QWidget *parent)
this->defineOSspec();
this->readConfigs();
if ( this->language != "en" ) {
this->ui->actionEnglish->setChecked( false );
if ( language == "es" ) {
this->ui->actionEspanol->setChecked( true );
} else if ( language == "fr" ) {
this->ui->actionFrancais->setChecked( true );
} else if ( language == "it" ) {
this->ui->actionItaliano->setChecked( true );
}
this->updateUiLanguage();
}
if ( this->window_theme_id != 0 ) {
@ -1152,69 +1160,140 @@ void MainWindow::menu_actionCheckUpdates_triggered()
}
////////////
//// DB ////
////////////
void MainWindow::setDbWorkingState( const bool& state )
{
this->db_working = state;
if ( state == false ) {
this->checkMakeStats_Makable();
if ( this->ui->table_StatsWarn->rowCount() > 0 ) {
this->ui->button_StatsWarn_Update->setEnabled( true );
}
this->checkStatsWarnDrawable();
this->checkStatsCountDrawable();
this->checkStatsSpeedDrawable();
this->checkStatsDayDrawable();
this->checkStatsRelatDrawable();
this->ui->button_StatsGlob_Apache->setEnabled( true );
this->ui->button_StatsGlob_Nginx->setEnabled( true );
this->ui->button_StatsGlob_Iis->setEnabled( true );
this->ui->Set->setEnabled( true );
} else {
this->ui->button_MakeStats_Start->setEnabled( false );
this->ui->button_StatsWarn_Update->setEnabled( false );
this->ui->button_StatsWarn_Draw->setEnabled( false );
this->ui->scrollArea_StatsCount->setEnabled( false );
this->ui->button_StatsSpeed_Draw->setEnabled( false );
this->ui->button_StatsDay_Draw->setEnabled( false );
this->ui->button_StatsRelat_Draw->setEnabled( false );
this->ui->button_StatsGlob_Apache->setEnabled( false );
this->ui->button_StatsGlob_Nginx->setEnabled( false );
this->ui->button_StatsGlob_Iis->setEnabled( false );
this->ui->Set->setEnabled( false );
}
}
//////////////
//// LOGS ////
//////////////
// check
void MainWindow::checkMakeStats_Makable()
{
if ( this->db_working == true
|| this->ui->checkBox_LogFiles_CheckAll->checkState() == Qt::CheckState::Unchecked ) {
// none checked or db is busy
this->ui->button_MakeStats_Start->setEnabled( false );
} else {
// at least one is checked
this->ui->button_MakeStats_Start->setEnabled( true );
}
}
// switch to apache web server
void MainWindow::on_button_LogFiles_Apache_clicked()
{
if ( this->craplog.getCurrentWSID() != 11 ) {
// enable the enables
// flat/unflat
this->ui->button_LogFiles_Apache->setFlat( false );
this->ui->button_LogFiles_Nginx->setFlat( true );
this->ui->button_LogFiles_Iis->setFlat( true );
// load the list
// set the WebServer
this->craplog.setCurrentWSID( 11 );
this->on_button_LogFiles_RefreshList_clicked();
// reset the log files viewer
QString rich_text;
RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text );
rich_text.clear();
// load the list
this->on_button_LogFiles_RefreshList_clicked();
}
}
// switch to nginx web server
void MainWindow::on_button_LogFiles_Nginx_clicked()
{
if ( this->craplog.getCurrentWSID() != 12 ) {
// enable the enables
// flat/unflat
this->ui->button_LogFiles_Nginx->setFlat( false );
this->ui->button_LogFiles_Apache->setFlat( true );
this->ui->button_LogFiles_Iis->setFlat( true );
// load the list
// set the WebServer
this->craplog.setCurrentWSID( 12 );
this->on_button_LogFiles_RefreshList_clicked();
// reset the log files viewer
QString rich_text;
RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text );
rich_text.clear();
// load the list
this->on_button_LogFiles_RefreshList_clicked();
}
}
// switch to iis web server
void MainWindow::on_button_LogFiles_Iis_clicked()
{
if ( this->craplog.getCurrentWSID() != 13 ) {
// load the list
// flat/unflat
this->ui->button_LogFiles_Iis->setFlat( false );
this->ui->button_LogFiles_Apache->setFlat( true );
this->ui->button_LogFiles_Nginx->setFlat( true );
// load the list
// set the WebServer
this->craplog.setCurrentWSID( 13 );
this->on_button_LogFiles_RefreshList_clicked();
// reset the log files viewer
QString rich_text;
RichText::richLogsDefault( rich_text );
this->ui->textLogFiles->setText( rich_text );
rich_text.clear();
// load the list
this->on_button_LogFiles_RefreshList_clicked();
}
}
// refresh the log files list
void MainWindow::on_button_LogFiles_RefreshList_clicked()
{
std::string col;
// clear the current tree
this->ui->listLogFiles->clear();
this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked );
// disable elements
this->ui->button_LogFiles_RefreshList->setEnabled( false );
this->ui->button_LogFiles_Apache->setEnabled( false );
this->ui->button_LogFiles_Nginx->setEnabled( false );
this->ui->button_LogFiles_Iis->setEnabled( false );
// start refreshing as thread
this->refreshing_list = true;
this->craplog_thread = std::thread( &MainWindow::refreshLogsList, this );
// periodically check if thread finished
this->craplog_timer = new QTimer(this);
connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(check_CraplogLLT_Finished()));
this->craplog_timer->start(250);
}
void MainWindow::refreshLogsList()
{
std::string col;
// iterate over elements of list
for ( const Craplog::LogFile& log_file : this->craplog.getLogsList(true) ) {
// new entry for the tree widget
@ -1255,23 +1334,34 @@ void MainWindow::on_button_LogFiles_RefreshList_clicked()
this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked );
this->ui->checkBox_LogFiles_CheckAll->setEnabled( false );
}
refreshing_list = false;
}
void MainWindow::check_CraplogLLT_Finished()
{
if ( this->refreshing_list == false ) {
this->craplog_timer->stop();
this->craplog_thread.join();
// back to normal state
this->ui->button_LogFiles_RefreshList->setEnabled( true );
this->ui->button_LogFiles_Apache->setEnabled( true );
this->ui->button_LogFiles_Nginx->setEnabled( true );
this->ui->button_LogFiles_Iis->setEnabled( true );
}
}
void MainWindow::on_checkBox_LogFiles_CheckAll_stateChanged(int arg1)
{
this->checkMakeStats_Makable();
Qt::CheckState new_state;
if ( this->ui->checkBox_LogFiles_CheckAll->checkState() == Qt::CheckState::Checked ) {
if ( arg1 == Qt::CheckState::Checked ) {
// check all
new_state = Qt::CheckState::Checked;
this->ui->button_MakeStats_Start->setEnabled(true);
} else if ( this->ui->checkBox_LogFiles_CheckAll->checkState() == Qt::CheckState::Unchecked ) {
} else if ( arg1 == Qt::CheckState::Unchecked ) {
// un-check all
new_state = Qt::CheckState::Unchecked;
this->ui->button_MakeStats_Start->setEnabled(false);
} else {
// do nothing
this->ui->button_MakeStats_Start->setEnabled(true);
return;
}
QTreeWidgetItemIterator i(this->ui->listLogFiles);
@ -1379,6 +1469,7 @@ void MainWindow::on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column)
void MainWindow::on_button_MakeStats_Start_clicked()
{
if ( this->db_working == false ) {
bool proceed = true;
// check that the format has been set
const FormatOps::LogsFormat& lf = this->craplog.getLogsFormat( this->craplog.getCurrentWSID() );
@ -1390,7 +1481,7 @@ void MainWindow::on_button_MakeStats_Start_clicked()
// no field, useless to parse
proceed = false;
DialogSec::errLogFormatNoFields( nullptr );
} else if ( lf.separators.size() < lf.fields.size()-2 ) {
} else if ( lf.separators.size() < lf.fields.size()-1 ) {
// missing at least a separator between two (or more) fields
proceed = false;
DialogSec::errLogFormatNoSeparators( nullptr );
@ -1436,6 +1527,7 @@ void MainWindow::on_button_MakeStats_Start_clicked()
}
}
}
}
void MainWindow::reset_MakeStats_labels()
{
@ -1488,8 +1580,8 @@ void MainWindow::craplogStarted()
this->craplog.logOps.resetPerfData();
// disable the LogFiles section
this->ui->LogBoxFiles->setEnabled(false);
// disable the start button
this->ui->button_MakeStats_Start->setEnabled(false);
// disable things which needs database access
this->setDbWorkingState( true );
// enable all labels (needed only the first time)
this->ui->icon_MakeStats_Size->setEnabled( false );
this->ui->label_MakeStats_Size->setEnabled( true );
@ -1499,9 +1591,6 @@ void MainWindow::craplogStarted()
this->ui->label_MakeStats_Time->setEnabled( true );
this->ui->icon_MakeStats_Speed->setEnabled( false );
this->ui->label_MakeStats_Speed->setEnabled( true );
// disable the stats/settings tab
this->ui->View->setEnabled(false);
this->ui->Set->setEnabled(false);
}
void MainWindow::craplogFinished()
@ -1524,9 +1613,8 @@ void MainWindow::craplogFinished()
this->ui->icon_MakeStats_Lines->setEnabled( true );
this->ui->icon_MakeStats_Time->setEnabled( true );
this->ui->icon_MakeStats_Speed->setEnabled( true );
// enable back the stats/settings tab
this->ui->View->setEnabled(true);
this->ui->Set->setEnabled(true);
// enable back
this->setDbWorkingState( false );
// get a fresh collection of available stats dates
this->refreshStatsDates();
}
@ -1552,6 +1640,7 @@ void MainWindow::refreshStatsDates()
//// WARN ////
void MainWindow::checkStatsWarnDrawable()
{
if ( this->db_working == false ) {
if ( this->ui->box_StatsWarn_Year->currentIndex() >= 0
&& this->ui->box_StatsWarn_Month->currentIndex() >= 0
&& this->ui->box_StatsWarn_Day->currentIndex() >= 0 ) {
@ -1561,6 +1650,9 @@ void MainWindow::checkStatsWarnDrawable()
// disable the draw button
this->ui->button_StatsWarn_Draw->setEnabled( false );
}
} else {
this->ui->button_StatsRelat_Draw->setEnabled( false );
}
}
void MainWindow::on_box_StatsWarn_WebServer_currentIndexChanged(int index)
@ -1636,6 +1728,15 @@ void MainWindow::on_box_StatsWarn_Hour_currentIndexChanged(int index)
void MainWindow::on_button_StatsWarn_Draw_clicked()
{
if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsWarn()));
this->crapview_timer->start(250);
}
}
void MainWindow::drawStatsWarn()
{
this->ui->table_StatsWarn->setRowCount(0);
this->crapview.drawWarn(
this->ui->table_StatsWarn, this->ui->chart_StatsWarn,
@ -1645,8 +1746,7 @@ void MainWindow::on_button_StatsWarn_Draw_clicked()
this->ui->box_StatsWarn_Month->currentText(),
this->ui->box_StatsWarn_Day->currentText(),
(this->ui->checkBox_StatsWarn_Hour->isChecked()) ? this->ui->box_StatsWarn_Hour->currentText() : "" );
this->ui->button_StatsWarn_Update->setEnabled( true );
}
this->setDbWorkingState( false );
}
@ -1662,6 +1762,7 @@ void MainWindow::on_button_StatsWarn_Update_clicked()
//// SPEED ////
void MainWindow::checkStatsSpeedDrawable()
{
if ( this->db_working == false ) {
if ( this->ui->box_StatsSpeed_Year->currentIndex() >= 0
&& this->ui->box_StatsSpeed_Month->currentIndex() >= 0
&& this->ui->box_StatsSpeed_Day->currentIndex() >= 0 ) {
@ -1671,6 +1772,9 @@ void MainWindow::checkStatsSpeedDrawable()
// disable the draw button
this->ui->button_StatsSpeed_Draw->setEnabled( false );
}
} else {
this->ui->button_StatsRelat_Draw->setEnabled( false );
}
}
void MainWindow::on_box_StatsSpeed_WebServer_currentIndexChanged(int index)
@ -1722,6 +1826,15 @@ void MainWindow::on_box_StatsSpeed_Day_currentIndexChanged(int index)
void MainWindow::on_button_StatsSpeed_Draw_clicked()
{
if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsSpeed()));
this->crapview_timer->start(250);
}
}
void MainWindow::drawStatsSpeed()
{
this->ui->table_StatsSpeed->setRowCount(0);
this->crapview.drawSpeed(
this->ui->table_StatsSpeed,
@ -1736,7 +1849,7 @@ void MainWindow::on_button_StatsSpeed_Draw_clicked()
this->crapview.parseTextualFilter( this->ui->inLine_StatsSpeed_Uri->text() ),
this->crapview.parseTextualFilter( this->ui->inLine_StatsSpeed_Query->text() ),
this->crapview.parseNumericFilter( this->ui->inLine_StatsSpeed_Response->text() ) );
}
this->setDbWorkingState( false );
}
@ -1744,6 +1857,7 @@ void MainWindow::on_button_StatsSpeed_Draw_clicked()
//// COUNT ////
void MainWindow::checkStatsCountDrawable()
{
if ( this->db_working == false ) {
if ( this->ui->box_StatsCount_Year->currentIndex() >= 0
&& this->ui->box_StatsCount_Month->currentIndex() >= 0
&& this->ui->box_StatsCount_Day->currentIndex() >= 0 ) {
@ -1753,6 +1867,9 @@ void MainWindow::checkStatsCountDrawable()
// disable the draw button
this->ui->scrollArea_StatsCount->setEnabled( false );
}
} else {
this->ui->button_StatsRelat_Draw->setEnabled( false );
}
}
void MainWindow::on_box_StatsCount_WebServer_currentIndexChanged(int index)
@ -1835,59 +1952,113 @@ void MainWindow::resetStatsCountButtons()
void MainWindow::on_button_StatsCount_Protocol_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Protocol->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Protocol->text();
this->ui->button_StatsCount_Protocol->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Method_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Method->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Method->text();
this->ui->button_StatsCount_Method->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Request_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Request->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Request->text();
this->ui->button_StatsCount_Request->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Query_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Query->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Query->text();
this->ui->button_StatsCount_Query->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Response_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Response->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Response->text();
this->ui->button_StatsCount_Response->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Referrer_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Referrer->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Referrer->text();
this->ui->button_StatsCount_Referrer->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Cookie_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Cookie->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Cookie->text();
this->ui->button_StatsCount_Cookie->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_UserAgent_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_UserAgent->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_UserAgent->text();
this->ui->button_StatsCount_UserAgent->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsCount_Client_clicked()
{
this->drawStatsCount( this->ui->button_StatsCount_Client->text() );
this->resetStatsCountButtons();
this->count_fld = this->ui->button_StatsCount_Client->text();
this->ui->button_StatsCount_Client->setFlat( false );
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount()));
this->crapview_timer->start(250);
}
void MainWindow::drawStatsCount( const QString& field )
void MainWindow::drawStatsCount()
{
this->ui->table_StatsCount->setRowCount(0);
this->crapview.drawCount(
@ -1895,8 +2066,8 @@ void MainWindow::drawStatsCount( const QString& field )
this->CHARTS_THEMES.at( this->charts_theme_id ), this->FONTS,
this->ui->box_StatsCount_WebServer->currentText(),
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
field );
this->resetStatsCountButtons();
this->count_fld );
this->setDbWorkingState( false );
}
@ -1904,6 +2075,7 @@ void MainWindow::drawStatsCount( const QString& field )
//// DAY ////
void MainWindow::checkStatsDayDrawable()
{
if ( this->db_working == false ) {
bool aux = true;
// secondary date (period)
if ( this->ui->checkBox_StatsDay_Period->isChecked() == true ) {
@ -1946,6 +2118,11 @@ void MainWindow::checkStatsDayDrawable()
aux = false;
}
this->ui->button_StatsDay_Draw->setEnabled( aux);
} else {
// db busy
this->ui->button_StatsRelat_Draw->setEnabled( false );
}
}
void MainWindow::on_box_StatsDay_WebServer_currentIndexChanged(int index)
@ -2069,6 +2246,15 @@ void MainWindow::on_box_StatsDay_ToDay_currentIndexChanged(int index)
void MainWindow::on_button_StatsDay_Draw_clicked()
{
if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsDay()));
this->crapview_timer->start(250);
}
}
void MainWindow::drawStatsDay()
{
QString filter;
if ( this->ui->box_StatsDay_LogsField->currentIndex() == 0 ) {
filter = this->crapview.parseBooleanFilter( this->ui->inLine_StatsDay_Filter->text() );
@ -2089,7 +2275,7 @@ void MainWindow::on_button_StatsDay_Draw_clicked()
( this->ui->checkBox_StatsDay_Period->isChecked() ) ? this->ui->box_StatsDay_ToDay->currentText() : "",
this->ui->box_StatsDay_LogsField->currentText(),
filter );
}
this->setDbWorkingState( false );
}
@ -2098,6 +2284,7 @@ void MainWindow::on_button_StatsDay_Draw_clicked()
//// RELATIONAL ////
void MainWindow::checkStatsRelatDrawable()
{
if ( this->db_working == false ) {
bool aux = true;
if ( this->ui->box_StatsRelat_FromYear->currentIndex() >= 0
&& this->ui->box_StatsRelat_FromMonth->currentIndex() >= 0
@ -2137,6 +2324,11 @@ void MainWindow::checkStatsRelatDrawable()
aux = false;
}
this->ui->button_StatsRelat_Draw->setEnabled( aux );
} else {
// db busy
this->ui->button_StatsRelat_Draw->setEnabled( false );
}
}
void MainWindow::on_box_StatsRelat_WebServer_currentIndexChanged(int index)
@ -2248,6 +2440,15 @@ void MainWindow::on_box_StatsRelat_ToDay_currentIndexChanged(int index)
void MainWindow::on_button_StatsRelat_Draw_clicked()
{
if ( this->checkDataDB() == true ) {
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsRelat()));
this->crapview_timer->start(250);
}
}
void MainWindow::drawStatsRelat()
{
int aux;
QString filter1, filter2;
aux = this->ui->box_StatsRelat_LogsField_1->currentIndex();
@ -2278,7 +2479,7 @@ void MainWindow::on_button_StatsRelat_Draw_clicked()
this->ui->box_StatsRelat_ToDay->currentText(),
this->ui->box_StatsRelat_LogsField_1->currentText(), filter1,
this->ui->box_StatsRelat_LogsField_2->currentText(), filter2 );
}
this->setDbWorkingState( false );
}
@ -2286,7 +2487,7 @@ void MainWindow::on_button_StatsRelat_Draw_clicked()
////////////////
//// GLOBAL ////
//
void MainWindow::makeStatsGlobals( const QString& web_server )
void MainWindow::makeStatsGlobals()
{
if ( this->checkDataDB() == true ) {
std::vector<std::tuple<QString,QString>> recur_list;
@ -2296,7 +2497,7 @@ void MainWindow::makeStatsGlobals( const QString& web_server )
const bool result = this->crapview.calcGlobals(
recur_list, traffic_list, perf_list, work_list,
web_server );
this->glob_ws );
if ( result == true ) {
this->ui->label_StatsGlob_Recur_Protocol_String->setText( std::get<0>( recur_list.at(0) ) );
@ -2326,6 +2527,29 @@ void MainWindow::makeStatsGlobals( const QString& web_server )
this->ui->label_StatsGlob_Work_Time_Count->setText( work_list.at(1) );
this->ui->label_StatsGlob_Work_Sent_Count->setText( work_list.at(2) );
if ( this->glob_ws == "Apache2" ) {
if ( this->ui->button_StatsGlob_Apache->isFlat() == true ) {
// un-flat
this->ui->button_StatsGlob_Apache->setFlat( false );
this->ui->button_StatsGlob_Nginx->setFlat( true );
this->ui->button_StatsGlob_Iis->setFlat( true );
}
} else if ( this->glob_ws == "Nginx" ) {
if ( this->ui->button_StatsGlob_Nginx->isFlat() == true ) {
// un-flat
this->ui->button_StatsGlob_Nginx->setFlat( false );
this->ui->button_StatsGlob_Apache->setFlat( true );
this->ui->button_StatsGlob_Iis->setFlat( true );
}
} else if ( this->glob_ws == "IIS" ) {
if ( this->ui->button_StatsGlob_Iis->isFlat() == true ) {
// un-flat
this->ui->button_StatsGlob_Iis->setFlat( false );
this->ui->button_StatsGlob_Apache->setFlat( true );
this->ui->button_StatsGlob_Nginx->setFlat( true );
}
}
} else {
this->resetStatsGlobals();
}
@ -2335,6 +2559,8 @@ void MainWindow::makeStatsGlobals( const QString& web_server )
} else {
this->resetStatsGlobals();
}
// restore
this->setDbWorkingState( false );
}
void MainWindow::resetStatsGlobals()
@ -2379,37 +2605,34 @@ void MainWindow::resetStatsGlobals()
void MainWindow::on_button_StatsGlob_Apache_clicked()
{
this->makeStatsGlobals( "Apache2" );
if ( this->ui->button_StatsGlob_Apache->isFlat() == true ) {
// un-flat
this->ui->button_StatsGlob_Apache->setFlat( false );
this->ui->button_StatsGlob_Nginx->setFlat( true );
this->ui->button_StatsGlob_Iis->setFlat( true );
}
this->glob_ws = "Apache2";
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsGlob_Nginx_clicked()
{
this->makeStatsGlobals( "Nginx" );
if ( this->ui->button_StatsGlob_Nginx->isFlat() == true ) {
// un-flat
this->ui->button_StatsGlob_Nginx->setFlat( false );
this->ui->button_StatsGlob_Apache->setFlat( true );
this->ui->button_StatsGlob_Iis->setFlat( true );
}
this->glob_ws = "Nginx";
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals()));
this->crapview_timer->start(250);
}
void MainWindow::on_button_StatsGlob_Iis_clicked()
{
this->makeStatsGlobals( "IIS" );
if ( this->ui->button_StatsGlob_Iis->isFlat() == true ) {
// un-flat
this->ui->button_StatsGlob_Iis->setFlat( false );
this->ui->button_StatsGlob_Apache->setFlat( true );
this->ui->button_StatsGlob_Nginx->setFlat( true );
}
this->glob_ws = "IIS";
this->setDbWorkingState( true );
this->crapview_timer = new QTimer(this);
this->crapview_timer->setSingleShot( true );
connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals()));
this->crapview_timer->start(250);
}

View file

@ -44,6 +44,8 @@ private slots:
void update_Craplog_PerfData();
void check_CraplogLLT_Finished();
// Qt's
/////////////////
//// CRAPLOG ////
@ -69,6 +71,18 @@ private slots:
//////////////////
//// CRAPVIEW ////
void drawStatsWarn();
void drawStatsSpeed();
void drawStatsCount();
void drawStatsDay();
void drawStatsRelat();
void makeStatsGlobals();
//// WARNINGS ////
void on_box_StatsWarn_WebServer_currentIndexChanged(int index);
@ -525,6 +539,9 @@ private:
///////////////////
std::string db_data_path,
db_hashes_path;
// actions when working on a db
bool db_working = false;
void setDbWorkingState( const bool& state );
/////////////////
@ -537,6 +554,7 @@ private:
std::chrono::system_clock::duration craplog_timer_elapsed;
void craplogStarted();
void craplogFinished();
void checkMakeStats_Makable();
//////////////
//// LOGS ////
@ -546,6 +564,8 @@ private:
enableAllButtons_LogFiles_WS();
// logs list related
bool hide_used_files = false;
bool refreshing_list = false;
void refreshLogsList();
// text browser related
TextBrowser TB;
@ -561,6 +581,8 @@ private:
//// CRAPVIEW ////
//////////////////
Crapview crapview;
/*std::thread crapview_thread;*/
QTimer *crapview_timer;
// refresh dates: query a new collection from the db and apply to the tabs
void refreshStatsDates();
// check if drawing conditions are met
@ -569,12 +591,11 @@ private:
void checkStatsCountDrawable();
void checkStatsDayDrawable();
void checkStatsRelatDrawable();
// polishing
// count
QString count_fld;
void resetStatsCountButtons();
// draw
void drawStatsCount( const QString& field );
// globals
void makeStatsGlobals( const QString& web_server );
QString glob_ws;
void resetStatsGlobals();