mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Merge pull request #2571 from birarda/ds-web
put servers alphabetically first in node list
This commit is contained in:
commit
247d8bc540
5 changed files with 51 additions and 11 deletions
|
@ -12,6 +12,7 @@
|
||||||
<th>Pool</th>
|
<th>Pool</th>
|
||||||
<th>Public</th>
|
<th>Public</th>
|
||||||
<th>Local</th>
|
<th>Local</th>
|
||||||
|
<th>Uptime (s)</th>
|
||||||
<th>Kill?</th>
|
<th>Kill?</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
@ -2,16 +2,47 @@ $(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) {
|
||||||
|
if (a.wake_timestamp < b.wake_timestamp) {
|
||||||
|
return 1;
|
||||||
|
} else if (a.wake_timestamp > b.wake_timestamp) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.type === "agent" && b.type !== "agent") {
|
||||||
|
return 1;
|
||||||
|
} else if (b.type === "agent" && a.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>";
|
|
||||||
|
var uptimeSeconds = (Date.now() - data.wake_timestamp) / 1000;
|
||||||
|
nodesTableBody += "<td>" + uptimeSeconds.toLocaleString() + "</td>";
|
||||||
|
|
||||||
|
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + data.uuid + "></span></td>";
|
||||||
nodesTableBody += "</tr>";
|
nodesTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -622,10 +622,12 @@ 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";
|
||||||
const char JSON_KEY_POOL[] = "pool";
|
const char JSON_KEY_POOL[] = "pool";
|
||||||
|
const char JSON_KEY_WAKE_TIMESTAMP[] = "wake_timestamp";
|
||||||
|
|
||||||
QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
|
QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
|
||||||
QJsonObject nodeJson;
|
QJsonObject nodeJson;
|
||||||
|
@ -635,6 +637,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;
|
||||||
|
|
||||||
|
@ -642,6 +647,9 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
|
||||||
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 uptime in our list
|
||||||
|
nodeJson[JSON_KEY_WAKE_TIMESTAMP] = QString::number(node->getWakeTimestamp());
|
||||||
|
|
||||||
// if the node has pool information, add it
|
// if the node has pool information, add it
|
||||||
SharedAssignmentPointer matchingAssignment = _staticAssignmentHash.value(node->getUUID());
|
SharedAssignmentPointer matchingAssignment = _staticAssignmentHash.value(node->getUUID());
|
||||||
if (matchingAssignment) {
|
if (matchingAssignment) {
|
||||||
|
@ -707,18 +715,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);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
#include <QtCore/QDataStream>
|
#include <QtCore/QDataStream>
|
||||||
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
const QString UNKNOWN_NodeType_t_NAME = "Unknown";
|
const QString UNKNOWN_NodeType_t_NAME = "Unknown";
|
||||||
|
@ -47,7 +48,7 @@ const QString& NodeType::getNodeTypeName(NodeType_t nodeType) {
|
||||||
Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) :
|
Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) :
|
||||||
_type(type),
|
_type(type),
|
||||||
_uuid(uuid),
|
_uuid(uuid),
|
||||||
_wakeMicrostamp(usecTimestampNow()),
|
_wakeTimestamp(QDateTime::currentMSecsSinceEpoch()),
|
||||||
_lastHeardMicrostamp(usecTimestampNow()),
|
_lastHeardMicrostamp(usecTimestampNow()),
|
||||||
_publicSocket(publicSocket),
|
_publicSocket(publicSocket),
|
||||||
_localSocket(localSocket),
|
_localSocket(localSocket),
|
||||||
|
|
|
@ -60,8 +60,8 @@ public:
|
||||||
const QUuid& getUUID() const { return _uuid; }
|
const QUuid& getUUID() const { return _uuid; }
|
||||||
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
||||||
|
|
||||||
quint64 getWakeMicrostamp() const { return _wakeMicrostamp; }
|
quint64 getWakeTimestamp() const { return _wakeTimestamp; }
|
||||||
void setWakeMicrostamp(quint64 wakeMicrostamp) { _wakeMicrostamp = wakeMicrostamp; }
|
void setWakeTimestamp(quint64 wakeTimestamp) { _wakeTimestamp = wakeTimestamp; }
|
||||||
|
|
||||||
quint64 getLastHeardMicrostamp() const { return _lastHeardMicrostamp; }
|
quint64 getLastHeardMicrostamp() const { return _lastHeardMicrostamp; }
|
||||||
void setLastHeardMicrostamp(quint64 lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; }
|
void setLastHeardMicrostamp(quint64 lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; }
|
||||||
|
@ -109,7 +109,7 @@ private:
|
||||||
|
|
||||||
NodeType_t _type;
|
NodeType_t _type;
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
quint64 _wakeMicrostamp;
|
quint64 _wakeTimestamp;
|
||||||
quint64 _lastHeardMicrostamp;
|
quint64 _lastHeardMicrostamp;
|
||||||
HifiSockAddr _publicSocket;
|
HifiSockAddr _publicSocket;
|
||||||
HifiSockAddr _localSocket;
|
HifiSockAddr _localSocket;
|
||||||
|
|
Loading…
Reference in a new issue