Skip to content

Commit

Permalink
Zone object DClass names
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmit799 committed Apr 5, 2024
1 parent 71ae86b commit fae8d24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/stateserver/database_state_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,15 @@ void DatabaseStateServer::HandleWeb(ws28::Client *client,
// Build a dictionary of zone objects under this Distributed Object.
nlohmann::json zoneObjs = nlohmann::json::object();
for (const auto &zoneData : distObj->GetZoneObjects()) {
zoneObjs[std::to_string(zoneData.first)] = zoneData.second;
for (const auto &zoneDoId : zoneData.second) {
// Try to get the DClass name for the zone object.
auto clsName = _distObjs.contains(zoneDoId)
? _distObjs[zoneDoId]->GetDClass()->get_name()
: "Unknown";

zoneObjs[std::to_string(zoneData.first)].push_back(
{{"doId", zoneDoId}, {"clsName", clsName}});
}
}

WebPanel::Send(client, {
Expand Down
10 changes: 9 additions & 1 deletion src/stateserver/state_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ void StateServer::HandleWeb(ws28::Client *client, nlohmann::json &data) {
// Build a dictionary of zone objects under this Distributed Object.
nlohmann::json zoneObjs = nlohmann::json::object();
for (const auto &zoneData : distObj->GetZoneObjects()) {
zoneObjs[std::to_string(zoneData.first)] = zoneData.second;
for (const auto &zoneDoId : zoneData.second) {
// Try to get the DClass name for the zone object.
auto clsName = _distObjs.contains(zoneDoId)
? _distObjs[zoneDoId]->GetDClass()->get_name()
: "Unknown";

zoneObjs[std::to_string(zoneData.first)].push_back(
{{"doId", zoneDoId}, {"clsName", clsName}});
}
}

WebPanel::Send(client, {
Expand Down

0 comments on commit fae8d24

Please sign in to comment.