Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #8011 - When displaying Reports for a host, eventful=true should b... #1895

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/views/common/_searchbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
<ul class="dropdown-menu pull-right">
<% bookmarks = Bookmark.my_bookmarks.controller(controller_name) %>
<% bookmarks.each do |bookmark| %>
<li><%= link_to_if_authorized bookmark.name, send("hash_for_#{bookmark.controller}_path").merge(:search => bookmark.query) %></li>
<% if bookmark.name == "eventful" or bookmark.name == "eventless" %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://devblog.avdi.org/2010/08/02/using-and-and-or-in-ruby/

In any case if you're checking if a variable is one of several values, this is a little more idiomatic:

['eventful', 'eventless'].include? bookmark.name

<% if (params[:search].try(:squeeze," ").include? "eventful") == true %>
<li><%= link_to_if_authorized bookmark.name, send("hash_for_#{bookmark.controller}_path").merge(:search => params[:search].try(:squeeze," ").gsub(/eventful.=.(false|true)/,bookmark.query)) %></li>
<% elsif params[:search].lstrip != "" %>
<li><%= link_to_if_authorized bookmark.name, send("hash_for_#{bookmark.controller}_path").merge(:search => params[:search].try(:squeeze," ") + " and " + bookmark.query) %></li>
<% else %>
<li><%= link_to_if_authorized bookmark.name, send("hash_for_#{bookmark.controller}_path").merge(:search => bookmark.query) %></li>
<% end %>
<% else %>
<li><%= link_to_if_authorized bookmark.name, send("hash_for_#{bookmark.controller}_path").merge(:search => bookmark.query) %></li>
<% end %>
<% end %>
<li class="divider"></li>
<li><%= link_to_function _('Bookmark this search'), "$('#bookmarks-modal').modal();",
Expand Down
1 change: 1 addition & 0 deletions db/seeds.d/15-bookmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Bookmark.without_auditing do
[
{ :name => "eventful", :query => "eventful = true", :controller=> "reports" },
{ :name => "eventless", :query => "eventful = false", :controller=> "reports" },
{ :name => "active", :query => 'last_report > "35 minutes ago" and (status.applied > 0 or status.restarted > 0)', :controller=> "hosts" },
{ :name => "out of sync", :query => 'last_report < "30 minutes ago" and status.enabled = true', :controller=> "hosts" },
{ :name => "error", :query => 'last_report > "35 minutes ago" and (status.failed > 0 or status.failed_restarts > 0 or status.skipped > 0)', :controller=> "hosts" },
Expand Down