Please review pull request #96: Autorefresh feature added opened by (dabooze)
Description:
Added a small link to the global nav. You can enable/disable a 5-sec autorefresh of the GUI. Useful for constant monitoring of the overall status.
The autorefresh enable/disable link works on every page of the dashboard.
This should cover feature request #4096.
- Opened: Thu May 03 07:45:45 UTC 2012
- Based on: puppetlabs:master (536fd2337d89300ece8e688909dfc862c4c0de41)
- Requested merge: dabooze:master (0557beac826d55dbeee2cb6836e54a3fbd7789c2)
Diff follows:
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index c4c61d1..71d67ee 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -12,9 +12,20 @@ class ApplicationController < ActionController::Base
filter_parameter_logging :password
before_filter :set_timezone
+ before_filter :set_autorefresh
private
+ def set_autorefresh
+ if params[:autorefresh]
+ if params[:autorefresh] == "true"
+ session[:autorefresh] = true
+ else
+ session.delete(:autorefresh)
+ end
+ end
+ end
+
def raise_if_enable_read_only_mode
raise ReadOnlyEnabledError.new if SETTINGS.enable_read_only_mode || session['ACCESS_CONTROL_ROLE'] == 'READ_ONLY'
end
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 6b8e61b..71e2c63 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -5,6 +5,8 @@
%title= [ page_title, 'Puppet Node Manager'].compact.join(' - ')
%link{ :href ="" image_path("favicon.ico"), :rel => "shortcut icon" }
%meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }
+ - if session[:autorefresh]
+ %meta{ :content => "5; URL="" "http-equiv" => "refresh" }
= _javascript__include_tag 'jquery.min'
:_javascript_
diff --git a/app/views/shared/_global_nav.html.haml b/app/views/shared/_global_nav.html.haml
index 9dfdd10..b45f812 100644
--- a/app/views/shared/_global_nav.html.haml
+++ b/app/views/shared/_global_nav.html.haml
@@ -30,3 +30,5 @@
= callback.call self
- Registry.each_callback :core, :account_widgets do |callback|
= callback.call self
+ %li#navigation-autorefresh
+ = link_to "#{session[:autorefresh] ? "Disable autorefresh" : "Enable autorefresh"}", "#{request.path}?autorefresh=#{session[:autorefresh] ? "false" : "true"}", :class => "autorefresh_link"
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 61c5ca0..ec6e891 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -631,3 +631,5 @@ body {
background-image: url("../images/icons/delayed-job-failure.png"); }
body .delayed-job p.warning em {
background-image: url("../images/icons/delayed-job-warning.png"); }
+ a.autorefresh_link {
+ color: #aaa; }
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
