diff --git a/build b/build index 615be70..8bfa2f5 100644 --- a/build +++ b/build @@ -1 +1 @@ -85 \ No newline at end of file +86 \ No newline at end of file diff --git a/src/RESTObjects/RESTAPI_ProvObjects.cpp b/src/RESTObjects/RESTAPI_ProvObjects.cpp index b271df2..b513302 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.cpp +++ b/src/RESTObjects/RESTAPI_ProvObjects.cpp @@ -864,6 +864,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_to_json(Obj,"errors",errors); RESTAPI_utils::field_to_json(Obj,"warnings",warnings); RESTAPI_utils::field_to_json(Obj,"timeStamp",timeStamp); + RESTAPI_utils::field_to_json(Obj,"details",details); } bool WebSocketNotificationContent::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -874,6 +875,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_from_json(Obj,"errors",errors); RESTAPI_utils::field_from_json(Obj,"warnings",warnings); RESTAPI_utils::field_from_json(Obj,"timeStamp",timeStamp); + RESTAPI_utils::field_from_json(Obj,"details",details); return true; } catch(...) { diff --git a/src/RESTObjects/RESTAPI_ProvObjects.h b/src/RESTObjects/RESTAPI_ProvObjects.h index 234d691..8e75500 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.h +++ b/src/RESTObjects/RESTAPI_ProvObjects.h @@ -500,7 +500,8 @@ namespace OpenWifi::ProvObjects { struct WebSocketNotificationContent { std::string title, - type; + type, + details; std::vector success, errors, warnings; diff --git a/src/Tasks/VenueConfigUpdater.h b/src/Tasks/VenueConfigUpdater.h index 591db54..c94fba8 100644 --- a/src/Tasks/VenueConfigUpdater.h +++ b/src/Tasks/VenueConfigUpdater.h @@ -59,6 +59,9 @@ namespace OpenWifi { if(When_ && When_>OpenWifi::Now()) Poco::Thread::trySleep( (long) (When_ - OpenWifi::Now()) * 1000 ); + ProvObjects::WebSocketNotification N; + N.content.type = "configuration_update"; + Logger().information(fmt::format("Job {} Starting.", JobId_)); ProvObjects::Venue Venue; @@ -66,8 +69,8 @@ namespace OpenWifi { if(StorageService()->VenueDB().GetRecord("id",VenueUUID_,Venue)) { for(const Types::UUID_t &uuid:Venue.devices) { ProvObjects::InventoryTag Device; - if(StorageService()->InventoryDB().GetRecord("id",uuid,Device)) { + N.content.title = "Venue Configuration Updater: " + Venue.info.name; Logger().debug(fmt::format("{}: Computing configuration.",Device.serialNumber)); auto DeviceConfig = std::make_shared(Device.serialNumber, Device.deviceType, Logger(), false); auto Configuration = Poco::makeShared(); @@ -85,34 +88,29 @@ namespace OpenWifi { Results.errorCode = 0; Logger().information(fmt::format("Device {} updated.", Device.serialNumber)); Updated++; + N.content.success.push_back(Device.serialNumber); } else { Logger().information(fmt::format("Device {} was not updated.", Device.serialNumber)); Results.errorCode = 1; Failed++; + N.content.warnings.push_back(Device.serialNumber); } } else { Logger().debug(fmt::format("{}: Configuration is bad.",Device.serialNumber)); Results.errorCode = 1; + N.content.errors.push_back(Device.serialNumber); BadConfigs++; } } } + N.content.details = fmt::format("Job {} Completed: {} updated, {} failed to update{} , {} bad configurations. ", + JobId_, Updated ,Failed, BadConfigs); } else { - Logger().warning(fmt::format("Venue {} no longer exists.",VenueUUID_)); + N.content.details = fmt::format("Venue {} no longer exists.",VenueUUID_); + Logger().warning(N.content.details); } - ProvObjects::WebSocketNotification N; - - N.content.title = "Bulk Configuration Updater"; - N.content.type = "configuration_update"; - N.content.success.push_back(fmt::format("Successfully updated {} devices.",Updated)); - if(Failed>0) - N.content.warnings.push_back(fmt::format("Could not update {} devices.",Failed)); - if(BadConfigs>0) - N.content.errors.push_back(fmt::format("Bad configuration for {} devices.",BadConfigs)); - auto Sent = WebSocketClientServer()->SendUserNotification(UI_.email,N); - Logger().information(fmt::format("Job {} Completed: {} updated, {} failed to update{} , {} bad configurations. Notification was send={}", JobId_, Updated ,Failed, BadConfigs, Sent)); delete this;