Project

General

Profile

Refactor #288 ยป 0001-Fixes-288-Moved-DashboardController-actions-except-f.patch

Proposed patch - Jochen Schalanda, 11/02/2010 02:00 PM

View differences:

app/controllers/dashboard_controller.rb
def index
end
def errors
show_hosts Host.recent.with_error, "Hosts with errors"
end
def active
show_hosts Host.recent.with_changes, "Active Hosts"
end
def OutOfSync
show_hosts Host.out_of_sync, "Hosts which didn't run puppet in the last #{SETTINGS[:puppet_interval]} minutes"
end
def disabled
show_hosts Host.alerts_disabled, "Hosts with notifications disabled"
end
private
def graphs
......
# the run interval to show in the dashboard graph
end
def show_hosts list, title
@search = list.search(params[:search])
respond_to do |format|
format.html do
hosts = @search.paginate :page => params[:page]
@last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => hosts})
render "hosts/_minilist", :locals => {:hosts => hosts, :header => title}
end
format.yml { render :text => @search.map(&:name).to_yaml }
end
end
end
app/controllers/hosts_controller.rb
render :nothing => true
end
def errors
show_hosts Host.recent.with_error, "Hosts with errors"
end
def active
show_hosts Host.recent.with_changes, "Active Hosts"
end
def out_of_sync
show_hosts Host.out_of_sync, "Hosts which didn't run puppet in the last #{SETTINGS[:puppet_interval]} minutes"
end
def disabled
show_hosts Host.alerts_disabled, "Hosts with notifications disabled"
end
private
def find_hosts
fact, klass, group = params[:fact], params[:class], params[:hostgroup]
......
end
end
def show_hosts list, title
@search = list.search(params[:search])
respond_to do |format|
format.html do
hosts = @search.paginate :page => params[:page]
@last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => hosts})
render "hosts/_minilist", :locals => {:hosts => hosts, :header => title}
end
format.yaml { render :text => @search.map(&:name).to_yaml }
format.json { render :json => @search.map(&:name).to_json }
end
end
end
app/views/dashboard/index.html.erb
<p>Generated at <%= Time.now.to_s(:short) %></p>
<p>Good Host Reports in the last <%= SETTINGS[:puppet_interval] %> minutes <%= "#{@good_hosts} / #{@total_hosts}" %> hosts (<%=@percentage%>%) </p>
<h1>Summary</h1>
<p>Hosts that had performed modifications <%= link_to @active_hosts, :action => "active" %></p>
<p>Out Of Sync Hosts <%= link_to @out_of_sync_hosts, :action => "OutOfSync" %></p>
<p>Hosts in Error State <%= link_to @bad_hosts, :action => "errors" %></p>
<p>Hosts With Alerts Disabled <%= link_to @disabled_hosts, :action => "disabled" %></p>
<p>Hosts that had performed modifications <%= link_to @active_hosts, :controller => "hosts", :action => "active" %></p>
<p>Out Of Sync Hosts <%= link_to @out_of_sync_hosts, :controller => "hosts", :action => "out_of_sync" %></p>
<p>Hosts in Error State <%= link_to @bad_hosts, :controller => "hosts", :action => "errors" %></p>
<p>Hosts With Alerts Disabled <%= link_to @disabled_hosts, :controller => "hosts", :action => "disabled" %></p>
<div id='overview'></div>
<%= @overview.render('overview') %>
config/routes.rb
map.resources :reports
map.connect "node/:name", :controller => 'hosts', :action => 'externalNodes',
:requirements => { :name => /[^\.][\w\.-]+/ }
map.connect "/hosts/query", :controller => 'hosts', :action => 'query'
map.with_options :controller => 'hosts' do |hosts|
hosts.connect 'hosts/query', :action => 'query'
hosts.connect 'hosts/active', :action => 'active'
hosts.connect 'hosts/out_of_sync', :action => 'out_of_sync'
hosts.connect 'hosts/errors', :action => 'errors'
hosts.connect 'hosts/disabled', :action => 'disabled'
end
map.resources :hosts,
:requirements => {:id => /[^\/]+/},
:member => { :report => :get, :reports => :get, :clone => :get,
    (1-1/1)