mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 07:05:52 -05:00
add timeout to message box notifications (#5689)
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
cb0b02152a
commit
00db0a3a39
@ -1230,8 +1230,11 @@ function handleServerCommand(data) {
|
||||
ipr.message = data.msg;
|
||||
ipr.username = data.username;
|
||||
if (data.realname && (data.realname != '')) { ipr.username = data.realname; }
|
||||
ipr.timeout = (typeof data.timeout === 'number' ? data.timeout : 120000);
|
||||
global._clientmessage = ipr.then(function (img) {
|
||||
this.messagebox = require('win-dialog').create(this.title, this.message, this.username, { timeout: 120000, b64Image: img.split(',').pop(), background: color_options.background, foreground: color_options.foreground });
|
||||
var options = { b64Image: img.split(',').pop(), background: color_options.background, foreground: color_options.foreground }
|
||||
if (this.timeout != 0) { options.timeout = this.timeout; }
|
||||
this.messagebox = require('win-dialog').create(this.title, this.message, this.username, options);
|
||||
this.__childPromise.addMessage = this.messagebox.addMessage.bind(this.messagebox);
|
||||
return (this.messagebox);
|
||||
});
|
||||
|
12
meshctrl.js
12
meshctrl.js
@ -941,15 +941,17 @@ if (args['_'].length == 0) {
|
||||
console.log("Display a message on the remote device, Example usages:\r\n");
|
||||
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceMessage --id 'deviceid' --msg \"message\""));
|
||||
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceMessage --id 'deviceid' --msg \"message\" --title \"title\""));
|
||||
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceMessage --id 'deviceid' --msg \"message\" --title \"title\" --timeout 120000"));
|
||||
console.log("\r\nRequired arguments:\r\n");
|
||||
if (process.platform == 'win32') {
|
||||
console.log(" --id [deviceid] - The device identifier.");
|
||||
console.log(" --id [deviceid] - The device identifier.");
|
||||
} else {
|
||||
console.log(" --id '[deviceid]' - The device identifier.");
|
||||
console.log(" --id '[deviceid]' - The device identifier.");
|
||||
}
|
||||
console.log(" --msg [message] - The message to display.");
|
||||
console.log(" --msg [message] - The message to display.");
|
||||
console.log("\r\nOptional arguments:\r\n");
|
||||
console.log(" --title [title] - Messagebox title, default is \"MeshCentral\".");
|
||||
console.log(" --title [title] - Messagebox title, default is \"MeshCentral\".");
|
||||
console.log(" --timeout [miliseconds] - After timeout messagebox vanishes, 0 keeps messagebox open until closed manually, default is 120000 (2 Minutes).");
|
||||
break;
|
||||
}
|
||||
case 'devicetoast': {
|
||||
@ -1735,7 +1737,7 @@ function serverConnect() {
|
||||
break;
|
||||
}
|
||||
case 'devicemessage': {
|
||||
ws.send(JSON.stringify({ action: 'msg', type: 'messagebox', nodeid: args.id, title: args.title ? args.title : "MeshCentral", msg: args.msg, responseid: 'meshctrl' }));
|
||||
ws.send(JSON.stringify({ action: 'msg', type: 'messagebox', nodeid: args.id, title: args.title ? args.title : "MeshCentral", msg: args.msg, timeout: args.timeout ? args.timeout : 120000, responseid: 'meshctrl' }));
|
||||
break;
|
||||
}
|
||||
case 'devicetoast': {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user