Added the facility to accept an alarm from the web interface ("/acceptalarm" url), and added button to web interface page.

This commit is contained in:
Graham Jones
2017-05-07 20:13:54 +01:00
parent b0b61b9fd2
commit 98f6af1083
4 changed files with 19 additions and 5 deletions

View File

@@ -59,8 +59,9 @@
</div>
</div>
<div id="settingsDiv">
<h2>Seizure Detector Settings</h2>
<button id="muteButton">Mute Alarm</button>
<h2>Seizure Detector Settings</h2>
<button id="acceptButton">Accept Alarm</button>
<button id="muteButton">Mute Alarm</button>
<div id="sdSettings">
SD Settings
</div>

View File

@@ -162,7 +162,11 @@ toggleMute = function() {
sd_muted = 1;
$("#muteButton").text("Un-mute Audible Alarm");
}
}
};
acceptAlarm = function() {
$.ajax({url:"/acceptalarm"});
};
$(document).ready(function() {
sd_muted = 0;
@@ -173,4 +177,5 @@ $(document).ready(function() {
setInterval("get_settings();",10000);
setInterval("get_spectrum();",5000);
$("#muteButton").click(toggleMute);
$("#acceptButton").click(acceptAlarm);
});

View File

@@ -755,7 +755,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
Log.v(TAG, "startWebServer()");
mUtil.writeToSysLogFile("SdServer.Start Web Server.");
if (webServer == null) {
webServer = new SdWebServer(getApplicationContext(), mUtil.getDataStorageDir(), mSdData);
webServer = new SdWebServer(getApplicationContext(), mUtil.getDataStorageDir(), mSdData, this);
try {
webServer.start();
} catch (IOException ioe) {

View File

@@ -25,14 +25,16 @@ import fi.iki.elonen.NanoHTTPD;
public class SdWebServer extends NanoHTTPD {
private String TAG = "WebServer";
private SdData mSdData;
private SdServer mSdServer;
private Context mContext;
private File mDataStorageDir = null;
public SdWebServer(Context context, File storageDir, SdData sdData) {
public SdWebServer(Context context, File storageDir, SdData sdData, SdServer sdServer) {
// Set the port to listen on (8080)
super(8080);
mSdData = sdData;
mContext = context;
mSdServer = sdServer;
mDataStorageDir = storageDir;
}
@@ -110,6 +112,12 @@ public class SdWebServer extends NanoHTTPD {
}
break;
case "/acceptalarm":
Log.v(TAG, "WebServer.serve() - Accepting alarm");
mSdServer.acceptAlarm();
answer = "Alarm Accepted";
break;
default:
if (uri.startsWith("/index.html") ||
uri.startsWith("/logfiles.html") ||