add different notification types (#5669)

Signed-off-by: si458 <simonsmith5521@gmail.com>

Simon Smith committed Jan 8, 2024 at 06:21 UTC bb616903eeaaf841c9b383ab558dba947556eaa7
1 file changed +16 -3
views/default.handlebars
+16 -3
@@ -8141,12 +8141,25 @@
8141
8142 function deviceToastFunction() {
8143 if (xxdialogMode) return;
8144 - setDialogMode(2, "Device Notification", 3, deviceToastFunctionEx, '<textarea id=d2devToast style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>');
8145 - Q('d2devToast').focus();
8144 + 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>';
8145 + x += '<br /><input id=dp2notifyTitle maxlength=256 placeholder="' + "Title" + '" style=width:100% />';
8146 + x += '<textarea id=d2notifyMsg style=background-color:#fcf3cf;width:100%;height:140px;resize:none;overflow-y:scroll></textarea>';
8147 + setDialogMode(2, "Device Notification", 3, deviceToastFunctionEx, x);
8148 + Q('d2notifyMsg').focus();
8149 }
8150
8151 function deviceToastFunctionEx() {
8149 - meshserver.send({ action: 'toast', nodeids: [ currentNode._id ], title: decodeURIComponent('{{{extitle}}}'), msg: Q('d2devToast').value });
8152 + var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value;
8153 + if (msg.length == 0) return;
8154 + if (title == '') { title = decodeURIComponent('{{{extitle}}}'); }
8155 + if (title == '') { title = "MeshCentral"; }
8156 + if (op == 1) { // MessageBox
8157 + meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: title, msg: msg });
8158 + } else if (op == 2) { // Toast
8159 + meshserver.send({ action: 'toast', nodeids: [ currentNode._id ], title: title, msg: msg });
8160 + } else if (op == 3) { // Old Style MessageBox
8161 + meshserver.send({ action: 'msg', type: 'alertbox', nodeid: currentNode._id, title: title, msg: msg });
8162 + }
8163 }
8164
8165 // Lock desktop