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

Improved push messaging support.

This commit is contained in:
Ylian Saint-Hilaire 2021-01-31 00:18:19 -08:00
parent 8a81bd30f8
commit 0658d6e5a5
4 changed files with 162 additions and 20 deletions

View file

@ -823,9 +823,10 @@
</td>
<td>&nbsp;</td>
<td id="p15outputselecttd">
<select id=p15outputselect>
<option value=1>Agent</option>
<option value=2>MQTT</option>
<select id=p15outputselect onchange="setupConsole()">
<option id="p15outputselect1" value=1>Agent</option>
<option id="p15outputselect3" value=3>Push</option>
<option id="p15outputselect2" value=2>MQTT</option>
</select>
</td>
<td style="width:1%"><input id="id_p15consoleClear" type="button" class="bottombutton" value="Clear" onclick="p15consoleClear()" /></td>
@ -5976,7 +5977,7 @@
x += '<input type=button value="' + "Log Event" + '" title="' + "Write an event for this device" + '" onclick=writeDeviceEvent("' + encodeURIComponentEx(node._id) + '") />';
if ((meshrights & 8) && ((connectivity & 1) || (node.pmt == 1))) { x += '<input type=button value="' + "Message" + '" title="' + "Display a text message on the remote device" + '" onclick=deviceMessageFunction() />'; }
//if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="' + "Display a text message of the remote device" + '" onclick=deviceToastFunction() />'; }
if ((connectivity & 1) && (meshrights & 8) && (node.agent.id == 14)) { x += '<input type=button value="' + "Chat" + '" title="' + "Open chat window to this computer" + '" onclick=deviceChat(event) />'; }
if ((meshrights & 8) && (connectivity & 1) || (node.pmt == 1)) { x += '<input type=button value="' + "Chat" + '" title="' + "Open chat window to this computer" + '" onclick=deviceChat(event) />'; }
if ((serverinfo.guestdevicesharing !== false) && (node.agent != null) && (node.agent.caps & 3) && (connectivity & 1) && (meshrights & 0x80008) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 0x1000) == 0))) { x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />'; }
// Custom UI
@ -6302,6 +6303,7 @@
if (xxdialogMode) return;
var url = '/messenger?id=meshmessenger/' + encodeURIComponentEx(currentNode._id) + '/' + encodeURIComponentEx(userinfo._id) + '&title=' + currentNode.name;
if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; }
if (currentNode.pmt == 1) { url += '&pmt=1'; } // Push messaging is possible for this device
if (e && (e.shiftKey == true)) {
safeNewWindow(url, 'meshmessenger:' + currentNode._id);
} else {
@ -9333,9 +9335,20 @@
var onlineText = ((consoleNode.conn & 1) != 0) ? "Agent is online" : "Agent is offline"
if ((consoleNode.conn & 16) != 0) { onlineText += ", MQTT is online" }
QH('p15statetext', onlineText);
QE('p15consoleText', online);
QE('p15uploadCore', ((consoleNode.conn & 1) != 0));
QV('p15outputselecttd', (consoleNode.conn & 17) == 17);
QV('p15outputselecttd', ((consoleNode.conn & 16) != 0) || (currentNode.pmt == 1));
QV('p15outputselect2', ((consoleNode.conn & 16) != 0)); // MQTT channel
QV('p15outputselect3', (currentNode.pmt == 1)); // Push Notification channel
var c = Q('p15outputselect').value;
if (((consoleNode.conn & 16) == 0) && (c == 2)) { c = 1; Q('p15outputselect').value = 1; }
if ((currentNode.pmt != 1) && (c == 3)) { c = 1; Q('p15outputselect').value = 1; }
var active = false;
if (((consoleNode.conn & 1) != 0) && (c == 1)) { active = true; } // Agent
if (((consoleNode.conn & 16) != 0) && (c == 2)) { active = true; } // MQTT
if ((consoleNode.pmt == 1) && (c == 3)) { active = true; } // Push
QE('p15consoleText', active);
} else {
QH('p15statetext', "Access Denied");
QE('p15consoleText', false);
@ -9368,12 +9381,17 @@
consoleServerText += t;
meshserver.send({ action: 'serverconsole', value: v });
} else {
if (((consoleNode.conn & 16) != 0) && ((Q('p15outputselect').value == 2) || ((consoleNode.conn & 1) == 0))) {
if (((consoleNode.conn & 16) != 0) && (Q('p15outputselect').value == 2)) {
// Send the command to MQTT
t = '<div style=color:orange>' + "MQTT" + '&gt; ' + EscapeHtml(v) + '<br/></div>';
consoleNode.consoleText += t;
meshserver.send({ action: 'sendmqttmsg', topic: 'console', nodeids: [ consoleNode._id ], msg: v });
} else {
} else if ((consoleNode.pmt == 1) && (Q('p15outputselect').value == 3)) {
// Send the command using push notification
t = '<div style=color:violet>' + "PUSH" + '&gt; ' + EscapeHtml(v) + '<br/></div>';
consoleNode.consoleText += t;
meshserver.send({ action: 'pushconsole', nodeid: consoleNode._id, console: v });
} else if ((consoleNode.conn & 1) == 0) {
// Send the command to the mesh agent
consoleNode.consoleText += t;
meshserver.send({ action: 'msg', type: 'console', nodeid: consoleNode._id, value: v });