Added device group name to search results as config option (#5544)

jrf280 committed Nov 13, 2023 at 00:18 UTC bc0550a791b73ff3f0df488c0bc995f218333ee9
5 files changed +47 -12
docs/docs/meshcentral/config.md
+5
@@ -1204,6 +1204,11 @@ See description for information about each item.
1204 "default": false,
1205 "description": "When set to true, the devices search box will match on both the server name and client name of a device."
1206 },
1207 + "deviceSearchBarGroupName": {
1208 + "type": "boolean",
1209 + "default": false,
1210 + "description": "When set to true, the devices search box will match on group name too."
1211 + },
1212 "agentSelfGuestSharing": {
1213 "type": [
1214 "boolean",
meshcentral-config-schema.json
+5
@@ -1197,6 +1197,11 @@
1197 "default": false,
1198 "description": "When set to true, the devices search box will match on both the server name and client name of a device."
1199 },
1200 + "deviceSearchBarGroupName": {
1201 + "type": "boolean",
1202 + "default": false,
1203 + "description": "When set to true, the devices search box will match on group name too."
1204 + },
1205 "agentSelfGuestSharing": {
1206 "type": [
1207 "boolean",
views/default-mobile.handlebars
+17 -5
@@ -2904,12 +2904,24 @@
2904 var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs); // In some cases (like +), this can throw an exception.
2905 for (var d in nodes) {
2906 if (features2 & 0x00008000) {
2907 - nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || ((nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()));
2907 + if(features2 & 0x10000000){
2908 + nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || (rx.test(meshes[nodes[d].meshid].name.toLowerCase())) || ((nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()));
2909 + }else {
2910 + nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || ((nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()));
2911 + }
2912 } else {
2909 - if (showRealNames) {
2910 - nodes[d].v = (nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase());
2911 - } else {
2912 - nodes[d].v = rx.test(nodes[d].name.toLowerCase());
2913 + if(features2 & 0x10000000){
2914 + if (showRealNames) {
2915 + nodes[d].v = (nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()) || (rx.test(meshes[nodes[d].meshid].name.toLowerCase()));
2916 + } else {
2917 + nodes[d].v = rx.test(nodes[d].name.toLowerCase()) || (rx.test(meshes[nodes[d].meshid].name.toLowerCase()));
2918 + }
2919 + }else{
2920 + if (showRealNames) {
2921 + nodes[d].v = (nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase());
2922 + } else {
2923 + nodes[d].v = rx.test(nodes[d].name.toLowerCase());
2924 + }
2925 }
2926 }
2927 }
views/default.handlebars
+19 -7
@@ -6157,15 +6157,27 @@
6157 // Device name search
6158 try {
6159 var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs); // In some cases (like +), this can throw an exception.
6160 - for (var d in nodes) {
6160 + for (var d in nodes) {
6161 if (features2 & 0x00008000) { // Both server and client names must match
6162 - if (rx.test(nodes[d].name.toLowerCase()) || ((nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()))) { r.push(d); }
6163 - } else {
6164 - if (showRealNames) {
6165 - if (nodes[d].rnamel != null && rx.test(nodes[d].rnamel.toLowerCase())) { r.push(d); }
6166 - } else {
6167 - if (rx.test(nodes[d].name.toLowerCase())) { r.push(d); }
6162 + if(features2 & 0x10000000){
6163 + if (rx.test(nodes[d].name.toLowerCase()) || rx.test(meshes[nodes[d].meshid].name.toLowerCase()) || ((nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()))) { r.push(d); }
6164 + }else {
6165 + if (rx.test(nodes[d].name.toLowerCase()) || ((nodes[d].rnamel != null) && rx.test(nodes[d].rnamel.toLowerCase()))) { r.push(d); }
6166 }
6167 + } else {
6168 + if(features2 & 0x10000000){
6169 + if (showRealNames) {
6170 + if (nodes[d].rnamel != null && rx.test(nodes[d].rnamel.toLowerCase()) || rx.test(meshes[nodes[d].meshid].name.toLowerCase()) ) { r.push(d); }
6171 + } else {
6172 + if (rx.test(nodes[d].name.toLowerCase()) || rx.test(meshes[nodes[d].meshid].name.toLowerCase()) ) { r.push(d); }
6173 + }
6174 + }else {
6175 + if (showRealNames) {
6176 + if (nodes[d].rnamel != null && rx.test(nodes[d].rnamel.toLowerCase())) { r.push(d); }
6177 + } else {
6178 + if (rx.test(nodes[d].name.toLowerCase())) { r.push(d); }
6179 + }
6180 + }
6181 }
6182 }
6183 } catch (ex) { for (var d in nodes) { r.push(d); } }
webserver.js
+1
@@ -3226,6 +3226,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
3226 if ((parent.msgserver != null) && (parent.msgserver.providers != 0)) { features2 += 0x02000000; } // User messaging server is enabled
3227 if ((parent.msgserver != null) && (parent.msgserver.providers != 0) && ((typeof domain.passwordrequirements != 'object') || (domain.passwordrequirements.msg2factor != false))) { features2 += 0x04000000; } // User messaging 2FA is allowed
3228 if (domain.scrolltotop == true) { features2 += 0x08000000; } // Show the "Scroll to top" button
3229 + if (domain.devicesearchbargroupname === true) { features2 += 0x10000000; } // Search bar will find by group name too
3230 return { features: features, features2: features2 };
3231 }
3232