From 7847c54c8a2055f0b0e583430ab38b7d9b7dd60b Mon Sep 17 00:00:00 2001 From: cmotelet Date: Sun, 2 Feb 2020 19:12:17 +0100 Subject: [PATCH] add silent alarm with PUT method --- public/js/signalk-autopilot.js | 54 +--------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/public/js/signalk-autopilot.js b/public/js/signalk-autopilot.js index f46aaaa..3865a83 100644 --- a/public/js/signalk-autopilot.js +++ b/public/js/signalk-autopilot.js @@ -203,58 +203,6 @@ var sendCommand = function(cmdAction) { console.log(cmdJson); ws.send(cmdJson); setTimeout(() => {sendIconDiv.style.visibility = 'hidden';}, timeoutBlink); - -/* - window.fetch('/plugins/raymarineautopilot/command', { - method: 'POST', - headers: { - "Content-Type": "application/json" - }, - body: cmdJson, - }).then(function(response) { - setTimeout(() => {sendIconDiv.style.visibility = 'hidden';}, timeoutBlink); - if (response.status !== 200) { - errorIconDiv.style.visibility = 'visible'; - if (response.status === 401) { - alert('You must be authenticated to send commands !') - } else { - errorIconDiv.style.visibility = 'visible'; - alert('[' + response.status + ']' + response.text) - } - } - }, function(status) { - sendIconDiv.style.visibility = 'hidden'; - errorIconDiv.style.visibility = 'visible'; - alert(status.message) - } - ); -*/ -} - -var silenceAlarm = function(skPathToAck) { - window.fetch('/silenceNotification', { - method: 'POST', - headers: { - "Content-Type": "application/json" - }, - body: {path: skPathToAck}, - }).then(function(response) { - setTimeout(() => {sendIconDiv.style.visibility = 'hidden';}, timeoutBlink); - if (response.status !== 200) { - errorIconDiv.style.visibility = 'visible'; - if (response.status === 401) { - alert('You must be authenticated to send commands !') - } else { - errorIconDiv.style.visibility = 'visible'; - alert('[' + response.status + ']' + response.text) - } - } - }, function(status) { - sendIconDiv.style.visibility = 'hidden'; - errorIconDiv.style.visibility = 'visible'; - alert(status.message) - } - ); } var notificationToValue = function (skPathToAck) { @@ -274,7 +222,7 @@ var sendSilence = function() { } } else { if (skPathToAck !== '') { - silenceAlarm(skPathToAck); + sendCommand({"path":"notifications." + skPathToAck + ".state","value":"normal"}); } countDownValue = 0; updateCountDownCounter();