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
52f168a6
Commit
52f168a6
authored
Aug 23, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to stop/reset a worker
parent
fda45c9f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
6 deletions
+53
-6
host.py
roles/host.py
+14
-2
adc2019.js
static/js/adc2019.js
+32
-2
index.html
templates/index.html
+1
-1
part_system_summary.html
templates/part_system_summary.html
+6
-1
No files found.
roles/host.py
View file @
52f168a6
...
@@ -174,6 +174,12 @@ class Host(object):
...
@@ -174,6 +174,12 @@ class Host(object):
elif
cmd
==
'cancel'
:
elif
cmd
==
'cancel'
:
self
.
worker_manager
.
request_cancel
(
params
)
self
.
worker_manager
.
request_cancel
(
params
)
return
{
'status'
:
'canceled'
}
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'
:
elif
cmd
==
'worker/status'
:
self
.
worker_manager
.
update_status
(
params
[
'address'
],
params
[
'status'
])
self
.
worker_manager
.
update_status
(
params
[
'address'
],
params
[
'status'
])
return
{
'status'
:
'updated'
}
return
{
'status'
:
'updated'
}
...
@@ -257,8 +263,14 @@ class WorkerManager(object):
...
@@ -257,8 +263,14 @@ class WorkerManager(object):
def
update_status
(
self
,
address
,
status
):
def
update_status
(
self
,
address
,
status
):
self
.
workers
[
address
]
.
status
=
status
self
.
workers
[
address
]
.
status
=
status
def
request_stop
(
self
):
def
reset_worker
(
self
,
address
):
self
.
workers
[
address
]
.
configure
()
def
request_stop
(
self
,
address
=
None
):
if
address
is
None
:
self
.
broadcast
(
'stop'
,
{})
self
.
broadcast
(
'stop'
,
{})
else
:
self
.
workers
[
address
]
.
post
(
'stop'
,
{})
def
request_cancel
(
self
,
params
):
def
request_cancel
(
self
,
params
):
self
.
broadcast
(
'cancel'
,
params
)
self
.
broadcast
(
'cancel'
,
params
)
...
...
static/js/adc2019.js
View file @
52f168a6
...
@@ -79,7 +79,10 @@ class StatusView {
...
@@ -79,7 +79,10 @@ class StatusView {
solvers
.
push
(
_val
);
solvers
.
push
(
_val
);
});
});
console
.
log
(
solvers
);
if
(
solvers
.
length
==
0
){
alert
(
"At least one solver must be selected."
);
return
;
}
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
...
@@ -209,6 +212,33 @@ class StatusView {
...
@@ -209,6 +212,33 @@ class StatusView {
});
});
};
};
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
(){
$
(
"#adccli-login-button"
).
click
(
function
(){
button_action_with_ajax
(
$
(
this
),
"/adccli-login"
);
button_action_with_ajax
(
$
(
this
),
"/adccli-login"
);
});
});
...
...
templates/index.html
View file @
52f168a6
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
<div
id=
"content-row"
class=
"row"
>
<div
id=
"content-row"
class=
"row"
>
<div
class=
"col-5"
id=
"content-left"
>
<div
class=
"col-5"
id=
"content-left"
>
<h3>
問題一覧
</h3>
<h3>
問題一覧
</h3>
<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"
>
<div
id=
"problem-list-container"
>
<p>
Loading...
</p>
<p>
Loading...
</p>
</div>
</div>
...
...
templates/part_system_summary.html
View file @
52f168a6
<h3>
システム
状況
</h3>
<h3>
システム
設定
</h3>
<div
class=
"summary-section"
>
<div
class=
"summary-section"
>
<h4
class=
'inline-heading'
>
動作モード
</h4>
<h4
class=
'inline-heading'
>
動作モード
</h4>
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
<th
class=
""
>
Worker
</th>
<th
class=
""
>
Worker
</th>
<th
class=
""
>
Role
</th>
<th
class=
""
>
Role
</th>
<th
class=
""
>
Status
</th>
<th
class=
""
>
Status
</th>
<th
class=
""
>
Cmd
</th>
</tr>
</tr>
{% for k, w in workers.items() %}
{% for k, w in workers.items() %}
<tr
class=
"worker-status-row"
data-cname=
"{{w.name}}"
>
<tr
class=
"worker-status-row"
data-cname=
"{{w.name}}"
>
...
@@ -36,6 +37,10 @@
...
@@ -36,6 +37,10 @@
</td>
</td>
<td
class=
""
>
{{w.role}}
</td>
<td
class=
""
>
{{w.role}}
</td>
<td
class=
"worker-status-value"
>
{{w.status}}
</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>
</tr>
{% endfor %}
{% endfor %}
</table>
</table>
...
...
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