diff --git a/comm/server/main.py b/comm/server/main.py index 06b627f692f27e6c822b12b4d9a9a7606305e921..02d072940de6193dee2e1d55422f678d7a98e422 100644 --- a/comm/server/main.py +++ b/comm/server/main.py @@ -262,6 +262,22 @@ def solve_questions(qname, qstr): return res +@app.route("/stop", methods=["POST"]) +def stop(): + _client = request.form["client"] + _url = _client + "/stop" + + try: + r = requests.get(_url) + client_res = json.loads(r.text)["status"] + except Exception as e: + client_res = "Connection error" + sys.stderr.write(str(e) + "\n") + + res = {"status": client_res} + + return json.dumps(res) + @app.route("/status", methods=["POST"]) def get_status(): _client = request.form["client"] diff --git a/comm/server/static/js/pynq-manager.js b/comm/server/static/js/pynq-manager.js index 8e06dcb5bf25f60403802c8784e12d3a2c365ee8..903fac2d808810ba4d8788e2bebb1c6fc3f0a606 100644 --- a/comm/server/static/js/pynq-manager.js +++ b/comm/server/static/js/pynq-manager.js @@ -74,7 +74,31 @@ var PynqManager = (function(){ _p.sendStop = function(){ - console.log("Not implemented!"); + for (var key in this.clients){ + (function(_key, _client){ + var statusObj = $(".client-status-row[data-cname='"+_key+"']").find(".client-status-value").eq(0) + $.ajax({ + type: "POST", + url: "/stop", + dataType: "json", + data: { + "client": _client + } + }).done(function(res){ + var answer = res["status"]; + var message = ""; + + if (answer) { + message = answer; + }else{ + message = "Illegal response: " + res; + } + statusObj.text(message); + }).fail(function(){ + statusObj.text("Connection error"); + }); + })(key, this.clients[key]); + } } @@ -139,6 +163,9 @@ $(function(){ var qname = $(this).data("qname"); pm.sendQuestion(qname, after=refresh_question_table); }); + $("#client-control-pane").find(".stop-button").eq(0).click(function(){ + pm.sendStop(); + }); }); } diff --git a/comm/server/templates/part_question_status.html b/comm/server/templates/part_question_status.html index 61a5dc3fe07ebd2c07bebe2d594d9f7db120ee8f..e46a98dccbec283024c7d703e347f519dd76ff9d 100644 --- a/comm/server/templates/part_question_status.html +++ b/comm/server/templates/part_question_status.html @@ -3,6 +3,7 @@

【{{qname}}】

+