From: Bdale Garbee Date: Mon, 26 May 2025 22:18:16 +0000 (-0600) Subject: fix missing global, make start test button responsive, skeleton stop endpoint X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e6dc0aa4293594efe8dc481fb9179d42984e8fe3;p=fw%2Fquantimotor fix missing global, make start test button responsive, skeleton stop endpoint --- 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); + } }