diff --git a/src/blackgui/components/dbloadoverviewcomponent.cpp b/src/blackgui/components/dbloadoverviewcomponent.cpp index 837d0f5b7..fccaf36b4 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.cpp +++ b/src/blackgui/components/dbloadoverviewcomponent.cpp @@ -11,6 +11,7 @@ #include "ui_dbloadoverviewcomponent.h" #include "blackcore/webdataservices.h" +#include "blackcore/db/infodatareader.h" #include "blackgui/guiapplication.h" #include "blackmisc/network/networkutils.h" @@ -62,6 +63,7 @@ namespace BlackGui if (sGui->hasWebDataServices()) { connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbLoadOverviewComponent::ps_dataLoaded); + QTimer::singleShot(10 * 1000, this, &CDbLoadOverviewComponent::ps_loadInfoObjects); } } @@ -130,22 +132,6 @@ namespace BlackGui if (!sGui) { return; } if (!sGui->hasWebDataServices()) { return; } - ui->le_AircraftIcaoCacheTs->setText(cacheTimestampForEntity(CEntityFlags::AircraftIcaoEntity)); - ui->le_AirlinesIcaoCacheTs->setText(cacheTimestampForEntity(CEntityFlags::AirlineIcaoEntity)); - ui->le_AirportsCacheTs->setText(cacheTimestampForEntity(CEntityFlags::AirportEntity)); - ui->le_LiveriesCacheTs->setText(cacheTimestampForEntity(CEntityFlags::LiveryEntity)); - ui->le_ModelsCacheTs->setText(cacheTimestampForEntity(CEntityFlags::ModelEntity)); - ui->le_CountriesCacheTs->setText(cacheTimestampForEntity(CEntityFlags::CountryEntity)); - ui->le_DistributorsCacheTs->setText(cacheTimestampForEntity(CEntityFlags::DistributorEntity)); - - ui->le_AircraftIcaoDbTs->setText(dbTimestampForEntity(CEntityFlags::AircraftIcaoEntity)); - ui->le_AirlinesIcaoDbTs->setText(dbTimestampForEntity(CEntityFlags::AirlineIcaoEntity)); - ui->le_AirportsDbTs->setText(dbTimestampForEntity(CEntityFlags::AirportEntity)); - ui->le_LiveriesDbTs->setText(dbTimestampForEntity(CEntityFlags::LiveryEntity)); - ui->le_ModelsDbTs->setText(dbTimestampForEntity(CEntityFlags::ModelEntity)); - ui->le_CountriesDbTs->setText(dbTimestampForEntity(CEntityFlags::CountryEntity)); - ui->le_DistributorsDbTs->setText(dbTimestampForEntity(CEntityFlags::DistributorEntity)); - ui->le_AircraftIcaoCacheCount->setText(cacheCountForEntity(CEntityFlags::AircraftIcaoEntity)); ui->le_AirlinesIcaoCacheCount->setText(cacheCountForEntity(CEntityFlags::AirlineIcaoEntity)); ui->le_AirportsCacheCount->setText(cacheCountForEntity(CEntityFlags::AirportEntity)); @@ -162,8 +148,32 @@ namespace BlackGui ui->le_CountriesDbCount->setText(dbCountForEntity(CEntityFlags::CountryEntity)); ui->le_DistributorsDbCount->setText(dbCountForEntity(CEntityFlags::DistributorEntity)); - ui->le_AircraftSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::AircraftIcaoEntity)); - ui->le_AirlinesSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::AirlineIcaoEntity)); + ui->le_AircraftIcaoSharedCount->setText(sharedCountForEntity(CEntityFlags::AircraftIcaoEntity)); + ui->le_AirlinesIcaoSharedCount->setText(sharedCountForEntity(CEntityFlags::AirlineIcaoEntity)); + ui->le_AirportsSharedCount->setText(sharedCountForEntity(CEntityFlags::AirportEntity)); + ui->le_LiveriesSharedCount->setText(sharedCountForEntity(CEntityFlags::LiveryEntity)); + ui->le_ModelsSharedCount->setText(sharedCountForEntity(CEntityFlags::ModelEntity)); + ui->le_CountriesSharedCount->setText(sharedCountForEntity(CEntityFlags::CountryEntity)); + ui->le_DistributorsSharedCount->setText(sharedCountForEntity(CEntityFlags::DistributorEntity)); + + ui->le_AircraftIcaoCacheTs->setText(cacheTimestampForEntity(CEntityFlags::AircraftIcaoEntity)); + ui->le_AirlinesIcaoCacheTs->setText(cacheTimestampForEntity(CEntityFlags::AirlineIcaoEntity)); + ui->le_AirportsCacheTs->setText(cacheTimestampForEntity(CEntityFlags::AirportEntity)); + ui->le_LiveriesCacheTs->setText(cacheTimestampForEntity(CEntityFlags::LiveryEntity)); + ui->le_ModelsCacheTs->setText(cacheTimestampForEntity(CEntityFlags::ModelEntity)); + ui->le_CountriesCacheTs->setText(cacheTimestampForEntity(CEntityFlags::CountryEntity)); + ui->le_DistributorsCacheTs->setText(cacheTimestampForEntity(CEntityFlags::DistributorEntity)); + + ui->le_AircraftIcaoDbTs->setText(dbTimestampForEntity(CEntityFlags::AircraftIcaoEntity)); + ui->le_AirlinesIcaoDbTs->setText(dbTimestampForEntity(CEntityFlags::AirlineIcaoEntity)); + ui->le_AirportsDbTs->setText(dbTimestampForEntity(CEntityFlags::AirportEntity)); + ui->le_LiveriesDbTs->setText(dbTimestampForEntity(CEntityFlags::LiveryEntity)); + ui->le_ModelsDbTs->setText(dbTimestampForEntity(CEntityFlags::ModelEntity)); + ui->le_CountriesDbTs->setText(dbTimestampForEntity(CEntityFlags::CountryEntity)); + ui->le_DistributorsDbTs->setText(dbTimestampForEntity(CEntityFlags::DistributorEntity)); + + ui->le_AircraftIcaoSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::AircraftIcaoEntity)); + ui->le_AirlinesIcaoSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::AirlineIcaoEntity)); ui->le_AirportsSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::AirportEntity)); ui->le_LiveriesSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::LiveryEntity)); ui->le_ModelsSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::ModelEntity)); @@ -231,13 +241,19 @@ namespace BlackGui QString CDbLoadOverviewComponent::sharedFileTimestampForEntity(CEntityFlags::Entity entity) { - const QDateTime ts = sGui->getWebDataServices()->getSharedFileTimestamp(entity); + const QDateTime ts = sGui->getWebDataServices()->getSharedInfoObjectTimestamp(entity); return formattedTimestamp(ts); } + QString CDbLoadOverviewComponent::sharedCountForEntity(CEntityFlags::Entity entity) + { + const int c = sGui->getWebDataServices()->getSharedInfoObjectCount(entity); + return c < 0 ? "-" : QString::number(c); + } + QString CDbLoadOverviewComponent::dbCountForEntity(CEntityFlags::Entity entity) { - const int c = sGui->getWebDataServices()->getDbInfoCount(entity); + const int c = sGui->getWebDataServices()->getDbInfoObjectCount(entity); return c < 0 ? "-" : QString::number(c); } @@ -266,8 +282,8 @@ namespace BlackGui this->showLoading(); // shared files ts - sGui->getWebDataServices()->triggerLoadingOfSharedFilesHeaders(entities); - sGui->getWebDataServices()->triggerReadOfInfoObjects(); + sGui->getWebDataServices()->triggerReadOfSharedInfoObjects(); + sGui->getWebDataServices()->triggerReadOfDbInfoObjects(); } void CDbLoadOverviewComponent::ps_refreshSharedPressed() @@ -289,18 +305,48 @@ namespace BlackGui this->showLoading(); // shared files ts - sGui->getWebDataServices()->triggerReadOfInfoObjects(); + sGui->getWebDataServices()->triggerReadOfDbInfoObjects(); } void CDbLoadOverviewComponent::ps_dataLoaded(CEntityFlags::Entity entities, CEntityFlags::ReadState state, int number) { Q_UNUSED(number); - if (!entities.testFlag(CEntityFlags::InfoObjectEntity) && !CEntityFlags::anySwiftDbEntity(entities)) { return; } + if (!entities.testFlag(CEntityFlags::SharedInfoObjectEntity) && !entities.testFlag(CEntityFlags::DbInfoObjectEntity) && !CEntityFlags::anySwiftDbEntity(entities)) { return; } if (state == CEntityFlags::ReadFinished || state == CEntityFlags::ReadFinishedRestricted) { this->m_loadInProgress = false; emit this->ps_triggerDigestGuiUpdate(); } } + + void CDbLoadOverviewComponent::ps_loadInfoObjects() + { + if (this->m_loadInProgress) { return; } + if (!sGui || !sGui->hasWebDataServices()) { return; } + bool direct = false; + + if (sGui->getWebDataServices()->getDbInfoDataReader() && sGui->getWebDataServices()->getDbInfoDataReader()->getInfoObjectCount() > 0) + { + direct = true; + } + else + { + sGui->getWebDataServices()->triggerReadOfDbInfoObjects(); + } + + if (sGui->getWebDataServices()->getSharedInfoDataReader() && sGui->getWebDataServices()->getSharedInfoDataReader()->getInfoObjectCount() > 0) + { + direct = true; + } + else + { + sGui->getWebDataServices()->triggerReadOfSharedInfoObjects(); + } + + if (direct) + { + this->m_dsTriggerGuiUpdate.inputSignal(); + } + } } // ns } // ns diff --git a/src/blackgui/components/dbloadoverviewcomponent.h b/src/blackgui/components/dbloadoverviewcomponent.h index 2d402f6d1..1cf61abfd 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.h +++ b/src/blackgui/components/dbloadoverviewcomponent.h @@ -83,20 +83,23 @@ namespace BlackGui //! Timestamp static QString formattedTimestamp(const QDateTime &dateTime); - //! Formatted ts for entity + //! Formatted ts for entity (cache) static QString cacheTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); - //! Formatted ts for entity - static QString dbTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); - - //! Formatted count for entity + //! Formatted count for entity (cache) static QString cacheCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); - //! Formatted ts for entity + //! Formatted ts for entity (DB) + static QString dbTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); + + //! Formatted count for entity (DB) + static QString dbCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); + + //! Formatted ts for entity (shared) static QString sharedFileTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); - //! Formatted count for entity - static QString dbCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); + //! Formatted count for entity (shared) + static QString sharedCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Admit caches static void admitCaches(); @@ -113,6 +116,9 @@ namespace BlackGui //! Data have been loaded void ps_dataLoaded(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Network::CEntityFlags::ReadState state, int number); + + //! Load info objects if not already loaded + void ps_loadInfoObjects(); }; } // ns } // ns diff --git a/src/blackgui/components/dbloadoverviewcomponent.ui b/src/blackgui/components/dbloadoverviewcomponent.ui index a81f08086..95d3b4647 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.ui +++ b/src/blackgui/components/dbloadoverviewcomponent.ui @@ -6,8 +6,8 @@ 0 0 - 626 - 283 + 712 + 273 @@ -27,8 +27,18 @@ 2 - 4 + 3 + + + + true + + + count + + + @@ -55,7 +65,7 @@ - + @@ -71,16 +81,6 @@ - - - - true - - - count - - - @@ -91,7 +91,23 @@ - + + + + + 100 + 0 + + + + true + + + File ts + + + + @@ -107,19 +123,13 @@ - - - - - 100 - 0 - - + + true - File ts + count @@ -137,7 +147,7 @@ - + @@ -153,7 +163,7 @@ - + @@ -169,7 +179,7 @@ - + @@ -202,7 +212,14 @@ - + + + + Models: + + + + @@ -218,14 +235,7 @@ - - - - Models: - - - - + @@ -241,6 +251,62 @@ + + + + Checking DB URL + + + + + + + Checking shared servers' URLs + + + + + + + + 60 + 0 + + + + shared count + + + S#: + + + + + + + true + + + count + + + + + + + + 100 + 0 + + + + true + + + cache ts + + + @@ -261,33 +327,7 @@ - - - - - 100 - 0 - - - - true - - - cache ts - - - - - - - true - - - count - - - - + @@ -303,22 +343,6 @@ - - - - - 100 - 0 - - - - true - - - DB ts - - - @@ -326,7 +350,23 @@ - + + + + + 100 + 0 + + + + true + + + DB ts + + + + @@ -342,7 +382,7 @@ - + @@ -358,6 +398,26 @@ + + + + true + + + count + + + + + + + true + + + count + + + @@ -365,7 +425,7 @@ - + @@ -381,7 +441,7 @@ - + @@ -397,73 +457,14 @@ - - - - true - - - count - - - - - - - true - - - count - - - - - - - Aircraft: - - - - + DB ts: - - - - - 100 - 0 - - - - true - - - DB ts - - - - - - - - 100 - 0 - - - - true - - - DB ts - - - - + @@ -479,7 +480,60 @@ - + + + + + 100 + 0 + + + + true + + + DB ts + + + + + + + + 100 + 0 + + + + true + + + DB ts + + + + + + + Aircraft: + + + + + + + Airports: + + + + + + + Shared: + + + + Shared ts: @@ -506,20 +560,6 @@ - - - - Airports: - - - - - - - Shared: - - - @@ -530,8 +570,8 @@ - - + + 48 @@ -570,6 +610,26 @@ + + + + + 48 + 16777215 + + + + refresh from shared files + + + ... + + + + :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png + + + @@ -590,36 +650,6 @@ - - - - - 48 - 16777215 - - - - refresh from shared files - - - ... - - - - :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png - - - - - - - Shared - - - Shr.: - - - @@ -667,40 +697,13 @@ - - - - - 48 - 16777215 - - + + - refresh from shared files + Shared - ... - - - - :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png - - - - - - - - 48 - 16777215 - - - - refresh from database - - - - :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png + Shr.: @@ -744,18 +747,8 @@ - - - - true - - - count - - - - - + + 48 @@ -763,10 +756,10 @@ - refresh from database + refresh from shared files - + ... @@ -774,8 +767,8 @@ - - + + 48 @@ -785,9 +778,6 @@ refresh from database - - - :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png @@ -814,8 +804,8 @@ - - + + 100 @@ -830,19 +820,53 @@ - - - + + + - 100 - 0 + 48 + 16777215 + + refresh from database + + + + + + + :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png + + + + + true - File ts + count + + + + + + + + 48 + 16777215 + + + + refresh from database + + + + + + + :/pastel/icons/pastel/16/arrow-refresh.png:/pastel/icons/pastel/16/arrow-refresh.png @@ -862,13 +886,19 @@ - - + + + + + 100 + 0 + + true - count + File ts @@ -882,7 +912,17 @@ - + + + + true + + + count + + + + @@ -908,14 +948,14 @@ - + Cache ts: - + @@ -968,17 +1008,63 @@ - - - - Checking shared servers' URLs + + + + true + + + count - - - - Checking DB URL + + + + true + + + count + + + + + + + true + + + count + + + + + + + true + + + count + + + + + + + true + + + count + + + + + + + true + + + count diff --git a/src/blackmisc/network/networkutils.cpp b/src/blackmisc/network/networkutils.cpp index d3f88c64f..055cee9cc 100644 --- a/src/blackmisc/network/networkutils.cpp +++ b/src/blackmisc/network/networkutils.cpp @@ -47,7 +47,7 @@ namespace BlackMisc { int CNetworkUtils::getTimeoutMs() { - return 2000; + return 3000; } bool CNetworkUtils::canPing(const QString &hostAddress) @@ -341,4 +341,4 @@ namespace BlackMisc return phpError.remove(regEx); } } // namespace -} // namespacee +} // namespace