You need to sign in or sign up before continuing.
Commit b2044029 authored by Kento HASEGAWA's avatar Kento HASEGAWA

Improve the request status display in the problem view

parent aa7af10d
...@@ -44,12 +44,9 @@ def webui_part_solver_status(): ...@@ -44,12 +44,9 @@ def webui_part_solver_status():
else: else:
return abort(404) return abort(404)
# @webui.route('/part/request/<request_id>')
@webui.route('/part/request/<problem_name>') @webui.route('/part/request/<problem_name>')
# def webui_part_request_status(request_id=None):
def webui_part_request_status(problem_name=None): def webui_part_request_status(problem_name=None):
if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): if (adc2019system.role is not None) and (adc2019system.role.type == 'host'):
# request_status = adc2019system.role.get_request_status(float(request_id))
request_status = adc2019system.role.get_request_by_problem(problem_name) request_status = adc2019system.role.get_request_by_problem(problem_name)
return render_template('part_request_status.html', status=request_status) return render_template('part_request_status.html', status=request_status)
else: else:
...@@ -64,7 +61,7 @@ def webui_part_problem_status(name=None): ...@@ -64,7 +61,7 @@ def webui_part_problem_status(name=None):
if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): if (adc2019system.role is not None) and (adc2019system.role.type == 'host'):
problem = adc2019system.role.get_problem(name) problem = adc2019system.role.get_problem(name)
workers = adc2019system.role.get_workers() workers = adc2019system.role.get_workers()
solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[0])) solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp))
if problem is None: if problem is None:
return abort(404) return abort(404)
else: else:
......
...@@ -354,6 +354,8 @@ class Request(object): ...@@ -354,6 +354,8 @@ class Request(object):
self.solvers = solvers self.solvers = solvers
self.response = dict() self.response = dict()
for w in self.solvers:
self.response[w] = list()
@property @property
def request_data(self): def request_data(self):
...@@ -370,7 +372,8 @@ class Request(object): ...@@ -370,7 +372,8 @@ class Request(object):
def store_response(self, data): def store_response(self, data):
worker = data['worker'] worker = data['worker']
self.response[worker] = data self.response[worker].append(data)
# self.response[worker] = data
def get_status(self): def get_status(self):
worker_count = 0 worker_count = 0
...@@ -401,8 +404,8 @@ class Request(object): ...@@ -401,8 +404,8 @@ class Request(object):
worker_status = dict() worker_status = dict()
for v in self.solvers: for v in self.solvers:
if v in self.response: if v in self.response and len(self.response[v]) > 0:
worker_status[v] = self.response[v]['status'] worker_status[v] = self.response[v][0]['status']
else: else:
if self.worker_manager.workers[v].status == 'Not connected': if self.worker_manager.workers[v].status == 'Not connected':
worker_status[v] = 'Not connected' worker_status[v] = 'Not connected'
......
...@@ -63,10 +63,10 @@ class StatusView { ...@@ -63,10 +63,10 @@ class StatusView {
} }
}).trigger('change'); }).trigger('change');
// _this.solver_status_refresh_timer = setInterval((function _t(){ _this.request_refresh_timer = setInterval((function _t(){
// _this.refresh_solver_status(); _this.get_request_status();
// return _t; return _t;
// }()), 1000); }()), 1000);
}); });
} }
...@@ -114,11 +114,6 @@ class StatusView { ...@@ -114,11 +114,6 @@ class StatusView {
// _this.stop_solver(); // _this.stop_solver();
// }); // });
_this.request_refresh_timer = setInterval((function _t(){
// _this.get_request_status(request_id);
_this.get_request_status();
return _t;
}()), 1000);
}); });
} }
...@@ -174,22 +169,6 @@ class StatusView { ...@@ -174,22 +169,6 @@ class StatusView {
}); });
} }
// get_request_status(request_id){
// var _this = this;
// $.ajax({
// type: 'GET',
// dataType: 'html',
// url: '/part/request/' + request_id
// }).done((d) => {
// _this.container.find('#request-status-container').empty();
// _this.container.find('#request-status-container').html(d);
// status = $(d).find('#request-status-value').text();
// if(status == 'done'){
// clearInterval(_this.request_refresh_timer);
// }
// });
// }
get_request_status(){ get_request_status(){
var _this = this; var _this = this;
$.ajax({ $.ajax({
...@@ -199,13 +178,6 @@ class StatusView { ...@@ -199,13 +178,6 @@ class StatusView {
}).done((d) => { }).done((d) => {
_this.container.find('#request-table-container').empty(); _this.container.find('#request-table-container').empty();
_this.container.find('#request-table-container').html(d); _this.container.find('#request-table-container').html(d);
// status = $(d).find('#request-status-value').text();
// if(status == 'done'){
// clearInterval(_this.request_refresh_timer);
// }
// _this.fire('refresh');
}); });
} }
......
...@@ -86,23 +86,3 @@ ...@@ -86,23 +86,3 @@
</div> </div>
</div> </div>
<div class="modal fade" id="solver-processing-modal" tabindex="-1" role="dialog" aria-labelledby="solver-processing-modal-title" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="solver-processing-modal-title">{{problem.name}}</h5>
<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button> -->
</div>
<div class="modal-body" id="request-status-container">
処理中...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger stop-button">Stop</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
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