Improved file search.

This commit is contained in:
Ylian Saint-Hilaire 2020-11-12 22:16:10 -08:00
parent a3d712d207
commit 562000f120
7 changed files with 1277 additions and 1256 deletions

View File

@ -1721,8 +1721,28 @@ function CreateMeshCentralServer(config, args) {
obj.GetConnectivityState = function (nodeid) { return obj.connectivityByNode[nodeid]; }; obj.GetConnectivityState = function (nodeid) { return obj.connectivityByNode[nodeid]; };
// Get the routing server id for a given node and connection type, can never be self. // Get the routing server id for a given node and connection type, can never be self.
obj.GetRoutingServerIdNotSelf = function (nodeid, connectType) {
if (obj.multiServer == null) return null;
for (var serverid in obj.peerConnectivityByNode) {
if (serverid == obj.serverId) continue;
var state = obj.peerConnectivityByNode[serverid][nodeid];
if ((state != null) && ((state.connectivity & connectType) != 0)) { return { serverid: serverid, meshid: state.meshid }; }
}
return null;
};
// Get the routing server id for a given node and connection type, self first
obj.GetRoutingServerId = function (nodeid, connectType) { obj.GetRoutingServerId = function (nodeid, connectType) {
if (obj.multiServer == null) return null; if (obj.multiServer == null) return null;
// Look at our own server first
var connections = obj.peerConnectivityByNode[obj.serverId];
if (connections != null) {
var state = connections[nodeid];
if ((state != null) && ((state.connectivity & connectType) != 0)) { return { serverid: obj.serverId, meshid: state.meshid }; }
}
// Look at other servers
for (var serverid in obj.peerConnectivityByNode) { for (var serverid in obj.peerConnectivityByNode) {
if (serverid == obj.serverId) continue; if (serverid == obj.serverId) continue;
var state = obj.peerConnectivityByNode[serverid][nodeid]; var state = obj.peerConnectivityByNode[serverid][nodeid];

View File

@ -945,7 +945,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
} }
} else { } else {
// Check if a peer server is connected to this agent // Check if a peer server is connected to this agent
var routing = parent.parent.GetRoutingServerId(command.nodeid, 1); // 1 = MeshAgent routing type var routing = parent.parent.GetRoutingServerIdNotSelf(command.nodeid, 1); // 1 = MeshAgent routing type
if (routing != null) { if (routing != null) {
// Check if we have permission to send a message to that node // Check if we have permission to send a message to that node
rights = parent.GetNodeRights(user, routing.meshid, command.nodeid); rights = parent.GetNodeRights(user, routing.meshid, command.nodeid);

View File

@ -99,7 +99,7 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us
} }
} else { } else {
// Check if a peer server is connected to this agent // Check if a peer server is connected to this agent
var routing = parent.parent.GetRoutingServerId(command.nodeid, 1); // 1 = MeshAgent routing type var routing = parent.parent.GetRoutingServerIdNotSelf(command.nodeid, 1); // 1 = MeshAgent routing type
if (routing != null) { if (routing != null) {
// Check if we have permission to send a message to that node // Check if we have permission to send a message to that node
rights = parent.GetNodeRights(user, routing.meshid, command.nodeid); rights = parent.GetNodeRights(user, routing.meshid, command.nodeid);

View File

@ -146,7 +146,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
} }
} else { } else {
// Check if a peer server is connected to this agent // Check if a peer server is connected to this agent
var routing = parent.parent.GetRoutingServerId(command.nodeid, 1); // 1 = MeshAgent routing type var routing = parent.parent.GetRoutingServerIdNotSelf(command.nodeid, 1); // 1 = MeshAgent routing type
if (routing != null) { if (routing != null) {
// Check if we have permission to send a message to that node // Check if we have permission to send a message to that node
rights = parent.GetNodeRights(user, routing.meshid, command.nodeid); rights = parent.GetNodeRights(user, routing.meshid, command.nodeid);

View File

@ -237,7 +237,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
}); });
} else { } else {
// Check if a peer server is connected to this agent // Check if a peer server is connected to this agent
var routing = parent.parent.GetRoutingServerId(command.nodeid, 1); // 1 = MeshAgent routing type var routing = parent.parent.GetRoutingServerIdNotSelf(command.nodeid, 1); // 1 = MeshAgent routing type
if (routing != null) { if (routing != null) {
// Check if we have permission to send a message to that node // Check if we have permission to send a message to that node
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) { parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
@ -1112,6 +1112,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
case 'info': { case 'info': {
var info = process.memoryUsage(); var info = process.memoryUsage();
info.dbType = ['None', 'NeDB', 'MongoJS', 'MongoDB'][parent.db.databaseType]; info.dbType = ['None', 'NeDB', 'MongoJS', 'MongoDB'][parent.db.databaseType];
try { if (parent.parent.multiServer != null) { info.serverId = parent.parent.multiServer.serverid; } } catch (ex) { }
if (parent.db.databaseType == 3) { info.dbChangeStream = parent.db.changeStream; } if (parent.db.databaseType == 3) { info.dbChangeStream = parent.db.changeStream; }
if (parent.parent.pluginHandler != null) { info.plugins = []; for (var i in parent.parent.pluginHandler.plugins) { info.plugins.push(i); } } if (parent.parent.pluginHandler != null) { info.plugins = []; for (var i in parent.parent.pluginHandler.plugins) { info.plugins.push(i); } }
try { info.nodeVersion = process.version; } catch (ex) { } try { info.nodeVersion = process.version; } catch (ex) { }

File diff suppressed because it is too large Load Diff

View File

@ -8158,25 +8158,21 @@
function p13findfile() { function p13findfile() {
if (xxdialogMode) return; if (xxdialogMode) return;
var x = addHtmlValue("Filter", '<input id=d2findFilter style="width:230px" onkeyup=p13findfileValidate() placeholder="*.txt"></input>'); var x = addHtmlValue("Filter", '<input id=d2findFilter style="width:230px" onkeyup=p13findfileValidate() onkeydown=p13findfileDown(event) placeholder="*.txt"></input>');
x += '<div id=d2findResults style="width:100%;height:184px;background-color:white;border:1px solid black;padding:3px;overflow:scroll;margin-top:8px"></div>'; x += '<div id=d2findResults style="width:100%;height:184px;background-color:white;border:1px solid black;padding:3px;overflow:scroll;margin-top:8px"></div>';
x += '<div style=margin-top:8px><input id=filefind_dlgCancelButton type=button value=' + "Cancel" + ' style=float:right;width:80px;margin-left:5px onclick=p13findfileCancel()>'; x += '<div style=margin-top:8px><input id=filefind_dlgCancelButton type=button value=' + "Close" + ' style=float:right;width:80px;margin-left:5px onclick=p13findfileCancel()>';
x += '<input id=filefind_dlgOkButton type=submit value=' + "OK" + ' style=float:right;width:80px onclick=p13findfileEx()><br /><br /></div>'; x += '<input id=filefind_dlgOkButton type=submit value=' + "Search" + ' style=float:right;width:80px onclick=p13findfileEx()><br /><br /></div>';
setDialogMode(2, "File Files", 0, null, x); setDialogMode(2, "Find Files", 0, null, x);
Q('d2findResults').focus();
p13findfileValidate(); p13findfileValidate();
Q('d2findFilter').focus();
} }
function p13findfileValidate() { function p13findfileDown(e) { if (e.code == "Enter") { p13findfileEx(); } }
QE('filefind_dlgOkButton', Q('d2findFilter').value.length > 0); function p13findfileValidate() { QE('filefind_dlgOkButton', Q('d2findFilter').value.length > 0); }
} function p13findfileCancel() { if (xxdialogTag != null) { files.sendText({ action: 'cancelfindfile', reqid: xxdialogTag }); } dialogclose(0) }
function p13findfileCancel() {
if (xxdialogTag != null) { files.sendText({ action: 'cancelfindfile', reqid: xxdialogTag }); }
dialogclose(0)
}
function p13findfileEx(b, t) { function p13findfileEx(b, t) {
if (Q('d2findFilter').value.length == 0) return;
var winagent = ((currentNode.agent.id > 0) && (currentNode.agent.id < 5)); var winagent = ((currentNode.agent.id > 0) && (currentNode.agent.id < 5));
var slash = winagent ? '\\' : '/'; var slash = winagent ? '\\' : '/';
var path = p13filetreelocation.join(slash) + slash; var path = p13filetreelocation.join(slash) + slash;