From 66e45c2aafc57a195fc148097ba629bf5a1f869f Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 21 Aug 2020 16:36:53 -0700 Subject: [PATCH] Added batch device notification. --- meshuser.js | 2 +- views/default.handlebars | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/meshuser.js b/meshuser.js index 5123bf09..86af7c65 100644 --- a/meshuser.js +++ b/meshuser.js @@ -1220,7 +1220,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (common.validateString(command.nodeid, 1, 1024) == false) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'msg', result: 'Unable to route', tag: command.tag, responseid: command.responseid })); } catch (ex) { } } return; - } + } // Rights check var requiredRights = null, requiredNonRights = null; diff --git a/views/default.handlebars b/views/default.handlebars index 4c4d1edf..58622baa 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4380,7 +4380,7 @@ } var x = "Select an operation to perform on all selected devices. Actions will be performed only with proper rights." + '

'; - x += addHtmlValue("Operation", ''); + x += addHtmlValue("Operation", ''); setDialogMode(2, "Group Action", 3, groupActionFunctionEx, x); } @@ -4446,6 +4446,14 @@ x += addHtmlValue("Operation", ''); x += addHtmlValue("Tags", ''); setDialogMode(2, "Edit Device Tags", 3, d2groupActionFunctionTagsExec, x); + } else if (op == 108) { + // Device notification + var x = "Perform batch device notification" + '

'; + x += ''; + x += '
'; + x += ''; + setDialogMode(2, "Device Notification", 3, d2groupActionFunctionNotifyExec, x); + Q('d2notifyMsg').focus(); } else { // Power operation meshserver.send({ action: 'poweraction', nodeids: getCheckedDevices(), actiontype: parseInt(op) }); @@ -4453,6 +4461,17 @@ } } + function d2groupActionFunctionNotifyExec() { + var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value, chkNodeIds = getCheckedDevices(); + if (msg.length == 0) return; + if (title == '') { title = '{{{title}}}'; } + if (op == 1) { // MessageBox + for (var i = 0; i < chkNodeIds.length; i++) { meshserver.send({ action: 'msg', type: 'messagebox', nodeid: chkNodeIds[i], title: title, msg: msg }); } + } else if (op == 2) { // Toast + meshserver.send({ action: 'toast', nodeids: chkNodeIds, title: title, msg: msg }); + } + } + function d2groupActionFunctionTagsExec() { var chkNodeIds = getCheckedDevices(), op = Q('d2deviceop').value, optags = Q('dp10devicevalue').value; if (op == 2) { // Set tags @@ -5964,7 +5983,6 @@ } function deviceMessageFunctionEx() { - if (desktop == null || desktop.State != 3) return; meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: '{{{title}}}', msg: Q('d2devMessage').value }); }