From 25020ffd18820f9a6c3f55c0a0afd58af55dab8e Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 31 Aug 2022 17:11:15 -0700 Subject: [PATCH] First working device paging support on desktop site. --- meshuser.js | 23 ++++++++++++++-------- public/images/views.png | Bin 3082 -> 3723 bytes public/styles/style.css | 32 ++++++++++++++++++++++++++++++ views/default.handlebars | 41 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/meshuser.js b/meshuser.js index bf2945e5..a4809ac6 100644 --- a/meshuser.js +++ b/meshuser.js @@ -109,7 +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 = {}; } + if (domain.maxdeviceview != null) { obj.deviceLimit = domain.maxdeviceview; } // 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; } @@ -678,10 +678,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use case 'nodes': { // If in paging mode, look to set the skip and limit values - if (obj.visibleDevices != null) { + if (domain.maxdeviceview != 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; } + if (obj.deviceLimit > domain.maxdeviceview) { obj.deviceLimit = domain.maxdeviceview; } } var links = [], extraids = null, err = null; @@ -731,13 +731,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use parent.common.unEscapeAllLinksFieldName(docs); var r = {}, nodeCount = docs.length; - if (obj.visibleDevices != null) { obj.visibleDevices = {}; } + if (domain.maxdeviceview != null) { obj.visibleDevices = {}; } for (i in docs) { // Check device links, if a link points to an unknown user, remove it. parent.cleanDevice(docs[i]); // TODO: This will make the total device count incorrect and will affect device paging. // If we are paging, add the device to the page here - if (obj.visibleDevices != null) { obj.visibleDevices[docs[i]._id] = 1; } + if (domain.maxdeviceview != null) { obj.visibleDevices[docs[i]._id] = 1; } // Remove any connectivity and power state information, that should not be in the database anyway. // TODO: Find why these are sometimes saved in the db. @@ -810,28 +810,35 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use r[meshid].push(docs[i]); } const response = { action: 'nodes', responseid: command.responseid, nodes: r, tag: command.tag }; - if (obj.visibleDevices != null) { + if (domain.maxdeviceview != null) { // If in paging mode, report back the skip and limit values response.skip = obj.deviceSkip; response.limit = obj.deviceLimit; // Add total device count + // Only set response.totalcount if we need to be in paging mode if (nodeCount < response.limit) { - response.totalcount = obj.deviceSkip + nodeCount; + if (obj.deviceSkip > 0) { response.totalcount = obj.deviceSkip + nodeCount; } else { obj.visibleDevices = null; } try { ws.send(JSON.stringify(response)); } catch (ex) { } } else { // Ask the database for the total device count if (db.CountAllTypeNoTypeFieldMeshFiltered) { db.CountAllTypeNoTypeFieldMeshFiltered(links, extraids, domain.id, 'node', command.id, function (err, count) { - if ((err == null) && (typeof response.totalcount == 'number')) { response.totalcount = count; } + if ((err != null) || (typeof count != 'number') || ((obj.deviceSkip == 0) && (count < obj.deviceLimit))) { + obj.visibleDevices = null; + } else { + response.totalcount = count; + } try { ws.send(JSON.stringify(response)); } catch (ex) { } }); } else { // The database does not support device counting + obj.visibleDevices = null; // We are not in paging mode try { ws.send(JSON.stringify(response)); } catch (ex) { } } } } else { + obj.visibleDevices = null; // We are not in paging mode try { ws.send(JSON.stringify(response)); } catch (ex) { } } }); diff --git a/public/images/views.png b/public/images/views.png index 5d40d8a6abaed368593c27d0cbd72123e9c157e2..3b9f6c147715ecf3d56716f68535a58b08510b56 100644 GIT binary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aaI(J$M-Y{=5Nc^K|MdI&NiG_J=wuRDW6{{;RKF z;HsIfSJZIl%n>4OR&hR!VW+u1`MA=t1@{*e2e&>^hxq2t92u>W#cT(sS+=4a2U?=cfG;fvX+efBmCv-R9vem#Y3ur4jW zwV#G&W)k!;!L3UZv%Pg$an#iFR?NE2YWN2E5w$I}rV$}Y)$^rnuo`^nErCWk? z&d*C6HIoZjL6k`4P8_0{zIA#%`tiv$9nqTLe>?&K=dHchom24!QHU0AOMxq*m?3|e z?Y5<33TyQ*v$GMBWV-Ontm@kRqn{0Hv=UAv;^W1C;)xQea$Gz()`-4{re!;hp1$KM zgCpd#wGBpt_mIZ@r60~2DPI~qz$tXl2k7!{`s7yE%yGr#Siody^vZ! ze^L#wAK4$82*9aGtnEC&gJB7ueGvY+G$Gg6bKX9A`37$fv76}QG@$p90A3gs5J_GP zY~Tpd`!Kad8W`{@A`%aO`di&7#zHw5R#+rr`qy{1Pl$;Iz%>|4#uEQaSBOa8i(E+2 zI7bwTbO;G?HLx^cS8`Y{Wn=q$$W&gWEFi20p_fJfoBtfCW)1&2kESwDxDPz3hyVZp07*qoM6N<$f@}ZY+5i9m diff --git a/public/styles/style.css b/public/styles/style.css index 712e3f90..449ae915 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -2943,6 +2943,38 @@ a { width: 28px; } +.viewSelector8 { + margin-left: 2px; + margin-top: 2px; + background: url(../images/views.png) -420px 0px; + height: 28px; + width: 28px; +} + +.viewSelector9 { + margin-left: 2px; + margin-top: 2px; + background: url(../images/views.png) -448px 0px; + height: 28px; + width: 28px; +} + +.viewSelector10 { + margin-left: 2px; + margin-top: 2px; + background: url(../images/views.png) -476px 0px; + height: 28px; + width: 28px; +} + +.viewSelector11 { + margin-left: 2px; + margin-top: 2px; + background: url(../images/views.png) -504px 0px; + height: 28px; + width: 28px; +} + .fulldesk .viewSelector5 { background: url(../images/views.png) -252px 0px; } diff --git a/views/default.handlebars b/views/default.handlebars index 345ff633..3d1d12da 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -294,6 +294,11 @@