diff --git a/domain-server/resources/web/stats/js/stats.js b/domain-server/resources/web/stats/js/stats.js index e82668ea9e..bebd16b883 100644 --- a/domain-server/resources/web/stats/js/stats.js +++ b/domain-server/resources/web/stats/js/stats.js @@ -13,7 +13,13 @@ $(document).ready(function(){ var statsTableBody = ""; $.getJSON("/nodes/" + uuid + ".json", function(json){ - $.each(json, function (key, value) { + + // update the table header with the right node type + $('#stats-lead h3').html(json.node_type + " stats (" + uuid +); + + delete json.node_type; + + $.each(json, function(key, value) { statsTableBody += ""; statsTableBody += "" + key + ""; statsTableBody += "" + value + ""; @@ -21,7 +27,7 @@ $(document).ready(function(){ }); $('#stats-table tbody').html(statsTableBody); - }); + }); } // do the first GET on page load diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 0a8b70a673..913ca44e12 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -737,8 +737,13 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url SharedNodePointer matchingNode = NodeList::getInstance()->nodeWithUUID(matchingUUID); if (matchingNode) { // create a QJsonDocument with the stats QJsonObject - QJsonDocument statsDocument(reinterpret_cast(matchingNode->getLinkedData()) - ->getStatsJSONObject()); + QJsonObject statsObject = + reinterpret_cast(matchingNode->getLinkedData())->getStatsJSONObject(); + + // add the node type to the JSON data for output purposes + statsObject["node_type"] = NodeType::getNodeTypeName(matchingNode->getType()).toLower().replace(' ', '-'); + + QJsonDocument statsDocument(statsObject); // send the response connection->respond(HTTPConnection::StatusCode200, statsDocument.toJson(), qPrintable(JSON_MIME_TYPE));