Merge branch 'cbayer-push-notifications' into 'master'

push notifications

See merge request gridtracker.org/gridtracker!280

If this is changing anything in the UI or operational behavior, please prepare to update the wiki!
merge-requests/237/merge
chrbayer84 2023-09-04 19:47:53 +00:00
commit d7a6e20ebe
Nie znaleziono w bazie danych klucza dla tego podpisu
9 zmienionych plików z 239 dodań i 4 usunięć

Wyświetl plik

@ -2978,6 +2978,59 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</tr>
</table>
</div>
<div class="mapItem">
<table align="center">
<tr>
<td>
<label data-i18n="settings.OAMS.simplepush.enable.label" for="msgSimplepush">Enable / Disable Simplepush Message forwarding</label>
<input title="Enable / Disable Simplepush" type="checkbox" id="msgSimplepush"
onclick="setOamsSimplepush(this);" />
</td>
</tr>
<tr>
<td data-i18n="settings.OAMS.simplepush.apikey.label"
title="SimplePush API Key to forward messages to your phone">SimplePush API Key</td>
</tr>
<tr>
<td>
<input title="SimplePush API Key to forward messages to your phone" type="text" id="msgSimplePushApiKey"
class="inputTextValue" maxlength="255" size="16"
oninput="ValidateText(this); newMessageSetting(this);" />
</td>
</tr>
</table>
</div>
<div class="mapItem">
<table align="center">
<tr>
<td>
<label data-i18n="settings.OAMS.pushover.enable.label" for="msgPushover">Enable / Disable Pushover Message forwarding</label>
<input title="Enable / Disable Pushover" type="checkbox" id="msgPushover"
onclick="setOamsPushover(this);" />
</td>
</tr>
<tr>
<td data-i18n="settings.OAMS.pushover.credentials.label"
title="Pushover Credentials to forward messages to your phone">Pushover Credentials</td>
</tr>
<tr>
<td>
<label data-i18n="settings.OAMS.pushover.username.label" for="msgPushoverUsername">Username</label>
<input title="Pushover Username to forward messages to your phone" type="text" id="msgPushoverUsername"
class="inputTextValue" maxlength="255" size="16"
oninput="ValidateText(this); newMessageSetting(this);" />
</td>
</tr>
<tr>
<td>
<label data-i18n="settings.OAMS.pushover.token.label" for="msgPushoverToken">Token</label>
<input title="Pushover Token to forward messages to your phone" type="text" id="msgPushoverToken"
class="inputTextValue" maxlength="255" size="16"
oninput="ValidateText(this); newMessageSetting(this);" />
</td>
</tr>
</table>
</div>
<br />
<div class="mapItem" id="msgFrequencySelectDiv">
<table align="center">

Wyświetl plik

@ -166,6 +166,12 @@
"settings.Alerts.label": "警報",
"settings.CallRoster.label": "呼叫清單",
"settings.OAMS.label": "OAMS",
"settings.OAMS.simplepush.enable.label": "Simplepush Message Forwarding on/off",
"settings.OAMS.simplepush.apikey.label": "Simplepush API Key",
"settings.OAMS.pushover.enable.label": "Pushover Message Forwarding on/off",
"settings.OAMS.pushover.credentials.label": "Pushover Credentials",
"settings.OAMS.pushover.username.label": "Username",
"settings.OAMS.pushover.token.label": "Token",
"settings.Logbook.label": "日志",
"settings.Update.label": "更新",
"settings.About.label": "關於",

Wyświetl plik

@ -166,6 +166,12 @@
"settings.Alerts.label": "警报",
"settings.CallRoster.label": "呼叫列表",
"settings.OAMS.label": "OAMS",
"settings.OAMS.simplepush.enable.label": "Simplepush Message Forwarding on/off",
"settings.OAMS.simplepush.apikey.label": "Simplepush API Key",
"settings.OAMS.pushover.enable.label": "Pushover Message Forwarding on/off",
"settings.OAMS.pushover.credentials.label": "Pushover Credentials",
"settings.OAMS.pushover.username.label": "Username",
"settings.OAMS.pushover.token.label": "Token",
"settings.Logbook.label": "日志",
"settings.Update.label": "更新",
"settings.About.label": "关于",

