1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

add timeout to message box notifications (#5689)

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-01-12 22:46:12 +00:00 committed by GitHub
parent cb0b02152a
commit 00db0a3a39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 20 deletions

View file

@ -5766,10 +5766,18 @@
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=2>' + "Toast Notification" + '</option><option value=1>' + "Message Box" + '</option><option value=3>' + "Alert Box" + '</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>';
var x = "<div style=margin-bottom:4px>Perform batch device notification</div>";
x += '<select id=d2deviceop style=width:100%;margin-bottom:4px><option value=2>' + "Toast Notification" + '</option><option value=1>' + "Message Box" + '</option><option value=3>' + "Alert Box" + '</option></select>';
x += '<input id=dp2notifyTitle maxlength=256 placeholder="' + "Title" + '" style=width:100%;box-sizing:border-box;margin-bottom:4px />';
x += '<textarea id=d2notifyMsg style=background-color:#fcf3cf;width:100%;height:140px;resize:none;overflow-y:scroll;box-sizing:border-box;margin-bottom:4px></textarea>';
x += '<select style=width:100% id=d2notifyTimeout>';
x += '<option disabled value="">Only Applicable to Message Box Notifications</option>';
x += '<option value=2 selected>' + "Show for 2 Minutes (Default)" + '</option>';
x += '<option value=10>' + "Show for 10 minutes" + '</option>';
x += '<option value=30>' + "Show for 30 minutes" + '</option>';
x += '<option value=60>' + "Show for 60 minutes" + '</option>';
x += '<option value=0>' + "Show message until dismissed by user" + '</option>';
x += '</select>';
setDialogMode(2, "Device Notification", 3, d2groupActionFunctionNotifyExec, x);
Q('d2notifyMsg').focus();
} else if (op == 109) {
@ -5812,12 +5820,13 @@
function d2groupActionFunctionAgentDefaultCodeExec() { meshserver.send({ action: 'uploadagentcore', nodeids: getCheckedDevices(), type: 'default' }); }
function d2groupActionFunctionNotifyExec() {
var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value, chkNodeIds = getCheckedDevices();
var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value, chkNodeIds = getCheckedDevices(), timeout = parseFloat(Q('d2notifyTimeout').value);
if (msg.length == 0) return;
if (title == '') { title = decodeURIComponent('{{{extitle}}}'); }
if (title == '') { title = "MeshCentral"; }
if (isNaN(timeout)) { timeout = 2; }
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 }); }
for (var i = 0; i < chkNodeIds.length; i++) { meshserver.send({ action: 'msg', type: 'messagebox', nodeid: chkNodeIds[i], title: title, msg: msg, timeout: (timeout * 60000) }); }
} else if (op == 2) { // Toast
meshserver.send({ action: 'toast', nodeids: chkNodeIds, title: title, msg: msg });
} else if (op == 3) { // Old Style MessageBox
@ -8094,17 +8103,27 @@
function deviceMessageFunction() {
if (xxdialogMode) return;
setDialogMode(2, "Device Message", 3, deviceMessageFunctionEx, '<div style=margin-bottom:4px>' + "Display a message box on the remote device." + '</div><textarea id=d2devMessage style=background-color:#fcf3cf;width:100%;height:80px;resize:none;overflow-y:scroll></textarea>');
var x = '<div style=margin-bottom:4px>Display a message box on the remote device.</div>';
x += '<textarea id=d2devMessage style=background-color:#fcf3cf;width:100%;height:80px;resize:none;overflow-y:scroll;box-sizing:border-box;margin-bottom:4px></textarea>';
x += '<select style=width:100% id=d2devTimeout>';
x += '<option value=2 selected>' + "Show for 2 Minutes (Default)" + '</option>';
x += '<option value=10>' + "Show for 10 minutes" + '</option>';
x += '<option value=30>' + "Show for 30 minutes" + '</option>';
x += '<option value=60>' + "Show for 60 minutes" + '</option>';
x += '<option value=0>' + "Show message until dismissed by user" + '</option>';
x += '</select>';
setDialogMode(2, "Device Message", 3, deviceMessageFunctionEx, x);
Q('d2devMessage').focus();
}
function deviceMessageFunctionEx() {
var title = decodeURIComponent('{{{extitle}}}');
var title = decodeURIComponent('{{{extitle}}}'), timeout = parseFloat(Q('d2devTimeout').value);
if (title == '') { title = "MeshCentral"; }
if(isNaN(timeout)){ timeout = 2; }
if (currentNode.pmt == 1) {
meshserver.send({ action: 'pushmessage', nodeid: currentNode._id, title: title, msg: Q('d2devMessage').value });
} else {
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: title, msg: Q('d2devMessage').value });
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: title, msg: Q('d2devMessage').value, timeout: (timeout * 60000) });
}
}
@ -8142,20 +8161,29 @@
function deviceToastFunction() {
if (xxdialogMode) return;
var x = '<select id=d2deviceop style=width:100%><option value=2>' + "Toast Notification" + '</option><option value=1>' + "Message Box" + '</option><option value=3>' + "Alert Box" + '</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>';
var x = '<select id=d2deviceop style=width:100%;margin-bottom:4px><option value=2>' + "Toast Notification" + '</option><option value=1>' + "Message Box" + '</option><option value=3>' + "Alert Box" + '</option></select>';
x += '<input id=dp2notifyTitle maxlength=256 placeholder="' + "Title" + '" style=width:100%;box-sizing:border-box;margin-bottom:4px />';
x += '<textarea id=d2notifyMsg style=background-color:#fcf3cf;width:100%;height:140px;resize:none;overflow-y:scroll;box-sizing:border-box;margin-bottom:4px></textarea>';
x += '<select style=width:100% id=d2notifyTimeout>';
x += '<option disabled value="">Only Applicable to Message Box Notifications</option>';
x += '<option value=2 selected>' + "Show for 2 Minutes (Default)" + '</option>';
x += '<option value=10>' + "Show for 10 minutes" + '</option>';
x += '<option value=30>' + "Show for 30 minutes" + '</option>';
x += '<option value=60>' + "Show for 60 minutes" + '</option>';
x += '<option value=0>' + "Show message until dismissed by user" + '</option>';
x += '</select>';
setDialogMode(2, "Device Notification", 3, deviceToastFunctionEx, x);
Q('d2notifyMsg').focus();
}
function deviceToastFunctionEx() {
var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value;
var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value, timeout = parseFloat(Q('d2notifyTimeout').value);
if (msg.length == 0) return;
if (title == '') { title = decodeURIComponent('{{{extitle}}}'); }
if (title == '') { title = "MeshCentral"; }
if(isNaN(timeout)){ timeout = 2; }
if (op == 1) { // MessageBox
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: title, msg: msg });
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: title, msg: msg, timeout: (timeout * 60000) });
} else if (op == 2) { // Toast
meshserver.send({ action: 'toast', nodeids: [ currentNode._id ], title: title, msg: msg });
} else if (op == 3) { // Old Style MessageBox