mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
pretty up the stats table
This commit is contained in:
parent
ba338cb7bc
commit
364df16a9f
2 changed files with 15 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue