mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:28:03 +02:00
fixes for admin interface with multiple nodes of same type
This commit is contained in:
parent
d3ac055add
commit
9339538a74
2 changed files with 26 additions and 14 deletions
|
@ -4,14 +4,14 @@ $(document).ready(function(){
|
||||||
$.getJSON("nodes.json", function(json){
|
$.getJSON("nodes.json", function(json){
|
||||||
nodesTableBody = "";
|
nodesTableBody = "";
|
||||||
|
|
||||||
$.each(json.nodes, function (type, data) {
|
$.each(json.nodes, function (uuid, data) {
|
||||||
nodesTableBody += "<tr>";
|
nodesTableBody += "<tr>";
|
||||||
nodesTableBody += "<td>" + type + "</td>";
|
nodesTableBody += "<td>" + data.type + "</td>";
|
||||||
nodesTableBody += "<td>" + data.UUID + "</td>";
|
nodesTableBody += "<td>" + uuid + "</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=" + data.UUID + "></span></td>";
|
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + uuid + "></span></td>";
|
||||||
nodesTableBody += "</tr>";
|
nodesTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@ $(document).ready(function(){
|
||||||
$.getJSON("assignments.json", function(json){
|
$.getJSON("assignments.json", function(json){
|
||||||
queuedTableBody = "";
|
queuedTableBody = "";
|
||||||
|
|
||||||
$.each(json.queued, function (type, data) {
|
$.each(json.queued, function (uuid, data) {
|
||||||
queuedTableBody += "<tr>";
|
queuedTableBody += "<tr>";
|
||||||
queuedTableBody += "<td>" + type + "</td>";
|
queuedTableBody += "<td>" + uuid + "</td>";
|
||||||
queuedTableBody += "<td>" + data.UUID + "</td>";
|
queuedTableBody += "<td>" + data.type + "</td>";
|
||||||
queuedTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
queuedTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
||||||
queuedTableBody += "</tr>";
|
queuedTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,8 +45,9 @@ QJsonObject jsonForSocket(sockaddr* socket) {
|
||||||
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";
|
||||||
|
const char JSON_KEY_POOL[] = "pool";
|
||||||
|
|
||||||
void addNodeToJsonObject(Node* node, QJsonObject& jsonObject) {
|
QJsonObject jsonObjectForNode(Node* node) {
|
||||||
QJsonObject nodeJson;
|
QJsonObject nodeJson;
|
||||||
|
|
||||||
// re-format the type name so it matches the target name
|
// re-format the type name so it matches the target name
|
||||||
|
@ -60,11 +61,13 @@ void addNodeToJsonObject(Node* node, QJsonObject& jsonObject) {
|
||||||
// add the node socket information
|
// add the node socket information
|
||||||
nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket());
|
nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket());
|
||||||
nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket());
|
nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket());
|
||||||
|
|
||||||
// add the node using the UUID as the key
|
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
|
||||||
jsonObject[uuidString] = nodeJson;
|
|
||||||
|
|
||||||
|
// if the node has pool information, add it
|
||||||
|
if (node->getLinkedData() && ((Assignment*) node->getLinkedData())->hasPool()) {
|
||||||
|
nodeJson[JSON_KEY_POOL] = QString(((Assignment*) node->getLinkedData())->getPool());
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodeJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
|
@ -92,7 +95,9 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
addNodeToJsonObject(&(*node), assignedNodesJSON);
|
// add the node using the UUID as the key
|
||||||
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
|
assignedNodesJSON[uuidString] = jsonObjectForNode(&(*node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +114,11 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces((*assignment)->getUUID());
|
QString uuidString = uuidStringWithoutCurlyBraces((*assignment)->getUUID());
|
||||||
queuedAssignmentJSON[JSON_KEY_TYPE] = QString((*assignment)->getTypeName());
|
queuedAssignmentJSON[JSON_KEY_TYPE] = QString((*assignment)->getTypeName());
|
||||||
|
|
||||||
|
// if the assignment has a pool, add it
|
||||||
|
if ((*assignment)->hasPool()) {
|
||||||
|
queuedAssignmentJSON[JSON_KEY_POOL] = QString((*assignment)->getPool());
|
||||||
|
}
|
||||||
|
|
||||||
// add this queued assignment to the JSON
|
// add this queued assignment to the JSON
|
||||||
queuedAssignmentsJSON[uuidString] = queuedAssignmentJSON;
|
queuedAssignmentsJSON[uuidString] = queuedAssignmentJSON;
|
||||||
|
|
||||||
|
@ -136,7 +146,9 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
addNodeToJsonObject(&(*node), nodesJSON);
|
// add the node using the UUID as the key
|
||||||
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
|
nodesJSON[uuidString] = jsonObjectForNode(&(*node));
|
||||||
}
|
}
|
||||||
|
|
||||||
rootJSON["nodes"] = nodesJSON;
|
rootJSON["nodes"] = nodesJSON;
|
||||||
|
|
Loading…
Reference in a new issue