Wyświetl plik

@ -166,6 +166,12 @@
"settings.Alerts.label": "Alarme",
"settings.CallRoster.label": "Rufzeichenliste",
"settings.OAMS.label": "OAMS",
"settings.OAMS.simplepush.enable.label": "Simplepush Nachrichtenweiterleitung ein/aus",
"settings.OAMS.simplepush.apikey.label": "Simplepush API Key",
"settings.OAMS.pushover.enable.label": "Pushover Nachrichtenweiterleitung ein/aus",
"settings.OAMS.pushover.credentials.label": "Pushover Zugangsdaten",
"settings.OAMS.pushover.username.label": "Benutzername",
"settings.OAMS.pushover.token.label": "Token",
"settings.Logbook.label": "Logbook",
"settings.Update.label": "Update",
"settings.About.label": "Über",

Wyświetl plik

@ -165,6 +165,12 @@
"settings.Alerts.label": "Alerts",
"settings.CallRoster.label": "Call Roster",
"settings.OAMS.label": "OAMS",
"settings.OAMS.simplepush.enable.label": "Simplepush Message Forwarding on/off",
"settings.OAMS.simplepush.apikey.label": "Simplepush API Key",
"settings.OAMS.pushover.enable.label": "Pushover Message Forwarding on/off",
"settings.OAMS.pushover.credentials.label": "Pushover Credentials",
"settings.OAMS.pushover.username.label": "Username",
"settings.OAMS.pushover.token.label": "Token",
"settings.Logbook.label": "Logbook",
"settings.Update.label": "Update",
"settings.About.label": "About",

Wyświetl plik

@ -193,7 +193,12 @@ var def_msgSettings = {
msgFrequencySelect: 0,
msgActionSelect: 1,
msgAwaySelect: 0,
msgAwayText: "I am away from the shack at the moment"
msgAwayText: "I am away from the shack at the moment",
msgSimplepush: 0,
msgSimplePushApiKey: "",
msgPushover: 0,
msgPushoverUsername: "",
msgPushoverToken: ""
};
var def_receptionSettings = {

Wyświetl plik

@ -469,6 +469,7 @@ GT.unconfirmedCalls = new Map();
GT.tracker = {};
GT.lastTrasmissionTimeSec = timeNowSec();
GT.getPostBuffer = getPostBuffer;
const PSKREPORTER_INTERVAL_IN_SECONDS = 5 * 60;
@ -10677,6 +10678,18 @@ function setOamsBandActivityNeighbors(checkbox)
oamsBandActivityCheck();
}
function setOamsSimplepush(checkbox)
{
GT.msgSettings.msgSimplepush = checkbox.checked;
localStorage.msgSettings = JSON.stringify(GT.msgSettings);
}
function setOamsPushover(checkbox)
{
GT.msgSettings.msgPushover = checkbox.checked;
localStorage.msgSettings = JSON.stringify(GT.msgSettings);
}
function setMsgEnable(checkbox)
{
GT.appSettings.gtMsgEnable = checkbox.checked;
@ -13026,6 +13039,9 @@ function loadMsgSettings()
{
document.getElementById(key).value = GT.msgSettings[key];
}
msgSimplepush.checked = GT.msgSettings.msgSimplepush;
msgPushover.checked = GT.msgSettings.msgPushover;
ValidateText(msgAwayText);
setMsgSettingsView();
}

Wyświetl plik

