Commit 52f168a6 authored by Kento HASEGAWA's avatar Kento HASEGAWA

Make it possible to stop/reset a worker

parent fda45c9f
......@@ -174,6 +174,12 @@ class Host(object):
elif cmd == 'cancel':
self.worker_manager.request_cancel(params)
return {'status': 'canceled'}
elif cmd == 'worker/reset':
self.worker_manager.reset_worker(params['address'])
return {'status': 'reset'}
elif cmd == 'worker/stop':
self.worker_manager.request_stop(params['address'])
return {'status': 'stopped'}
elif cmd == 'worker/status':
self.worker_manager.update_status(params['address'], params['status'])
return {'status': 'updated'}
......@@ -256,9 +262,15 @@ class WorkerManager(object):
def update_status(self, address, status):
self.workers[address].status = status
def reset_worker(self, address):
self.workers[address].configure()
def request_stop(self):
self.broadcast('stop', {})
def request_stop(self, address=None):
if address is None:
self.broadcast('stop', {})
else:
self.workers[address].post('stop', {})
def request_cancel(self, params):
self.broadcast('cancel', params)
......
......@@ -78,8 +78,11 @@ class StatusView {
var _val = $(el).val();
solvers.push(_val);
});
console.log(solvers);
if(solvers.length == 0){
alert("At least one solver must be selected.");
return;
}
$.ajax({
type: "POST",
......@@ -208,6 +211,33 @@ class StatusView {
alert(data['message']);
});
};
var button_action_with_ajax_post = function($obj, url, param){
$obj.prop("disabled", "disabled");
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: JSON.stringify(param),
contentType: 'application/json'
}).done((data)=>{
$obj.prop("disabled", false);
alert(data['status']);
});
};
$(".btn-worker-reset").click(function(){
var param = {
"address": $(this).data('worker')
};
button_action_with_ajax_post($(this), "/api/worker/reset", param);
});
$(".btn-worker-stop").click(function(){
var param = {
"address": $(this).data('worker')
};
button_action_with_ajax_post($(this), "/api/worker/stop", param);
});
$("#adccli-login-button").click(function(){
button_action_with_ajax($(this), "/adccli-login");
......
......@@ -22,7 +22,7 @@
<div id="content-row" class="row">
<div class="col-5" id="content-left">
<h3>問題一覧</h3>&nbsp;
<span><a href="/#" id="view-server-status-button">システム状況</a></span>
<span><a href="/#" id="view-server-status-button">システム設定</a></span>
<div id="problem-list-container">
<p>Loading...</p>
</div>
......
<h3>システム状況</h3>
<h3>システム設定</h3>
<div class="summary-section">
<h4 class='inline-heading'>動作モード</h4>
......@@ -28,6 +28,7 @@
<th class="">Worker</th>
<th class="">Role</th>
<th class="">Status</th>
<th class="">Cmd</th>
</tr>
{% for k, w in workers.items() %}
<tr class="worker-status-row" data-cname="{{w.name}}">
......@@ -36,6 +37,10 @@
</td>
<td class="">{{w.role}}</td>
<td class="worker-status-value">{{w.status}}</td>
<td>
<button type="button" class="btn btn-danger btn-sm btn-worker-reset" data-worker="{{w.address}}">Reset</button>
<button type="button" class="btn btn-warning btn-sm btn-worker-stop" data-worker="{{w.address}}">Stop</button>
</td>
</tr>
{% endfor %}
</table>
......
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