Commit cf46e101 authored by Kento HASEGAWA's avatar Kento HASEGAWA

Add a stop button

parent 48485307
......@@ -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"]
......
......@@ -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();
});
});
}
......
......@@ -3,6 +3,7 @@
<h3> 【{{qname}}】</h3>
<p>
<button class="btn btn-primary btn-lg start-button" type="button" data-qname="{{qname}}">Start</button>
<button class="btn btn-danger btn-lg stop-button" type="button" data-qname="all">Stop</button>
</p>
</div>
<div class="col-8">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment