Project

General

Profile

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
6 6
  def index
7 7
  end
8 8

  
9
  def errors
10
    show_hosts Host.recent.with_error, "Hosts with errors"
11
  end
12

  
13
  def active
14
    show_hosts Host.recent.with_changes, "Active Hosts"
15
  end
16

  
17
  def OutOfSync
18
    show_hosts Host.out_of_sync, "Hosts which didn't run puppet in the last #{SETTINGS[:puppet_interval]} minutes"
19
  end
20

  
21
  def disabled
22
    show_hosts Host.alerts_disabled, "Hosts with notifications disabled"
23
  end
24

  
25 9
  private
26 10
  def graphs
27 11

  
......
60 44
    # the run interval to show in the dashboard graph
61 45
  end
62 46

  
63
  def show_hosts list, title
64
    @search = list.search(params[:search])
65
    respond_to do |format|
66
      format.html do
67
        hosts = @search.paginate :page => params[:page]
68
        @last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => hosts})
69
        render "hosts/_minilist", :locals => {:hosts => hosts, :header => title}
70
      end
71
      format.yml { render :text => @search.map(&:name).to_yaml }
72
    end
73
  end
74

  
75 47
end
app/controllers/hosts_controller.rb
373 373
    render :nothing => true
374 374
  end
375 375

  
376
  def errors
377
    show_hosts Host.recent.with_error, "Hosts with errors"
378
  end
379

  
380
  def active
381
    show_hosts Host.recent.with_changes, "Active Hosts"
382
  end
383

  
384
  def out_of_sync
385
    show_hosts Host.out_of_sync, "Hosts which didn't run puppet in the last #{SETTINGS[:puppet_interval]} minutes"
386
  end
387

  
388
  def disabled
389
    show_hosts Host.alerts_disabled, "Hosts with notifications disabled"
390
  end
391

  
376 392
  private
377 393
  def find_hosts
378 394
    fact, klass, group = params[:fact], params[:class], params[:hostgroup]
......
471 487
    end
472 488
  end
473 489

  
490
  def show_hosts list, title
491
    @search = list.search(params[:search])
492
    respond_to do |format|
493
      format.html do
494
        hosts = @search.paginate :page => params[:page]
495
        @last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => hosts})
496
        render "hosts/_minilist", :locals => {:hosts => hosts, :header => title}
497
      end
498
      format.yaml { render :text => @search.map(&:name).to_yaml }
499
      format.json { render :json => @search.map(&:name).to_json }
500
    end
501
  end
502

  
474 503
end
app/views/dashboard/index.html.erb
4 4
  <p>Generated at <%= Time.now.to_s(:short) %></p>
5 5
  <p>Good Host Reports in the last <%= SETTINGS[:puppet_interval] %> minutes <%= "#{@good_hosts} / #{@total_hosts}" %> hosts (<%=@percentage%>%) </p>
6 6
  <h1>Summary</h1>
7
  <p>Hosts that had performed modifications <%= link_to @active_hosts, :action => "active" %></p>
8
  <p>Out Of Sync Hosts <%= link_to @out_of_sync_hosts, :action => "OutOfSync" %></p>
9
  <p>Hosts in Error State <%= link_to @bad_hosts, :action => "errors" %></p>
10
  <p>Hosts With Alerts Disabled <%= link_to @disabled_hosts, :action => "disabled" %></p>
7
  <p>Hosts that had performed modifications <%= link_to @active_hosts, :controller => "hosts", :action => "active" %></p>
8
  <p>Out Of Sync Hosts <%= link_to @out_of_sync_hosts, :controller => "hosts", :action => "out_of_sync" %></p>
9
  <p>Hosts in Error State <%= link_to @bad_hosts, :controller => "hosts", :action => "errors" %></p>
10
  <p>Hosts With Alerts Disabled <%= link_to @disabled_hosts, :controller => "hosts", :action => "disabled" %></p>
11 11

  
12 12
  <div id='overview'></div>
13 13
  <%= @overview.render('overview') %>
config/routes.rb
4 4
  map.resources :reports
5 5
  map.connect "node/:name", :controller => 'hosts', :action => 'externalNodes',
6 6
    :requirements => { :name => /[^\.][\w\.-]+/ }
7
  map.connect "/hosts/query", :controller => 'hosts', :action => 'query'
7
  map.with_options :controller => 'hosts' do |hosts|
8
    hosts.connect 'hosts/query', :action => 'query'
9
    hosts.connect 'hosts/active', :action => 'active'
10
    hosts.connect 'hosts/out_of_sync', :action => 'out_of_sync'
11
    hosts.connect 'hosts/errors', :action => 'errors'
12
    hosts.connect 'hosts/disabled', :action => 'disabled'
13
  end
8 14
  map.resources :hosts,
9 15
    :requirements => {:id => /[^\/]+/},
10 16
    :member => { :report => :get, :reports => :get, :clone => :get,
11
-