mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:21:16 +02:00
put servers alphabetically first in node list
This commit is contained in:
parent
52bfae5b4d
commit
44860a5f5a
2 changed files with 29 additions and 7 deletions
|
@ -2,16 +2,35 @@ $(document).ready(function(){
|
||||||
// setup a function to grab the assignments
|
// setup a function to grab the assignments
|
||||||
function getNodesAndAssignments() {
|
function getNodesAndAssignments() {
|
||||||
$.getJSON("nodes.json", function(json){
|
$.getJSON("nodes.json", function(json){
|
||||||
|
|
||||||
|
json.nodes.sort(function(a, b){
|
||||||
|
if (a.type === b.type) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.type === "agent" && b.type !== "agent") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.type > b.type) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.type < b.type) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
nodesTableBody = "";
|
nodesTableBody = "";
|
||||||
|
|
||||||
$.each(json.nodes, function (uuid, data) {
|
$.each(json.nodes, function(index, data) {
|
||||||
nodesTableBody += "<tr>";
|
nodesTableBody += "<tr>";
|
||||||
nodesTableBody += "<td>" + data.type + "</td>";
|
nodesTableBody += "<td>" + data.type + "</td>";
|
||||||
nodesTableBody += "<td><a href='stats/?uuid=" + uuid + "'>" + uuid + "</a></td>";
|
nodesTableBody += "<td><a href='stats/?uuid=" + data.uuid + "'>" + data.uuid + "</a></td>";
|
||||||
nodesTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
nodesTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
||||||
nodesTableBody += "<td>" + data.public.ip + "<span class='port'>:" + data.public.port + "</span></td>";
|
nodesTableBody += "<td>" + data.public.ip + "<span class='port'>:" + data.public.port + "</span></td>";
|
||||||
nodesTableBody += "<td>" + data.local.ip + "<span class='port'>:" + data.local.port + "</span></td>";
|
nodesTableBody += "<td>" + data.local.ip + "<span class='port'>:" + data.local.port + "</span></td>";
|
||||||
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + uuid + "></span></td>";
|
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + data.uuid + "></span></td>";
|
||||||
nodesTableBody += "</tr>";
|
nodesTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -622,6 +622,7 @@ QJsonObject DomainServer::jsonForSocket(const HifiSockAddr& socket) {
|
||||||
return socketJSON;
|
return socketJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char JSON_KEY_UUID[] = "uuid";
|
||||||
const char JSON_KEY_TYPE[] = "type";
|
const char JSON_KEY_TYPE[] = "type";
|
||||||
const char JSON_KEY_PUBLIC_SOCKET[] = "public";
|
const char JSON_KEY_PUBLIC_SOCKET[] = "public";
|
||||||
const char JSON_KEY_LOCAL_SOCKET[] = "local";
|
const char JSON_KEY_LOCAL_SOCKET[] = "local";
|
||||||
|
@ -635,6 +636,9 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
|
||||||
nodeTypeName = nodeTypeName.toLower();
|
nodeTypeName = nodeTypeName.toLower();
|
||||||
nodeTypeName.replace(' ', '-');
|
nodeTypeName.replace(' ', '-');
|
||||||
|
|
||||||
|
// add the node UUID
|
||||||
|
nodeJson[JSON_KEY_UUID] = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
|
|
||||||
// add the node type
|
// add the node type
|
||||||
nodeJson[JSON_KEY_TYPE] = nodeTypeName;
|
nodeJson[JSON_KEY_TYPE] = nodeTypeName;
|
||||||
|
|
||||||
|
@ -707,18 +711,17 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
} else if (url.path() == QString("%1.json").arg(URI_NODES)) {
|
} else if (url.path() == QString("%1.json").arg(URI_NODES)) {
|
||||||
// setup the JSON
|
// setup the JSON
|
||||||
QJsonObject rootJSON;
|
QJsonObject rootJSON;
|
||||||
QJsonObject nodesJSON;
|
QJsonArray nodesJSONArray;
|
||||||
|
|
||||||
// enumerate the NodeList to find the assigned nodes
|
// enumerate the NodeList to find the assigned nodes
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||||
// add the node using the UUID as the key
|
// add the node using the UUID as the key
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
nodesJSONArray.append(jsonObjectForNode(node));
|
||||||
nodesJSON[uuidString] = jsonObjectForNode(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rootJSON["nodes"] = nodesJSON;
|
rootJSON["nodes"] = nodesJSONArray;
|
||||||
|
|
||||||
// print out the created JSON
|
// print out the created JSON
|
||||||
QJsonDocument nodesDocument(rootJSON);
|
QJsonDocument nodesDocument(rootJSON);
|
||||||
|
|
Loading…
Reference in a new issue