mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 22:25:52 -05:00
Added batch device notification.
This commit is contained in:
parent
70419c9381
commit
df0f964fe6
@ -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;
|
||||
|
@ -4380,7 +4380,7 @@
|
||||
}
|
||||
|
||||
var x = "Select an operation to perform on all selected devices. Actions will be performed only with proper rights." + '<br /><br />';
|
||||
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>');
|
||||
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>');
|
||||
setDialogMode(2, "Group Action", 3, groupActionFunctionEx, x);
|
||||
}
|
||||
|
||||
@ -4446,6 +4446,14 @@
|
||||
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>');
|
||||
x += addHtmlValue("Tags", '<input id=dp10devicevalue maxlength=4096 placeholder="' + "Tag1, Tag2, Tag3" + '" />');
|
||||
setDialogMode(2, "Edit Device Tags", 3, d2groupActionFunctionTagsExec, x);
|
||||
} else if (op == 108) {
|
||||
// Device notification
|
||||
var x = "Perform batch device notification" + '<br /><br />';
|
||||
x += '<select id=d2deviceop style=width:100%><option value=1>' + "Message Box" + '</option><option value=2>' + "Toast Notification" + '</option></select>';
|
||||
x += '<br /><input id=dp2notifyTitle maxlength=256 placeholder="' + "Title" + '" style=width:100% />';
|
||||
x += '<textarea id=d2notifyMsg style=background-color:#fcf3cf;width:100%;height:140px;resize:none;overflow-y:scroll></textarea>';
|
||||
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 });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user