Skip to content

Commit

Permalink
add old style alertbox
Browse files Browse the repository at this point in the history
* add old style alertbox

Signed-off-by: si458 <simonsmith5521@gmail.com>
  • Loading branch information
si458 committed Dec 14, 2023
1 parent 91c83e2 commit 947d843
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions agents/meshcore.js
Expand Up @@ -1466,6 +1466,14 @@ function handleServerCommand(data) {
sendConsoleText('localappMsg: ' + data.appid + ', ' + JSON.stringify(data.value));
if (data.appid != null) { sendToRegisteredApp(data.appid, data.value); } else { broadcastToRegisteredApps(data.value); }
break;
case 'alertbox': {
// Display an old style alert box
if (data.title && data.msg) {
MeshServerLogEx(18, [data.title, data.msg], "Displaying alert box, title=" + data.title + ", message=" + data.msg, data);
try { require('message-box').create(data.title, data.msg, 9999, 1).then(function () { }).catch(function () { }); } catch (ex) { }
}
break;
}
default:
// Unknown action, ignore it.
break;
Expand Down
4 changes: 3 additions & 1 deletion views/default.handlebars
Expand Up @@ -5767,7 +5767,7 @@
} 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></select>';
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>';
setDialogMode(2, "Device Notification", 3, d2groupActionFunctionNotifyExec, x);
Expand Down Expand Up @@ -5820,6 +5820,8 @@
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 });
} else if (op == 3) { // Old Style MessageBox
for (var i = 0; i < chkNodeIds.length; i++) { meshserver.send({ action: 'msg', type: 'alertbox', nodeid: chkNodeIds[i], title: title, msg: msg }); }
}
}

Expand Down

0 comments on commit 947d843

Please sign in to comment.