Started work on user groups UI.

Ylian Saint-Hilaire committed Dec 27, 2019 at 22:41 UTC 5bdb4cc8b0515b6abd5d280840655e2912d74573
5 files changed +95 -23
MeshCentralServer.njsproj
+1 -1
@@ -180,7 +180,6 @@
180 <Content Include="public\clickonce\minirouter\MeshMiniRouter.application" />
181 <Content Include="public\clickonce\minirouter\publish.htm" />
182 <Content Include="public\commander.htm" />
183 - <Content Include="public\compress.bat" />
183 <Content Include="public\compress.wcc" />
184 <Content Include="public\favicon.ico" />
185 <Content Include="public\images-isdu\ComputerIcon.png" />
@@ -270,6 +269,7 @@
269 <Content Include="public\styles\font-awesome\scss\_variables.scss" />
270 <Content Include="public\styles\messenger.css" />
271 <Content Include="public\styles\style.css" />
272 + <Content Include="public\translate.bat" />
273 <Content Include="public\translator.htm" />
274 <Content Include="readme.md" />
275 <Content Include="sample-config.json" />
meshuser.js
+21 -8
@@ -38,14 +38,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
38 const MESHRIGHT_UNINSTALL = 32768;
39
40 // Site rights
41 - const SITERIGHT_SERVERBACKUP = 1;
42 - const SITERIGHT_MANAGEUSERS = 2;
43 - const SITERIGHT_SERVERRESTORE = 4;
44 - const SITERIGHT_FILEACCESS = 8;
45 - const SITERIGHT_SERVERUPDATE = 16;
46 - const SITERIGHT_LOCKED = 32; // 0x00000020
47 - const SITERIGHT_NONEWGROUPS = 64; // 0x00000040
48 - const SITERIGHT_NOMESHCMD = 128; // 0x00000080
41 + const SITERIGHT_SERVERBACKUP = 1; // 0x00000001
42 + const SITERIGHT_MANAGEUSERS = 2; // 0x00000002
43 + const SITERIGHT_SERVERRESTORE = 4; // 0x00000004
44 + const SITERIGHT_FILEACCESS = 8; // 0x00000008
45 + const SITERIGHT_SERVERUPDATE = 16; // 0x00000010
46 + const SITERIGHT_LOCKED = 32; // 0x00000020
47 + const SITERIGHT_NONEWGROUPS = 64; // 0x00000040
48 + const SITERIGHT_NOMESHCMD = 128; // 0x00000080
49 + const SITERIGHT_USERGROUPS = 256; // 0x00000100
50
51 var obj = {};
52 obj.user = user;
@@ -1471,6 +1472,18 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1472 }
1473 break;
1474 }
1475 + case 'createusergroup':
1476 + {
1477 + // TODO
1478 + //console.log(command);
1479 + break;
1480 + }
1481 + case 'deleteusergroup':
1482 + {
1483 + // TODO
1484 + //console.log(command);
1485 + break;
1486 + }
1487 case 'changemeshnotify':
1488 {
1489 var err = null;
public/images/group-256.png
Binary files /dev/null and b/public/images/group-256.png differ
public/styles/style.css
+1 -1
@@ -253,7 +253,7 @@ body {
253 }
254
255 /* #UserDummyMenuSpan, */
256 -#MainSubMenuSpan, #MeshSubMenuSpan, #UserSubMenuSpan, #ServerSubMenuSpan, #MainMenuSpan, #MainSubMenu, #MeshSubMenu, #UserSubMenu, #ServerSubMenu, #UserDummyMenu, #PluginSubMenu {
256 +#MainSubMenuSpan, #MeshSubMenuSpan, #UserSubMenuSpan, #UsersSubMenuSpan, #ServerSubMenuSpan, #MainMenuSpan, #MainSubMenu, #MeshSubMenu, #UserSubMenu, #ServerSubMenu, #UserDummyMenu, #PluginSubMenu {
257 width: 100%;
258 height: 24px;
259 color: white;
views/default.handlebars
+72 -13
@@ -162,6 +162,15 @@
162 </tr>
163 </table>
164 </div>
165 + <div id=UsersSubMenuSpan style="display:none">
166 + <table id=UsersSubMenu cellpadding=0 cellspacing=0 class=style1>
167 + <tr>
168 + <td tabindex=0 id=UsersGeneral class="topbar_td style3x" onclick=go(4,event) onkeypress="if (event.key == 'Enter') go(4)">Users</td>
169 + <td tabindex=0 id=UsersGroups class="topbar_td style3x" onclick=go(50,event) onkeypress="if (event.key == 'Enter') go(50)">Groups</td>
170 + <td class="topbar_td_end style3">&nbsp;</td>
171 + </tr>
172 + </table>
173 + </div>
174 <div id=ServerSubMenuSpan style="display:none">
175 <table id=ServerSubMenu cellpadding=0 cellspacing=0 class=style1>
176 <tr>
@@ -933,6 +942,23 @@
942 <h1>My Server Plugins - <span id="p43title"></span></h1>
943 <iframe id="p43iframe" frameBorder=0 style="width:100%;height:calc(100vh - 245px);max-height:calc(100vh - 245px)"></iframe>
944 </div>
945 + <div id=p50 style="display:none">
946 + <div id="p50title"><h1>My User Groups</h1></div>
947 + <table class="pTable">
948 + <tr>
949 + <td class="h1"></td>
950 + <td class="style14">
951 + <div style="float:right">
952 + </div>
953 + <div>
954 + <input id=NewUserGroupButton type=button style=margin-left:6px onclick=showCreateUserGroupDialog() value="New Group..." />
955 + </div>
956 + </td>
957 + <td class="h2"></td>
958 + </tr>
959 + </table>
960 + <div id="p50groups"></div>
961 + </div>
962 <div id=p19 style="display:none">
963 <h1>Plugins - <span id=p19deviceName></span></h1>
964 <div id="p19headers"></div>
@@ -8875,6 +8901,7 @@
8901 x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverrestore>' + "Server Restore" + '</label><br>';
8902 x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverupdate>' + "Server Updates" + '</label><br>';
8903 x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusers>' + "Manage Users" + '</label><br>';
8904 + x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusergroups>' + "Manage User Groups" + '</label><br>';
8905 x += '<hr/></div><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_lockedaccount>' + "Lock Account" + '</label><br>';
8906 x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewgroups>' + "No New Device Groups" + '</label><br>';
8907 x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nomeshcmd>' + "No Tools (MeshCmd/Router)" + '</label><br>';
@@ -8883,18 +8910,20 @@
8910 setDialogMode(2, "Server Permissions", 3, showUserAdminDialogEx, x, user);
8911 if (user.siteadmin && user.siteadmin != 0) {
8912 Q('ua_fulladmin').checked = (user.siteadmin == 0xFFFFFFFF);
8886 - Q('ua_serverbackup').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 1) != 0)); // Server Backup
8887 - Q('ua_manageusers').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 2) != 0)); // Manage Users
8888 - Q('ua_serverrestore').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 4) != 0)); // Server Restore
8889 - Q('ua_fileaccess').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 8) != 0)); // Server Files
8890 - Q('ua_serverupdate').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 16) != 0)); // Server Update
8891 - Q('ua_lockedaccount').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 32) != 0)); // Account locked
8892 - Q('ua_nonewgroups').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 64) != 0)); // No New Groups
8893 - Q('ua_nomeshcmd').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 128) != 0)); // No Tools (MeshCMD / Router)
8913 + Q('ua_serverbackup').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 1) != 0)); // Server Backup
8914 + Q('ua_manageusers').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 2) != 0)); // Manage Users
8915 + Q('ua_serverrestore').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 4) != 0)); // Server Restore
8916 + Q('ua_fileaccess').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 8) != 0)); // Server Files
8917 + Q('ua_serverupdate').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 16) != 0)); // Server Update
8918 + Q('ua_lockedaccount').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 32) != 0)); // Account locked
8919 + Q('ua_nonewgroups').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 64) != 0)); // No New Groups
8920 + Q('ua_nomeshcmd').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 128) != 0)); // No Tools (MeshCMD / Router)
8921 + Q('ua_manageusergroups').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 256) != 0)); // Manage User Groups
8922 }
8923 QE('ua_fulladmin', userinfo.siteadmin == 0xFFFFFFFF);
8924 QE('ua_serverbackup', userinfo.siteadmin == 0xFFFFFFFF);
8925 QE('ua_manageusers', userinfo.siteadmin == 0xFFFFFFFF);
8926 + QE('ua_manageusergroups', userinfo.siteadmin == 0xFFFFFFFF);
8927 QE('ua_serverrestore', userinfo.siteadmin == 0xFFFFFFFF);
8928 QE('ua_fileaccess', userinfo.siteadmin == 0xFFFFFFFF);
8929 QE('ua_fileaccessquota', userinfo.siteadmin == 0xFFFFFFFF);
@@ -8918,6 +8947,7 @@
8947 QE('ua_lockedaccount', !Q('ua_fulladmin').checked);
8948 QE('ua_nonewgroups', !Q('ua_fulladmin').checked);
8949 QE('ua_nomeshcmd', !Q('ua_fulladmin').checked);
8950 + QE('ua_manageusergroups', !Q('ua_fulladmin').checked && Q('ua_manageusers').checked);
8951 QE('ua_fileaccessquota', Q('ua_fileaccess').checked && !Q('ua_fulladmin').checked);
8952 }
8953 }
@@ -8933,6 +8963,7 @@
8963 if (Q('ua_lockedaccount').checked == true) siteadmin += 32;
8964 if (Q('ua_nonewgroups').checked == true) siteadmin += 64;
8965 if (Q('ua_nomeshcmd').checked == true) siteadmin += 128;
8966 + if (Q('ua_manageusergroups').checked == true) siteadmin += 256;
8967 }
8968 var x = { action: 'edituser', id: user._id, siteadmin: siteadmin };
8969 if (isNaN(quota) == false) { x.quota = (quota * 1024); }
@@ -8941,8 +8972,35 @@
8972
8973 function onUserSearchInputChanged() { updateUsers(); }
8974
8975 +
8976 + //
8977 + // MY USER GROUPS
8978 + //
8979 +
8980 + function updateUserGroups() {
8981 +
8982 + }
8983 +
8984 + function showCreateUserGroupDialog() {
8985 + if (xxdialogMode) return;
8986 + var x = '';
8987 + x += addHtmlValue("Name", '<input id=p4name maxlength=64 onchange=showCreateUserGroupDialogValidate() onkeyup=showCreateUserGroupDialogValidate() />');
8988 + x += addHtmlValue("Description", '<textarea id=p4desc value="" style=width:230px;height:60px;resize:none maxlength=1024 /></textarea>');
8989 + setDialogMode(2, "Create User Group", 3, showCreateUserGroupDialogEx, x);
8990 + showCreateUserGroupDialogValidate();
8991 + Q('p4name').focus();
8992 + }
8993 +
8994 + function showCreateUserGroupDialogValidate() {
8995 + QE('idx_dlgOkButton', (Q('p4name').value.length > 0) && (Q('p4name').value.indexOf(' ') == -1));
8996 + }
8997 +
8998 + function showCreateUserGroupDialogEx() {
8999 + meshserver.send({ action: 'createusergroup', name: Q('p4name').value, desc: Q('p4desc').value });
9000 + }
9001 +
9002 //
8945 - // MY USERS GENERAL
9003 + // MY USER GENERAL
9004 //
9005
9006 var currentUser = null;
@@ -9173,7 +9231,7 @@
9231 }
9232
9233 //
9176 - // MY USERS EVENTS
9234 + // MY USER EVENTS
9235 //
9236
9237 var currentUserEvents = null;
@@ -9801,7 +9859,7 @@
9859 }
9860
9861 // Edit this line when adding a new screen
9804 - for (var i = 0; i < 44; i++) { QV('p' + i, i == x); }
9862 + for (var i = 0; i < 51; i++) { QV('p' + i, i == x); }
9863 xxcurrentView = x;
9864
9865 // Remove top bar selection
@@ -9837,7 +9895,7 @@
9895 // My Events
9896 QC('MainMenuMyEvents').add(mainMenuActiveClass);
9897 QC('LeftMenuMyEvents').add(leftMenuActiveClass);
9840 - } else if (x == 4 || (x >= 30 && x < 40)) {
9898 + } else if (x == 4 || (x >= 30 && x < 40) || x == 50) {
9899 // My Users
9900 QC('MainMenuMyUsers').add(mainMenuActiveClass);
9901 QC('LeftMenuMyUsers').add(leftMenuActiveClass);
@@ -9864,7 +9922,8 @@
9922 QV('MeshSubMenuSpan', (x >= 20) && (x < 30));
9923 QV('UserSubMenuSpan', (x >= 30) && (x < 40));
9924 QV('ServerSubMenuSpan', x == 6 || x == 115 || x == 40 || x == 41 || x == 42 || x == 43);
9867 - var panels = { 10: 'MainDev', 11: 'MainDevDesktop', 12: 'MainDevTerminal', 13: 'MainDevFiles', 14: 'MainDevAmt', 15: 'MainDevConsole', 16: 'MainDevEvents', 17: 'MainDevInfo', 19: 'MainDevPlugins', 20: 'MeshGeneral', 21: 'MeshSummary', 30: 'UserGeneral', 31: 'UserEvents', 6: 'ServerGeneral', 40: 'ServerStats', 41: 'ServerTrace', 42: 'ServerPlugins', 115: 'ServerConsole' };
9925 + QV('UsersSubMenuSpan', x == 4 || x == 50);
9926 + var panels = { 4: 'UsersGeneral', 10: 'MainDev', 11: 'MainDevDesktop', 12: 'MainDevTerminal', 13: 'MainDevFiles', 14: 'MainDevAmt', 15: 'MainDevConsole', 16: 'MainDevEvents', 17: 'MainDevInfo', 19: 'MainDevPlugins', 20: 'MeshGeneral', 21: 'MeshSummary', 30: 'UserGeneral', 31: 'UserEvents', 6: 'ServerGeneral', 40: 'ServerStats', 41: 'ServerTrace', 42: 'ServerPlugins', 50: 'UsersGroups', 115: 'ServerConsole' };
9927 for (var i in panels) {
9928 QC(panels[i]).remove('style3x');
9929 QC(panels[i]).remove('style3sel');