Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2019-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
adc2019
adc2019-system
Commits
fa1216cf
Commit
fa1216cf
authored
Jul 25, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve displaying status
parent
e7a02e9a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
29 deletions
+88
-29
adc2019.js
static/js/adc2019.js
+50
-19
part_problem_status.html
templates/part_problem_status.html
+5
-5
part_problems.html
templates/part_problems.html
+1
-1
data.py
utils/data.py
+32
-4
No files found.
static/js/adc2019.js
View file @
fa1216cf
...
@@ -6,6 +6,8 @@ class StatusView {
...
@@ -6,6 +6,8 @@ class StatusView {
this
.
container
=
$
(
selector
);
this
.
container
=
$
(
selector
);
this
.
problem_key
=
null
;
this
.
problem_key
=
null
;
this
.
request_refresh_timer
=
null
;
this
.
request_refresh_timer
=
null
;
this
.
event
=
Object
();
}
}
// 問題詳細画面を表示
// 問題詳細画面を表示
...
@@ -29,6 +31,7 @@ class StatusView {
...
@@ -29,6 +31,7 @@ class StatusView {
_this
.
container
.
find
(
'.save-button'
).
click
(()
=>
{
_this
.
container
.
find
(
'.save-button'
).
click
(()
=>
{
_this
.
save_solution
();
_this
.
save_solution
();
_this
.
fire
(
'refresh'
);
});
});
_this
.
container
.
find
(
'.solution-detail-row td'
).
click
((
e
)
=>
{
_this
.
container
.
find
(
'.solution-detail-row td'
).
click
((
e
)
=>
{
...
@@ -62,8 +65,8 @@ class StatusView {
...
@@ -62,8 +65,8 @@ class StatusView {
show
:
true
show
:
true
});
});
_this
.
container
.
find
(
'#solver-processing-modal'
).
on
(
'hidden.bs.modal'
,
function
(
e
){
_this
.
container
.
find
(
'#solver-processing-modal'
).
on
(
'hidden.bs.modal'
,
function
(
e
){
// console.log(e);
_this
.
show_problem
();
_this
.
show_problem
();
_this
.
fire
(
'refresh'
);
})
})
_this
.
container
.
find
(
'.stop-button'
).
click
(()
=>
{
_this
.
container
.
find
(
'.stop-button'
).
click
(()
=>
{
...
@@ -174,37 +177,66 @@ class StatusView {
...
@@ -174,37 +177,66 @@ class StatusView {
});
});
}
}
// イベントの追加
on
(
key
,
func
){
if
(
!
this
.
event
.
hasOwnProperty
(
key
)){
this
.
event
[
key
]
=
Array
();
}
this
.
event
[
key
].
push
(
func
);
}
// イベントの発火
fire
(
key
){
if
(
this
.
event
.
hasOwnProperty
(
key
)){
for
(
var
i
=
0
;
i
<
this
.
event
[
key
].
length
;
i
++
){
this
.
event
[
key
][
i
]();
}
}
}
}
}
$
(
function
(){
// 問題一覧画面
class
ProblemListView
{
const
status_view
=
new
StatusView
(
'#status-container'
);
constructor
(
selector
)
{
this
.
container
=
$
(
selector
);
}
refresh
(){
var
_this
=
this
;
var
refresh_problems
=
function
(){
$
.
ajax
({
$
.
ajax
({
type
:
"GET"
,
type
:
"GET"
,
dataType
:
"html"
,
dataType
:
"html"
,
url
:
"/part/problems"
url
:
"/part/problems"
}).
done
((
d
)
=>
{
}).
done
((
d
)
=>
{
$
(
"#problem-list-container"
).
empty
();
_this
.
container
.
empty
();
$
(
"#problem-list-container"
).
html
(
d
);
_this
.
container
.
html
(
d
);
$
(
".problem-row td"
).
click
(
function
(){
var
$tr
=
$
(
this
).
parent
(
"tr.problem-row"
);
$
(
".problem-row"
).
removeClass
(
"q-selected"
);
$tr
.
addClass
(
"q-selected"
);
var
qname
=
$tr
.
data
(
"qname"
);
// show_problem_status(qname);
location
.
hash
=
"#"
+
qname
;
return
false
;
});
var
hash
=
location
.
hash
.
replace
(
"#"
,
""
);
var
hash
=
location
.
hash
.
replace
(
"#"
,
""
);
if
(
hash
!=
""
){
if
(
hash
!=
""
){
$
(
".problem-row[data-qname
='"
+
hash
+
"']"
).
addClass
(
"q-selected"
);
_this
.
container
.
find
(
".problem-row[data-problem
='"
+
hash
+
"']"
).
addClass
(
"q-selected"
);
}
}
_this
.
container
.
find
(
".problem-row td"
).
click
((
e
)
=>
{
var
$tr
=
$
(
e
.
target
).
parent
(
"tr.problem-row"
);
_this
.
container
.
find
(
".problem-row"
).
removeClass
(
"q-selected"
);
$tr
.
addClass
(
"q-selected"
);
var
problem_key
=
$tr
.
data
(
"problem"
);
location
.
hash
=
"#"
+
problem_key
;
});
});
});
}
}
}
$
(
function
(){
const
status_view
=
new
StatusView
(
'#status-container'
);
const
problem_list_view
=
new
ProblemListView
(
'#problem-list-container'
);
status_view
.
on
(
'refresh'
,
()
=>
{
problem_list_view
.
refresh
()});
$
(
window
).
on
(
'hashchange'
,
function
(){
$
(
window
).
on
(
'hashchange'
,
function
(){
var
hash
=
location
.
hash
.
replace
(
"#"
,
""
);
var
hash
=
location
.
hash
.
replace
(
"#"
,
""
);
...
@@ -213,9 +245,8 @@ $(function(){
...
@@ -213,9 +245,8 @@ $(function(){
}
else
{
}
else
{
status_view
.
show_problem
(
hash
);
status_view
.
show_problem
(
hash
);
}
}
problem_list_view
.
refresh
();
}).
trigger
(
'hashchange'
);
}).
trigger
(
'hashchange'
);
refresh_problems
();
});
});
templates/part_problem_status.html
View file @
fa1216cf
...
@@ -30,11 +30,11 @@
...
@@ -30,11 +30,11 @@
<td>
{{v.timestamp_str}}
</td>
<td>
{{v.timestamp_str}}
</td>
<td>
{{v.worker}}
</td>
<td>
{{v.worker}}
</td>
<td>
<td>
{
#% if v.nlcheck == -1 %#
}
{
% if v.is_valid_solution() %
}
<!-- Not solved -->
{{v.score}} ({{v.size_str}})
{
#% else %#
}
{
% else %
}
{
#{v.nlcheck}#
}
{
{v.status}
}
{
#% endif %#
}
{
% endif %
}
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
...
templates/part_problems.html
View file @
fa1216cf
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
</thead>
</thead>
<tbody>
<tbody>
{% for k, v in problems.items() %}
{% for k, v in problems.items() %}
<tr
class=
"problem-row"
data-
qname
=
"{{v.name}}"
>
<tr
class=
"problem-row"
data-
problem
=
"{{v.name}}"
>
<td
class=
"large-cell"
>
{{v.name}}
</td>
<td
class=
"large-cell"
>
{{v.name}}
</td>
<td
class=
"small-cell"
>
{{v.size_str}}
</td>
<td
class=
"small-cell"
>
{{v.size_str}}
</td>
<td
class=
"small-cell"
>
{{v.block_num}}
</td>
<td
class=
"small-cell"
>
{{v.block_num}}
</td>
...
...
utils/data.py
View file @
fa1216cf
...
@@ -15,7 +15,7 @@ class Problem(object):
...
@@ -15,7 +15,7 @@ class Problem(object):
self
.
block_num
=
0
self
.
block_num
=
0
self
.
blocks
=
dict
()
self
.
blocks
=
dict
()
self
.
problem
=
''
self
.
problem
=
''
self
.
status
=
'Ready'
#
self.status = 'Ready'
self
.
solutions
=
dict
()
self
.
solutions
=
dict
()
self
.
solution_path
=
solution_path
self
.
solution_path
=
solution_path
self
.
best_solution
=
None
self
.
best_solution
=
None
...
@@ -25,6 +25,27 @@ class Problem(object):
...
@@ -25,6 +25,27 @@ class Problem(object):
@
property
@
property
def
size_str
(
self
):
def
size_str
(
self
):
return
f
'{self.size[0]}X{self.size[1]}'
return
f
'{self.size[0]}X{self.size[1]}'
@
property
def
status
(
self
):
_status
=
'None'
if
self
.
problem
!=
''
:
_status
=
'Ready'
if
len
(
self
.
solutions
)
>
0
:
_solved_count
=
0
_trial_count
=
0
for
k
,
v
in
self
.
solutions
.
items
():
_trial_count
+=
1
if
v
.
is_valid_solution
():
_solved_count
+=
1
if
_solved_count
>
0
:
_status
=
f
'Solved ({_solved_count}/{_trial_count})'
else
:
_status
=
f
'Tried ({_trial_count})'
if
not
self
.
best_solution
is
None
:
_status
=
f
'Saved'
return
_status
def
_load_problem
(
self
,
path
):
def
_load_problem
(
self
,
path
):
...
@@ -77,7 +98,7 @@ class Problem(object):
...
@@ -77,7 +98,7 @@ class Problem(object):
self
.
blocks
=
blocks
self
.
blocks
=
blocks
self
.
name
=
name
self
.
name
=
name
self
.
problem
=
q_text
self
.
problem
=
q_text
self
.
status
=
'Ready'
#
self.status = 'Ready'
def
get_dict
(
self
):
def
get_dict
(
self
):
return
{
return
{
...
@@ -86,7 +107,7 @@ class Problem(object):
...
@@ -86,7 +107,7 @@ class Problem(object):
'size_str'
:
self
.
size_str
,
'size_str'
:
self
.
size_str
,
'block_num'
:
self
.
block_num
,
'block_num'
:
self
.
block_num
,
'problem'
:
self
.
problem
,
'problem'
:
self
.
problem
,
'status'
:
self
.
status
#
'status': self.status
}
}
def
get_d3json
(
self
):
def
get_d3json
(
self
):
...
@@ -213,10 +234,17 @@ class Solution(object):
...
@@ -213,10 +234,17 @@ class Solution(object):
@
property
@
property
def
score
(
self
):
def
score
(
self
):
if
(
len
(
self
.
size
)
==
2
)
and
(
self
.
size
[
0
]
is
not
None
)
and
(
self
.
size
[
1
]
is
not
None
):
if
self
.
is_valid_solution
(
):
return
self
.
size
[
0
]
*
self
.
size
[
1
]
return
self
.
size
[
0
]
*
self
.
size
[
1
]
else
:
else
:
return
None
return
None
@
property
def
size_str
(
self
):
if
self
.
is_valid_solution
():
return
f
'{self.size[0]}X{self.size[1]}'
else
:
return
'-'
def
is_valid_solution
(
self
):
def
is_valid_solution
(
self
):
return
self
.
status
==
'done'
return
self
.
status
==
'done'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment