Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autorefresh in Dashboard using ActiveAdmin

I'm developing an application in Rails wich acts as a network and apps monitor. I'm using Active Admin Dashboard as a main page, showing the status of every server and some apps in my network. I'd like to configure the dashboard page to autorefresh every x minutes, but I don't know where to configure this setting, because I don't have full control of the html rendered by the dashboard. Have anyone managed to do it?

Thanks

like image 356
Toni Grimalt Avatar asked Jun 12 '12 16:06

Toni Grimalt


1 Answers

In config/initializers/active_admin.rb you can register javascripts:

config.register_javascript "/javascripts/admin-auto-refresh.js"

Then create a admin-auto-refresh.js that does exactly that.

You'll also want to register admin-auto-refresh.js in your config/environments/production.rb

config.assets.precompile += "admin-auto-refresh.js"

UPDATE:

Added some code to refresh the page after 5 seconds. Add this to /javascripts/admin-auto-refresh.js

$(function() {
  setTimeout(location.reload(true), 5000);
})
like image 120
Jesse Wolgamott Avatar answered Sep 28 '22 10:09

Jesse Wolgamott