Revision 010c668d
Added by Paul Kelly over 13 years ago
- ID 010c668d6dcb08b2e7dec0ee5e5a5f6879d72900
app/controllers/hosts_controller.rb | ||
---|---|---|
redirect_to :controller => "reports", :action => "show", :id => Report.maximum('id', :conditions => {:host_id => @host})
|
||
end
|
||
|
||
# shows all interesting reports for a certain host
|
||
# shows reports for a certain host
|
||
def reports
|
||
# set defaults search order - cant use default scope due to bug in AR
|
||
# http://github.com/binarylogic/searchlogic/issues#issue/17
|
||
params[:search] ||= {}
|
||
params[:search][:order] ||= "ascend_by_reported_at"
|
||
@search = Report.search(params[:search]).status_ne(0)
|
||
@search = Report.search(params[:search])
|
||
@reports = @search.paginate(:page => params[:page], :conditions => {:host_id => @host}, :include => :host)
|
||
end
|
||
|
app/controllers/reports_controller.rb | ||
---|---|---|
filter_parameter_logging :report
|
||
|
||
def index
|
||
@interesting = (params[:search] and params[:search][:interesting] and params[:search][:interesting] == "true")
|
||
search_cmd = "Report"
|
||
for condition in Report::METRIC
|
||
search_cmd += ".with('#{condition.to_s}', #{params[condition]})" if params.has_key? condition
|
||
end
|
||
search_cmd += ".with_changes" if (@interesting = params[:interesting])
|
||
search_cmd += ".search(params[:search])"
|
||
# set defaults search order - cant use default scope due to bug in AR
|
||
# http://github.com/binarylogic/searchlogic/issues#issue/17
|
app/models/report.rb | ||
---|---|---|
named_scope :recent, lambda { |*args| {:conditions => ["reported_at > ?", (args.first || 1.day.ago)]} }
|
||
|
||
# with_changes
|
||
named_scope :with_changes, {:conditions => "status != 0"}
|
||
named_scope :interesting, {:conditions => "status != 0"}
|
||
|
||
# a method that save the report values (e.g. values from METRIC)
|
||
# it is not supported to edit status values after it has been written once.
|
app/views/home/_menu.erb | ||
---|---|---|
<tr>
|
||
<td style="width: 100%;">
|
||
<ul>
|
||
<li> <%= link_to_if_authorized "Dashboard", hash_for_dashboard_path %> </li>
|
||
<li> <%= link_to_if_authorized "Hosts", hash_for_hosts_path %> </li>
|
||
<li> <%= link_to_if_authorized "Reports", hash_for_reports_path.merge(:interesting => 1) %> </li>
|
||
<li> <%= link_to_if_authorized "Facts", hash_for_fact_values_path %> </li>
|
||
<li> <%= link_to_if_authorized "Audit Log", hash_for_audits_path %> </li>
|
||
<li> <%= link_to_if_authorized "Statistics", hash_for_statistics_path %> </li>
|
||
<li> <%= link_to_if_authorized "Dashboard", hash_for_dashboard_path %> </li>
|
||
<li> <%= link_to_if_authorized "Hosts", hash_for_hosts_path %> </li>
|
||
<li> <%= link_to_if_authorized "Reports", hash_for_reports_path.merge(:search => {:interesting => true}) %> </li>
|
||
<li> <%= link_to_if_authorized "Facts", hash_for_fact_values_path %> </li>
|
||
<li> <%= link_to_if_authorized "Audit Log", hash_for_audits_path %> </li>
|
||
<li> <%= link_to_if_authorized "Statistics", hash_for_statistics_path %> </li>
|
||
</ul>
|
||
</td>
|
||
<td>
|
app/views/reports/_list.html.erb | ||
---|---|---|
<% for report in @reports %>
|
||
<tr class="<%= cycle("even", "odd") -%>">
|
||
<% unless defined? @host -%>
|
||
<td><%= link_to h(report.host.shortname), reports_host_path(report.host) %></td>
|
||
<td><%= link_to h(report.host.shortname), reports_host_path(report.host) + "?search[interesting]=1" %></td>
|
||
<% end -%>
|
||
<td><%= reported_at_column(report) %></td>
|
||
<td><%= h report.applied %></td>
|
app/views/reports/_search_line.html.erb | ||
---|---|---|
</div>
|
||
<div> |
|
||
<span title="Reports that contain some activity">
|
||
<%= check_box_tag "interesting", "1", params[:interesting] %>
|
||
<%= f.check_box :interesting , {}, true, false %>
|
||
<small>Interesting</small>
|
||
</span>
|
||
<% for status in Report::METRIC -%>
|
Also available in: Unified diff
Fixes #444 - use searchlogic in interesting report filter