From eef250e124fbfdf66043716d4a43d54c640c193e Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 17 Apr 2020 16:08:20 -0700 Subject: [PATCH] UI fixes, allow spaces in user group names. --- meshuser.js | 4 ++-- views/default.handlebars | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/meshuser.js b/meshuser.js index 6b9b1627..643df880 100644 --- a/meshuser.js +++ b/meshuser.js @@ -1705,7 +1705,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use else if ((parent.parent.mailserver != null) && (domain.auth != 'sspi') && (domain.auth != 'ldap') && (user.emailVerified !== true) && (user.siteadmin != 0xFFFFFFFF)) { err = 'Email verification required'; } // User must verify it's email first. // Create user group - else if ((common.validateString(command.name, 1, 64) == false) || (command.name.indexOf(' ') >= 0)) { err = 'Invalid group name'; } // User group name is between 1 and 64 characters + else if (common.validateString(command.name, 1, 64) == false) { err = 'Invalid group name'; } // User group name is between 1 and 64 characters else if ((command.desc != null) && (common.validateString(command.desc, 0, 1024) == false)) { err = 'Invalid group description'; } // User group description is between 0 and 1024 characters // If we are cloning from an existing user group, check that. @@ -1854,7 +1854,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // Get the user group var group = parent.userGroups[command.ugrpid]; if (group != null) { - if ((common.validateString(command.name, 1, 64) == true) && (command.name != group.name) && (command.name.indexOf(' ') == -1)) { change = 'User group name changed from "' + group.name + '" to "' + command.name + '"'; group.name = command.name; } + if ((common.validateString(command.name, 1, 64) == true) && (command.name != group.name)) { change = 'User group name changed from "' + group.name + '" to "' + command.name + '"'; group.name = command.name; } if ((common.validateString(command.desc, 0, 1024) == true) && (command.desc != group.desc)) { if (change != '') change += ' and description changed'; else change += 'User group "' + group.name + '" description changed'; group.desc = command.desc; } if (change != '') { db.Set(group); diff --git a/views/default.handlebars b/views/default.handlebars index 97e4e008..0d16fdee 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2289,7 +2289,7 @@ if (message.event.desc) { ugroup.desc = message.event.desc; } else { delete ugroup.desc; } if (message.event.links) { ugroup.links = message.event.links; } else { delete ugroup.links; } } - masterUpdate(8192 + 16384); + masterUpdate(4096 + 8192 + 16384); // Group update, refresh all our device groups and nodes. TODO: Optimize this to only do this when needed. meshserver.send({ action: 'meshes' }); @@ -8383,7 +8383,8 @@ } if (sortedusers[i].id.startsWith('ugrp/')) { icon = 4; } var username = EscapeHtml(decodeURIComponent(sortedusers[i].name)); - if (users != null) { username = '' + username + ''; } + if ((usergroups != null) && sortedusers[i].id.startsWith('ugrp/')) { username = '' + username + ''; } + if ((users != null) && sortedusers[i].id.startsWith('user/')) { username = '' + username + ''; } x += '
 ' + username + '
' + trash + '
' + rights + '
'; ++count; } @@ -10211,9 +10212,7 @@ Q('p4name').focus(); } - function showCreateUserGroupDialogValidate() { - QE('idx_dlgOkButton', (Q('p4name').value.length > 0) && (Q('p4name').value.indexOf(' ') == -1)); - } + function showCreateUserGroupDialogValidate() { QE('idx_dlgOkButton', Q('p4name').value.length > 0); } function showCreateUserGroupDialogEx(b, mode) { var x = { action: 'createusergroup', name: Q('p4name').value, desc: Q('p4desc').value }; @@ -10394,8 +10393,7 @@ } function p51editgroupValidate(e) { - QE('idx_dlgOkButton', (Q('dp51name').value.length > 0) && (Q('dp51name').value.indexOf(' ') == -1)); - if (e && e.key == 'Enter') { Q('dp51desc').focus(); } + QE('idx_dlgOkButton', Q('dp51name').value.length > 0); if (e && e.key == 'Enter') { Q('dp51desc').focus(); } } function p51showDeleteUserGroupDialog() {