Commit 9d989358 authored by Kento HASEGAWA's avatar Kento HASEGAWA

Improve the problem status view

parent dda8b6a6
......@@ -61,11 +61,28 @@ def webui_part_problem_status(name=None):
if (adc2019system.role is not None) and (adc2019system.role.type == 'host'):
problem = adc2019system.role.get_problem(name)
workers = adc2019system.role.get_workers()
# solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp))
if problem is None:
return abort(404)
else:
# return render_template('part_problem_status.html', problem=problem, workers=workers, solutions=solutions)
return render_template('part_problem_status.html', problem=problem, workers=workers)
else:
return abort(404)
@webui.route('/part/problem_solution/<name>')
def webui_part_solution_status(name=None):
if name is None:
return abort(404)
if (adc2019system.role is not None) and (adc2019system.role.type == 'host'):
problem = adc2019system.role.get_problem(name)
solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp))
if problem is None:
return abort(404)
else:
return render_template('part_problem_status.html', problem=problem, workers=workers, solutions=solutions)
return render_template('part_solution_status.html', problem=problem, solutions=solutions)
else:
return abort(404)
......
......@@ -41,13 +41,6 @@ class StatusView {
_this.fire('refresh');
});
_this.container.find('.solution-detail-row.valid-solution td').click((e) => {
var solution_id = $(e.target).parent("tr").data("solution-id");
var problem_name = $(e.target).parent("tr").data("problem");
var viewer_url = "/viewer#" + problem_name + "/" + solution_id;
window.open(viewer_url, "_blank");
});
_this.container.find('#chk-solver-all').prop('checked', false);
_this.container.find('#chk-solver-all').on('change', (e) => {
......@@ -64,7 +57,7 @@ class StatusView {
}).trigger('change');
_this.request_refresh_timer = setInterval((function _t(){
_this.get_request_status();
_this.update_status_view();
return _t;
}()), 1000);
});
......@@ -97,24 +90,6 @@ class StatusView {
contentType: 'application/json'
}).done((d) => {
console.log(d);
// var request_id = d['request_id'];
// var timeout = d['timeout'];
// _this.container.find('#solver-processing-modal').modal({
// backdrop: 'static',
// keyboard: false,
// show: true
// });
// _this.container.find('#solver-processing-modal').on('hidden.bs.modal', function(e){
// clearInterval(_this.request_refresh_timer);
// _this.show_problem();
// _this.fire('refresh');
// })
// _this.container.find('.stop-button').click(()=>{
// _this.stop_solver();
// });
});
}
......@@ -170,7 +145,7 @@ class StatusView {
});
}
get_request_status(){
update_status_view(){
var _this = this;
$.ajax({
type: 'GET',
......@@ -180,6 +155,24 @@ class StatusView {
_this.container.find('#request-table-container').empty();
_this.container.find('#request-table-container').html(d);
});
$.ajax({
type: 'GET',
dataType: 'html',
url: '/part/problem_solution/' + _this.problem_key
}).done((d) => {
_this.container.find('#solution-table-container').empty();
_this.container.find('#solution-table-container').html(d);
_this.container.find('.solution-detail-row.valid-solution td').click((e) => {
var solution_id = $(e.target).parent("tr").data("solution-id");
var problem_name = $(e.target).parent("tr").data("problem");
var viewer_url = "/viewer#" + problem_name + "/" + solution_id;
window.open(viewer_url, "_blank");
});
_this.fire('refresh');
});
}
// システム詳細画面を表示
......
......@@ -56,33 +56,9 @@
<div id='solution-list-container'>
<h4>処理結果一覧</h4>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Timestamp</th>
<th>Client</th>
<th>Score</th>
</tr>
</thead>
<tbody>
{% for k, v in solutions %}
{% set tr_class = '' %}
{% set tr_class = tr_class + ' submit-solution' if k == problem.best_solution else '' %}
{% set tr_class = tr_class + ' valid-solution' if v.is_valid_solution() else '' %}
<tr class="solution-detail-row {{tr_class}}" data-solution-id="{{k}}" data-problem="{{problem.name}}">
<td>{{v.timestamp_str}}</td>
<td>{{v.worker}}</td>
<td>
{% if v.is_valid_solution() %}
{{v.score}} ({{v.size_str}})
{% else %}
{{v.status}}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div id="solution-table-container">
</div>
</div>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Timestamp</th>
<th>Client</th>
<th>Score</th>
</tr>
</thead>
<tbody>
{% for k, v in solutions %}
{% set tr_class = '' %}
{% set tr_class = tr_class + ' submit-solution' if k == problem.best_solution else '' %}
{% set tr_class = tr_class + ' valid-solution' if v.is_valid_solution() else '' %}
<tr class="solution-detail-row {{tr_class}}" data-solution-id="{{k}}" data-problem="{{problem.name}}">
<td>{{v.timestamp_str}}</td>
<td>{{v.worker}}</td>
<td>
{% if v.is_valid_solution() %}
{{v.score}} ({{v.size_str}})
{% else %}
{{v.status}}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
......@@ -31,7 +31,7 @@ class Problem(object):
self._load_problem(problem_path)
if not self.solution_path is None:
solution_files = glob.glob(f'{self.solution_path}/{self.name}/*.json')
solution_files = glob.glob(f'{self.solution_path}/{self.name}/tmp-*.json')
for v in solution_files:
solution = Solution(solution_file=v)
solution_id = solution.get_id()
......@@ -364,7 +364,7 @@ class Problem(object):
outdir = f"{self.solution_path}/{self.name}"
if not os.path.exists(outdir):
os.mkdir(outdir)
outpath = f"{outdir}/{data['request_id']}-{data['worker']}-p{data['part_id']}.json".replace(":", ".")
outpath = f"{outdir}/part-{data['request_id']}-{data['worker']}-p{data['part_id']}.json".replace(":", ".")
with open(outpath, 'w') as fp:
json.dump(self.get_dict(), fp, indent=4)
......@@ -540,7 +540,7 @@ class Solution(object):
outdir = f"{basedir}/{self.problem}"
if not os.path.exists(outdir):
os.mkdir(outdir)
outpath = f"{outdir}/{self.request_id}-{self.worker}.json".replace(":", ".")
outpath = f"{outdir}/tmp-{self.request_id}-{self.worker}.json".replace(":", ".")
with open(outpath, 'w') as fp:
json.dump(self.get_dict(), fp, indent=4)
......
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