Skip to content

Commit

Permalink
Add autorefresh button to scheduling checks page (#3185)
Browse files Browse the repository at this point in the history
* Add autorefresh button to scheduling checks page

* Remove debugging prints
  • Loading branch information
willgearty committed Dec 24, 2020
1 parent 03a8c20 commit 4b2a464
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
13 changes: 12 additions & 1 deletion esp/public/media/default_styles/scheduling_checks.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,15 @@ table {
}
.alittlepspace {
padding-top: 8px;
}
}

input[name="refresh_interval"] {
width: 40px;
float: right;
margin-right: 10px;
}

button[name="refresh"] {
float: right;
margin-right: 10px;
}
34 changes: 34 additions & 0 deletions esp/public/media/scripts/program/modules/scheduling_checks.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
var auto_running = false;
var myInterval;

$j(function(){
function refreshAll() {
if (auto_running) {
$j("button.refresh-button").click();
// Allow for updating fresh interval while the refresh is already running
myInterval = setTimeout(refreshAll, $j("[name=refresh_interval]").val() * 1000);
}
}
$j("[name=refresh]").click(function() {
if (auto_running) {
auto_running = false;
// Change button class and text
$j(this).addClass("btn-success");
$j(this).removeClass("btn-danger");
$j(this).html("Start Auto Refresh");

// Stop autorefreshing
clearTimeout(myInterval);
} else {
auto_running = true;
// Change button class and text
$j(this).addClass("btn-danger");
$j(this).removeClass("btn-success");
$j(this).html("Stop Auto Refresh");

// Start autorefreshing
refreshAll()
}
});
});

/**
* List of scheduling checks.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h1>Schedule Diagnostic Output for {{program.niceName}} </h1>
<p>Clicking "Include unreviewed classes" will show all classes in the diagnostic.</p>
<br></div>
<a class="btn move_left" href="scheduling_checks{% if unreviewed %}">Exclude{% else %}?unreviewed">Include{% endif %} unreviewed classes</a>
<button class="btn btn-success" name="refresh">Start Auto Refresh</button><input type="number" min="5" name="refresh_interval" title="(Refresh interval in seconds)" value=30>

<div id="scheduling-check-wrapper" />
<script type="text/jsx">
Expand Down

0 comments on commit 4b2a464

Please sign in to comment.