Permalink
Browse files

Merge pull request #44 from jburnham/better_refresh

Change the refresh behavior for graphs.
  • Loading branch information...
2 parents a2144e7 + 181dc40 commit 58c788a0ba1f2d4c2deb11049dc3683213c3c46f @ripienaar committed Jun 29, 2012
Showing with 29 additions and 3 deletions.
  1. +13 −1 views/full_size_dashboard.erb
  2. +16 −2 views/layout.erb
@@ -1,6 +1,6 @@
<html>
<head>
- <meta http-equiv="refresh" content="60">
+ <script src="<%= @prefix %>/js/jquery-1.5.2.min.js"></script>
</head>
<% if @error %>
<h2><%= @error %></h2>
@@ -19,6 +19,18 @@
</tr>
<% end %>
</table>
+<script>
+ $(document).ready(function() {
+ setInterval(reloadDash, <%= @refresh_rate * 1000 %>);
+ });
+ function reloadDash() {
+ var now = new Date();
+ $('img').each(function(index) {
+ var url = $(this).attr('src').replace(/&\d+$/, '');
+ $(this).attr('src', url + '&' + now.getTime());
+ });
+ }
+</script>
</body>
<% end %>
</html>
View
@@ -9,7 +9,6 @@
<script src="<%= @prefix %>/js/bootstrap-dropdown.js"></script>
<script src="<%= @prefix %>/js/bootstrap-popover.js"></script>
<title><%= @dash_title %></title>
- <meta http-equiv="refresh" content="<%= @refresh_rate %>">
</head>
<body style="padding-top: 80px;">
<div class="topbar-wrapper" style="z-index: 5;">
@@ -47,7 +46,22 @@
<%= yield %>
</div>
<div class="container">
- <h6>Updated <%= Time.now %></h6>
+ <h6 id="updated"></h6>
</div>
+ <script>
+ $(document).ready(function() {
+ var now = new Date();
+ $('#updated').text('Updated ' + now.toLocaleString())
+ setInterval(reloadDash, <%= @refresh_rate * 1000 %>);
+ });
+ function reloadDash() {
+ var now = new Date();
+ $('img').each(function(index) {
+ var url = $(this).attr('src').replace(/&\d+$/, '');
+ $(this).attr('src', url + '&' + now.getTime());
+ });
+ $('#updated').text('Updated ' + now.toLocaleString())
+ }
+ </script>
</body>
</html>

0 comments on commit 58c788a

Please sign in to comment.