pretty up the stats table

This commit is contained in:
Stephen Birarda 2014-03-24 16:34:00 -07:00
parent ba338cb7bc
commit 364df16a9f
2 changed files with 15 additions and 4 deletions

View file

@ -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 += "<tr>";
statsTableBody += "<td>" + key + "</td>";
statsTableBody += "<td>" + value + "</td>";
@ -21,7 +27,7 @@ $(document).ready(function(){
});
$('#stats-table tbody').html(statsTableBody);
});
});
}
// do the first GET on page load

View file

@ -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<DomainServerNodeData*>(matchingNode->getLinkedData())
->getStatsJSONObject());
QJsonObject statsObject =
reinterpret_cast<DomainServerNodeData*>(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));