More work on server device paging.
This commit is contained in:
parent
15c882f24e
commit
46e7464b49
|
@ -341,6 +341,7 @@
|
|||
"loginPicture": { "type": "string", "default": null, "description": "Web site .png logo file placed in meshcentral-data that used on the login page when sitestyle is 2." },
|
||||
"rootRedirect": { "type": "string", "default": null, "description": "Redirects HTTP root requests to this URL. When in use, direct users to /login to see the normal login page." },
|
||||
"mobileSite": { "type": "boolean", "default": true, "description": "When set to false, this setting will disable the mobile site." },
|
||||
"maxDeviceView": { "type": "integer", "default": null, "description": "The maximum number of devices a user can see on the devices page at the same time. By default all devices will show, but this may need to be limited on servers with large number of devices." },
|
||||
"unknownUserRootRedirect": { "type": "string", "default": null, "description": "Redirects HTTP root requests to this URL only where user is not already logged in. When in use, direct users to /login to see the normal login page." },
|
||||
"nightMode": { "type": "integer", "default": 0, "description": "0 = User selects day/night mode, 1 = Always night mode, 2 = Always day mode" },
|
||||
"userQuota": { "type": "integer" },
|
||||
|
|
|
@ -1278,6 +1278,7 @@ function CreateMeshCentralServer(config, args) {
|
|||
if (obj.config.domains[i].limits == null) { obj.config.domains[i].limits = {}; }
|
||||
if (obj.config.domains[i].dns == null) { obj.config.domains[i].url = (i == '') ? '/' : ('/' + i + '/'); } else { obj.config.domains[i].url = '/'; }
|
||||
obj.config.domains[i].id = i;
|
||||
if ((typeof obj.config.domains[i].maxdeviceview != 'number') || (obj.config.domains[i].maxdeviceview < 1)) { delete obj.config.domains[i].maxdeviceview; }
|
||||
if (typeof obj.config.domains[i].loginkey == 'string') { obj.config.domains[i].loginkey = [obj.config.domains[i].loginkey]; }
|
||||
if ((obj.config.domains[i].loginkey != null) && (obj.common.validateAlphaNumericArray(obj.config.domains[i].loginkey, 1, 128) == false)) { console.log("ERROR: Invalid login key, must be alpha-numeric string with no spaces."); process.exit(); return; }
|
||||
if (typeof obj.config.domains[i].agentkey == 'string') { obj.config.domains[i].agentkey = [obj.config.domains[i].agentkey]; }
|
||||
|
|
25
meshuser.js
25
meshuser.js
|
@ -109,6 +109,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
obj.deviceSkip = 0; // How many devices to skip
|
||||
obj.deviceLimit = 0; // How many devices to view
|
||||
obj.visibleDevices = null; // An object of visible nodeid's if the user is in paging mode
|
||||
if (domain.maxdeviceview != null) { obj.deviceLimit = domain.maxdeviceview; obj.visibleDevices = {}; }
|
||||
|
||||
// Check if we are a cross-domain administrator
|
||||
if (parent.parent.config.settings.managecrossdomain && (parent.parent.config.settings.managecrossdomain.indexOf(user._id) >= 0)) { obj.crossDomain = true; }
|
||||
|
@ -613,6 +614,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
}
|
||||
serverinfo.preConfiguredScripts = r;
|
||||
}
|
||||
if (domain.maxdeviceview != null) { serverinfo.maxdeviceview = domain.maxdeviceview; } // Maximum number of devices a user can view at any given time
|
||||
|
||||
// Send server information
|
||||
try { ws.send(JSON.stringify({ action: 'serverinfo', serverinfo: serverinfo })); } catch (ex) { }
|
||||
|
@ -675,6 +677,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
switch (command.action) {
|
||||
case 'nodes':
|
||||
{
|
||||
// If in paging mode, look to set the skip and limit values
|
||||
if (obj.visibleDevices != null) {
|
||||
if ((typeof command.skip == 'number') && (command.skip >= 0)) { obj.deviceSkip = command.skip; }
|
||||
if ((typeof command.limit == 'number') && (command.limit > 0)) { obj.deviceLimit = command.limit; }
|
||||
if ((domain.maxdeviceview != null) && (obj.deviceLimit > domain.maxdeviceview)) { obj.deviceLimit = domain.maxdeviceview; }
|
||||
}
|
||||
|
||||
var links = [], extraids = null, err = null;
|
||||
|
||||
// Resolve the device group name if needed
|
||||
|
@ -721,7 +730,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
if (docs == null) { docs = []; }
|
||||
parent.common.unEscapeAllLinksFieldName(docs);
|
||||
|
||||
var r = {};
|
||||
var r = {}, nodeCount = docs.length;
|
||||
if (obj.visibleDevices != null) { obj.visibleDevices = {}; }
|
||||
for (i in docs) {
|
||||
// Check device links, if a link points to an unknown user, remove it.
|
||||
|
@ -805,9 +814,19 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
// If in paging mode, report back the skip and limit values
|
||||
response.skip = obj.deviceSkip;
|
||||
response.limit = obj.deviceLimit;
|
||||
// TODO: Add total device count
|
||||
|
||||
// Add total device count
|
||||
if (nodeCount < response.limit) {
|
||||
response.totalcount = obj.deviceSkip + nodeCount;
|
||||
try { ws.send(JSON.stringify(response)); } catch (ex) { }
|
||||
} else {
|
||||
// TODO
|
||||
//console.log('response.totalcount', '???');
|
||||
try { ws.send(JSON.stringify(response)); } catch (ex) { }
|
||||
}
|
||||
} else {
|
||||
try { ws.send(JSON.stringify(response)); } catch (ex) { }
|
||||
}
|
||||
try { ws.send(JSON.stringify(response)); } catch (ex) { }
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@
|
|||
"_loginPicture": "title-sample.png",
|
||||
"_rootRedirect": "https://www.youtube.com/watch?v=Gs069dndIYk",
|
||||
"_mobileSite": false,
|
||||
"_maxDeviceView": 1000,
|
||||
"_unknownUserRootRedirect": "https://www.youtube.com/watch?v=2Q_ZzBGPdqE",
|
||||
"_nightMode": 1,
|
||||
"_userQuota": 1048576,
|
||||
|
|
Loading…
Reference in New Issue