]> git.gag.com Git - fw/quantimotor/commitdiff
fix missing global, make start test button responsive, skeleton stop endpoint
authorBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 22:18:16 +0000 (16:18 -0600)
committerBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 22:18:16 +0000 (16:18 -0600)
ui/app.py
ui/index.html

index 74bdefd1075ad4061a3b1b430ac763b476b1b084..2fc57521cdbf0c23c0c2baf85c0c64b689031f1d 100755 (executable)
--- 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()
index f99fe8e9d086b4ed655469c216818b8a1c2c488b..bd8dcd10da8d40631e3e0c5416289ec8dedb6c2b 100644 (file)
        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);
+        }
       }
     </script>
   </head>