Sorted device group actions, #3500

Ylian Saint-Hilaire committed Jan 21, 2022 at 09:13 UTC b45a5bad8cfd9a200b0958cacf320140f3f25fd6
7 files changed +20 -16
agents/agents-old/MeshCmd-signed.exe
Binary files /dev/null and b/agents/agents-old/MeshCmd-signed.exe differ
agents/agents-old/MeshCmd64-signed.exe
Binary files /dev/null and b/agents/agents-old/MeshCmd64-signed.exe differ
agents/agents-old/MeshService-signed.exe
Binary files /dev/null and b/agents/agents-old/MeshService-signed.exe differ
agents/agents-old/MeshService.exe
Binary files /dev/null and b/agents/agents-old/MeshService.exe differ
agents/agents-old/MeshService64-signed.exe
Binary files /dev/null and b/agents/agents-old/MeshService64-signed.exe differ
agents/agents-old/MeshService64.exe
Binary files /dev/null and b/agents/agents-old/MeshService64.exe differ
views/default.handlebars
+20 -16
@@ -5235,35 +5235,39 @@
5235 }
5236
5237 function groupActionFunction() {
5238 - var addedOptions = '', nodeids = getCheckedDevices(), added = 0;
5238 + var addedOptions = [], nodeids = getCheckedDevices(), added = 0;
5239
5240 // Check if any of the selected devices have a MQTT connection active
5241 if (features & 0x00400000) {
5242 - for (var i in nodeids) { if ((getNodeFromId(nodeids[i]).conn & 16) != 0) { addedOptions += '<option value=103>' + "Send MQTT Message" + '</option>'; break; } }
5242 + for (var i in nodeids) { if ((getNodeFromId(nodeids[i]).conn & 16) != 0) { addedOptions.push({ v:103, name: "Send MQTT Message" });; break; } }
5243 }
5244
5245 - // Display the "Uninstall Agent" option if allowed and we selected connected devices.
5245 + // Display the options that are allowed depending on what devices are selected.
5246 + addedOptions.push({ v: 105, name: "Export device information", s:true });
5247 for (var i in nodeids) {
5248 var node = getNodeFromId(nodeids[i]), rights = GetNodeRights(node);
5248 - if ((rights & 1) && ((added & 2) == 0)) { added |= 2; addedOptions += '<option value=102>' + "Move to device group" + '</option>'; }
5249 - if (((node.conn & 1) != 0) && ((rights & 0x8000) != 0) && ((added & 1) == 0)) { added |= 1; addedOptions += '<option value=104>' + "Uninstall Agent" + '</option>'; }
5250 - if ((rights & 64) && ((added & 8) == 0)) { added |= 8; addedOptions += '<option value=100>' + "Wake-up devices" + '</option>'; }
5251 - if ((rights & 262144) && ((added & 4) == 0)) { added |= 4; addedOptions += '<option value=4>' + "Sleep devices" + '</option><option value=3>' + "Reset devices" + '</option><option value=2>' + "Power off devices" + '</option>'; }
5252 - if ((rights & 131072) && ((added & 16) == 0)) { added |= 16; addedOptions += '<option value=106>' + "Run commands" + '</option>'; }
5253 - if ((rights & 16384) && ((added & 32) == 0)) { added |= 32; addedOptions += '<option value=108>' + "Device notification" + '</option>'; }
5254 - if ((rights & 4) && ((added & 64) == 0)) { added |= 64; addedOptions += '<option value=107>' + "Edit tags" + '</option>'; }
5255 - if ((rights & 8) && ((added & 256) == 0)) { added |= 256; addedOptions += '<option value=109>' + "Upload files" + '</option>'; }
5256 - if ((rights & 32768) && ((added & 128) == 0)) { added |= 128; addedOptions += '<option value=101>' + "Delete devices" + '</option>'; }
5249 + if ((rights & 1) && ((added & 2) == 0)) { added |= 2; addedOptions.push({ v: 102, name: "Move to device group" }); }
5250 + if (((node.conn & 1) != 0) && ((rights & 0x8000) != 0) && ((added & 1) == 0)) { added |= 1; addedOptions.push({ v: 104, name: "Uninstall Agent" }); }
5251 + if ((rights & 64) && ((added & 8) == 0)) { added |= 8; addedOptions.push({ v: 100, name: "Wake-up devices" }); }
5252 + if ((rights & 262144) && ((added & 4) == 0)) { added |= 4; addedOptions.push({ v: 4, name: "Sleep devices" }); addedOptions.push({ v: 3, name: "Reset devices" }); addedOptions.push({ v: 2, name: "Power off devices" }); }
5253 + if ((rights & 131072) && ((added & 16) == 0)) { added |= 16; addedOptions.push({ v: 106, name: "Run commands" }); }
5254 + if ((rights & 16384) && ((added & 32) == 0)) { added |= 32; addedOptions.push({ v: 108, name: "Device notification" }); }
5255 + if ((rights & 4) && ((added & 64) == 0)) { added |= 64; addedOptions.push({ v: 107, name: "Edit tags" }); }
5256 + if ((rights & 8) && ((added & 256) == 0)) { added |= 256; addedOptions.push({ v: 109, name: "Upload files" }); }
5257 + if ((rights & 32768) && ((added & 128) == 0)) { added |= 128; addedOptions.push({ v: 101, name: "Delete devices" }); }
5258 if ((node.agent != null) && (features2 & 0x00000010) && (rights == 0xFFFFFFFF) && ((added & 512) == 0)) {
5259 added |= 512;
5259 - addedOptions += '<option value=110>' + "Force agent update" + '</option>';
5260 - addedOptions += '<option value=111>' + "Clear agent core" + '</option>';
5261 - addedOptions += '<option value=112>' + "Upload default server core" + '</option>';
5260 + addedOptions.push({ v: 110, name: "Force agent update" });
5261 + addedOptions.push({ v: 111, name: "Clear agent core" });
5262 + addedOptions.push({ v: 112, name: "Upload default server core" });
5263 }
5264 }
5265
5266 + var addedOptionsStr = '';
5267 + addedOptions.sort(nameSort);
5268 + for (var i in addedOptions) { addedOptionsStr += '<option value=' + addedOptions[i].v + (addedOptions[i].s?' selected':'') + '>' + addedOptions[i].name + '</option>'; }
5269 var x = "Select an operation to perform on all selected devices. Actions will be performed only with proper rights." + '<br /><br />';
5266 - x += addHtmlValue("Operation", '<select id=d2groupop><option value=105>' + "Export device information" + '</option>' + '</option>' + addedOptions + '</select>');
5270 + x += addHtmlValue("Operation", '<select id=d2groupop>' + addedOptionsStr + '</select>');
5271 setDialogMode(2, "Group Action", 3, groupActionFunctionEx, x);
5272 }
5273