From e6dc0aa4293594efe8dc481fb9179d42984e8fe3 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Mon, 26 May 2025 16:18:16 -0600 Subject: [PATCH] fix missing global, make start test button responsive, skeleton stop endpoint --- ui/app.py | 11 +++++++++++ ui/index.html | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ui/app.py b/ui/app.py index 74bdefd..2fc5752 100755 --- a/ui/app.py +++ b/ui/app.py @@ -70,6 +70,7 @@ def handler(signum, frame): signal.signal(signal.SIGINT, handler) def sense_armed(): + global lastsense try: with gpiod.request_lines( "/dev/gpiochip0", @@ -185,6 +186,16 @@ class App: else: return "Method not allowed", 405 + # end point for concluding a test + @cherrypy.expose + def endtest(self): + if cherrypy.request.method == 'GET': + status = "idle" + cherrypy.log("status " + status) + return "Test concluded" + else: + return "Method not allowed", 405 + # end point for handling AJAX requests for current status @cherrypy.expose @cherrypy.tools.json_out() diff --git a/ui/index.html b/ui/index.html index f99fe8e..bd8dcd1 100644 --- a/ui/index.html +++ b/ui/index.html @@ -62,12 +62,22 @@ const response = fetch("/armsystem", fetchOptions); } + let status = "idle"; + // start current test by just hitting an endpoint function startTest() { const fetchOptions = { method: "GET", }; - const response = fetch("/starttest", fetchOptions); + if (status == "idle") { + status = "testing"; + document.querySelector('#startTest').textContent = 'End Test'; + const response = fetch("/starttest", fetchOptions); + } else { + status = "idle"; + document.querySelector('#startTest').textContent = 'Start Test'; + const response = fetch("/endtest", fetchOptions); + } } -- 2.47.2