Skip to content
Browse files

Add refresh_time parameter to allow page to meta-refresh at a specifi…

…ed rate (useful for session monitors, etc)
  • Loading branch information...
1 parent 265ac06 commit 391062d552d0d04c87176b1bfe26686cb58c1657 @ijcd ijcd committed with Jan 15, 2009
Showing with 9 additions and 0 deletions.
  1. +4 −0 README
  2. +3 −0 lib/auto_admin_configuration.rb
  3. +1 −0 lib/auto_admin_controller.rb
  4. +1 −0 themes/django/views/layouts/layout.html.erb
View
4 README
@@ -18,6 +18,7 @@ Streamlined[http://streamlined.relevancellc.com/].
def name; first_name + ' ' + last_name; end
+ refresh_time 5
sort_by :last_name
search_by :first_name, :last_name
filter_by :active, :store
@@ -178,6 +179,9 @@ methods:
interface. Currently, this is used to group together related objects on the
index page.
+[refresh_time(seconds)]
+ Instructs the list view to meta-refresh with the specified delay.
+
[sort_by(column, reverse=false)]
Instructs the list view to sort on the specified column by default.
View
3 lib/auto_admin_configuration.rb
@@ -185,6 +185,9 @@ def default_columns_for_list
columns
end
+ # Instructs the list view to meta-refresh this often
+ def refresh_time time=nil; if defined?(@refresh_time) ; then @refresh_time else @refresh_time = time ; end ; end
+
# Instructs the list view to sort on the specified column by default.
def sort_by column, reverse=false; @sort_column = column.to_s; @sort_reverse = reverse; end
View
1 lib/auto_admin_controller.rb
@@ -117,6 +117,7 @@ def collect_associations_for_model
def list
params[:filter] ||= {}
params[:filter] = model.filter_defaults.merge(params[:filter])
+ @auto_admin_refresh_time = model.refresh_time
conditions = model.filter_conditions( params[:filter] )
unless sort_column = model.find_column( params[:sort] )
sort_column = model.find_column( params[:sort] = model.sort_column )
View
1 themes/django/views/layouts/layout.html.erb
@@ -5,6 +5,7 @@
<title><%=h @title ? "#{@title} | " : '' %><%=h site.name %></title>
<%= tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => url_for( :action => 'asset', :path => 'stylesheets/auto_admin.css', :escape => false ) } ) %>
<%= javascript_include_tag :defaults %>
+ <%= tag("meta", { "http-equiv" => "refresh", "content" => @auto_admin_refresh_time } ) if @auto_admin_refresh_time %>
</head>
<body class="<%=h @body_class %>">

0 comments on commit 391062d

Please sign in to comment.
Something went wrong with that request. Please try again.