Added batch device notification.
Ylian Saint-Hilaire committed
Aug 21, 2020 at 16:36 UTC
df0f964fe665b2693e222bfc3f811ae434e57f1c
2 files changed
+21
-3
meshuser.js
+1
-1
@@ -1220,7 +1220,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1220
if (common.validateString(command.nodeid, 1, 1024) == false) {
1221
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'msg', result: 'Unable to route', tag: command.tag, responseid: command.responseid })); } catch (ex) { } }
1222
return;
1223
- }
1223
+ }
1224
1225
// Rights check
1226
var requiredRights = null, requiredNonRights = null;
views/default.handlebars
+20
-2
@@ -4380,7 +4380,7 @@
4380
}
4381
4382
var x = "Select an operation to perform on all selected devices. Actions will be performed only with proper rights." + '<br /><br />';
4383
- x += addHtmlValue("Operation", '<select id=d2groupop><option value=100>' + "Wake-up devices" + '</option><option value=106>' + "Run commands" + '</option><option value=4>' + "Sleep devices" + '</option><option value=3>' + "Reset devices" + '</option><option value=2>' + "Power off devices" + '</option><option value=105>' + "Export device information" + '</option><option value=102>' + "Move to device group" + '</option>' + '</option><option value=107>' + "Edit tags" + '</option>' + addedOptions + '<option value=101>' + "Delete devices" + '</option></select>');
4383
+ x += addHtmlValue("Operation", '<select id=d2groupop><option value=100>' + "Wake-up devices" + '</option><option value=106>' + "Run commands" + '</option><option value=4>' + "Sleep devices" + '</option><option value=3>' + "Reset devices" + '</option><option value=2>' + "Power off devices" + '</option><option value=105>' + "Export device information" + '</option><option value=102>' + "Move to device group" + '</option>' + '</option><option value=107>' + "Edit tags" + '</option><option value=108>' + "Device notification" + '</option>' + addedOptions + '<option value=101>' + "Delete devices" + '</option></select>');
4384
setDialogMode(2, "Group Action", 3, groupActionFunctionEx, x);
4385
}
4386
@@ -4446,6 +4446,14 @@
4446
x += addHtmlValue("Operation", '<select id=d2deviceop style=float:right;width:250px><option value=1>' + "Add tags" + '</option><option value=2>' + "Set tags" + '</option><option value=3>' + "Remove tags" + '</option></select>');
4447
x += addHtmlValue("Tags", '<input id=dp10devicevalue maxlength=4096 placeholder="' + "Tag1, Tag2, Tag3" + '" />');
4448
setDialogMode(2, "Edit Device Tags", 3, d2groupActionFunctionTagsExec, x);
4449
+ } else if (op == 108) {
4450
+ // Device notification
4451
+ var x = "Perform batch device notification" + '<br /><br />';
4452
+ x += '<select id=d2deviceop style=width:100%><option value=1>' + "Message Box" + '</option><option value=2>' + "Toast Notification" + '</option></select>';
4453
+ x += '<br /><input id=dp2notifyTitle maxlength=256 placeholder="' + "Title" + '" style=width:100% />';
4454
+ x += '<textarea id=d2notifyMsg style=background-color:#fcf3cf;width:100%;height:140px;resize:none;overflow-y:scroll></textarea>';
4455
+ setDialogMode(2, "Device Notification", 3, d2groupActionFunctionNotifyExec, x);
4456
+ Q('d2notifyMsg').focus();
4457
} else {
4458
// Power operation
4459
meshserver.send({ action: 'poweraction', nodeids: getCheckedDevices(), actiontype: parseInt(op) });
@@ -4453,6 +4461,17 @@
4461
}
4462
}
4463
4464
+ function d2groupActionFunctionNotifyExec() {
4465
+ var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value, chkNodeIds = getCheckedDevices();
4466
+ if (msg.length == 0) return;
4467
+ if (title == '') { title = '{{{title}}}'; }
4468
+ if (op == 1) { // MessageBox
4469
+ for (var i = 0; i < chkNodeIds.length; i++) { meshserver.send({ action: 'msg', type: 'messagebox', nodeid: chkNodeIds[i], title: title, msg: msg }); }
4470
+ } else if (op == 2) { // Toast
4471
+ meshserver.send({ action: 'toast', nodeids: chkNodeIds, title: title, msg: msg });
4472
+ }
4473
+ }
4474
+
4475
function d2groupActionFunctionTagsExec() {
4476
var chkNodeIds = getCheckedDevices(), op = Q('d2deviceop').value, optags = Q('dp10devicevalue').value;
4477
if (op == 2) { // Set tags
@@ -5964,7 +5983,6 @@
5983
}
5984
5985
function deviceMessageFunctionEx() {
5967
- if (desktop == null || desktop.State != 3) return;
5986
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: '{{{title}}}', msg: Q('d2devMessage').value });
5987
}
5988