diff options
| -rw-r--r-- | app/assets/javascripts/events.coffee | 8 | ||||
| -rw-r--r-- | app/views/agents/events/index.html.erb | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/app/assets/javascripts/events.coffee b/app/assets/javascripts/events.coffee index 24f83d1..e72d214 100644 --- a/app/assets/javascripts/events.coffee +++ b/app/assets/javascripts/events.coffee @@ -1,3 +1,11 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ + +class window.EventsFeed + start: (pollingInterval, refreshLink)-> + window.setTimeout (-> + console.log('refreshing...') + $("#{refreshLink}")[0].click() + return + ), pollingInterval diff --git a/app/views/agents/events/index.html.erb b/app/views/agents/events/index.html.erb index 6b56b40..d0c9fd0 100644 --- a/app/views/agents/events/index.html.erb +++ b/app/views/agents/events/index.html.erb @@ -4,6 +4,7 @@ <h1>Listing Events for agent <%= @agent.hostname %></h1> <%= link_to 'New Event', new_agent_event_path(@agent), class: 'button' %> + <%= link_to "refresh", params, id: 'refresh_page_link', style: 'display:none;' %> <table> <thead> @@ -13,7 +14,6 @@ <th width="210">Created At</th> </tr> </thead> - <tbody> <% @events.each do |event| %> <tr> @@ -42,3 +42,9 @@ <%= pie_chart @agent.events.group(:name).count %> </div> </div> + +<script type="text/javascript" charset="utf-8"> +$(function(){ + new window.EventsFeed().start(1000, '#refresh_page_link'); +}); +</script> |