@ -567,6 +567,46 @@ function htmlEntities(str)
.replace(/"/g, "&quot;");
}
function sendSimplePushMessage(jsmesg)
{
const url = "https://api.simplepush.io/send";
let data = { key: GT.msgSettings.msgSimplePushApiKey, title: "GridTracker Chat Message", msg: jsmesg.call + ": " + jsmesg.msg };
getPostBuffer(
url,
null, // callback,
null,
"https",
443,
data,
500, // timeoutMs,
null, // timeoutCallback,
"simplepush"
);
}
function sendPushOverMessage(jsmesg)
{
const url = "https://api.pushover.net/1/messages.json";
let data = {
user: GT.msgSettings.msgPushoverUsername,
token: GT.msgSettings.msgPushoverToken,
title:
"GridTracker Chat Message",
message: jsmesg.call + ": " + jsmesg.msg
};
getPostBuffer(
url,
null, // callback,
null,
"https",
443,
data,
500, // timeoutMs,
null, // timeoutCallback,
"pushover"
);
}
function gtChatMessage(jsmesg)
{
if (GT.appSettings.gtMsgEnable == true)
@ -580,7 +620,7 @@ function gtChatMessage(jsmesg)
}
catch (e)
{
jsmesg.msg = "Corrupt message recieved";
jsmesg.msg = "Corrupt message received";
}
if (jsmesg.call != null && jsmesg.call != "" && jsmesg.call != "NOCALL")
@ -589,6 +629,16 @@ function gtChatMessage(jsmesg)
GT.gtUnread[cid] = true;
GT.gtCurrentMessageCount++;
if (GT.msgSettings.msgSimplepush && GT.msgSettings.msgSimplePushApiKey != null)
{
sendSimplePushMessage(jsmesg);
}
if (GT.msgSettings.msgPushover && GT.msgSettings.msgPushoverUsername != null &&
GT.msgSettings.msgPushoverToken != null)
{
sendPushOverMessage(jsmesg);
}
if (newChatMessage(cid, jsmesg) == false) alertChatMessage();
if (GT.msgSettings.msgAwaySelect == 1 && !(cid in GT.gtSentAwayToCid))

Wyświetl plik

@ -110,8 +110,95 @@ function sendAlerts(callRoster, rosterSettings)
{
conosle.log(e);
}
CR.scriptReport = Object();
}
else CR.scriptReport = Object();
if (window.opener.GT.msgSettings.msgPushover)
{
sendPushOverAlert(parseCRJson(CR.scriptReport));
}
if (window.opener.GT.msgSettings.msgSimplepush)
{
sendSimplePushMessage(parseCRJson(CR.scriptReport));
}
CR.scriptReport = Object();
}
}
function sendSimplePushMessage(message)
{
const url = "https://api.simplepush.io/send";
let data = {
key: window.opener.GT.msgSettings.msgSimplePushApiKey,
title: "GridTracker Alert " + window.opener.GT.appSettings.myCall,
msg: message
};
window.opener.GT.getPostBuffer(
url,
null, // callback,
null,
"https",
443,
data,
500, // timeoutMs,
null, // timeoutCallback,
"simplepush"
);
}
function sendPushOverAlert(message)
{
const url = "https://api.pushover.net/1/messages.json";
let data = {
user: window.opener.GT.msgSettings.msgPushoverUsername,
token: window.opener.GT.msgSettings.msgPushoverToken,
title:
"GridTracker Alert " + window.opener.GT.appSettings.myCall,
message: message
};
window.opener.GT.getPostBuffer(
url,
null, // callback,
null,
"https",
443,
data,
500, // timeoutMs,
null, // timeoutCallback,
"pushover"
);
}
function parseCRJson(data)
{
let message = "";
for (let callsign in data)
{
if (data[callsign].shouldAlert === true && data[callsign].alerted === false)
{
if (data[callsign].grid)
{
if (data[callsign].state)
{
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].grid + ", " + data[callsign].band + ", " + data[callsign].state + "\n";
}
else
{
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].grid + ", " + data[callsign].band + "\n";
}
}
else
{
if (!data[callsign].grid)
{
if (data[callsign].state)
{
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].band + ", " + data[callsign].state + "\n";
}
else
{
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].band + "\n";
}
}
}
}
}
return message;
}