Skip to content

Commit

Permalink
Add option to change refresh-interval
Browse files Browse the repository at this point in the history
  • Loading branch information
harmenwassenaar committed Jul 4, 2024
1 parent fd37e7c commit 3c18420
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Unreleased
* In the case of an unexpected worker death (e.g., OOM errors) and the worker was working on an ``apply`` task, the
worker will now be restarted and the other workers will continue their work. The task that caused the death will be
set to failed (`#110`_)
* Add option on dashboard to change the refresh interval (`#136`_)

.. _#110: https://github.com/sybrenjansen/mpire/issues/110
.. _#130: https://github.com/sybrenjansen/mpire/issues/130
.. _#136: https://github.com/sybrenjansen/mpire/pull/136

2.10.2
------
Expand Down
12 changes: 10 additions & 2 deletions mpire/dashboard/static/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ $(function() {
var progress_bar_animation_duration = 450;
var refresh_interval = 500;
var completed_pb_ids = {};
var interval_id = setInterval(refresh, refresh_interval);
refresh();
setInterval(refresh, refresh_interval);


// Update progress bar given an ID and a progress (between 0-1)
function update_progress_bar(pb_id, progress)
Expand Down Expand Up @@ -122,6 +121,15 @@ function AddReadMore(tag_id, char_limit, text)
// Refresh contents
function refresh()
{
var new_refresh_interval = Math.max(100, parseInt($('#refresh_interval').val()));
if (! isNaN(new_refresh_interval) && new_refresh_interval != refresh_interval)
{
refresh_interval = new_refresh_interval;
clearInterval(interval_id);
interval_id = setInterval(refresh, refresh_interval);
$('#refresh_interval').val(refresh_interval);
}

$.getJSON($SCRIPT_ROOT + '/_progress_bar_update', {}, function(data)
{
var i, worker_id, worker_prefix, task_idx, task_prefix;
Expand Down
4 changes: 4 additions & 0 deletions mpire/dashboard/templates/menu_top_right.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div id="menu-top-right">


<label>
Refresh interval: <input type="number" id="refresh_interval" value="500" min="100" step="100" size="5"/>ms
</label>
<a href="https://slimmer-ai.github.io/mpire/" target="_blank">
<button class="btn btn-secondary">Docs</button>
</a>
Expand Down

0 comments on commit 3c18420

Please sign in to comment.