lib/flapjack/gateways/web/views/contact.html.erb in flapjack-1.6.0 vs lib/flapjack/gateways/web/views/contact.html.erb in flapjack-2.0.0b1

- old
+ new

@@ -1,56 +1,57 @@ <div class="page-header"> - <h2><%= h @contact.name %></h2> + <h2><%= h @contact[:name] %></h2> </div> -<% alerting = {} %> - <h3>Contact Media</h3> -<% if !@contact.media || @contact.media.empty? %> +<% if @media.nil? || @media.empty? %> <p>No media</p> <% else %> <table class="table table-bordered table-hover table-condensed"> <tr> <th>Media</th> <th>Address</th> <th>Interval</th> <th>Summary Mode</th> <th>Summary Threshold</th> </tr> - <% @contact.media.each_pair do |mk, mv| %> - <% alerting_checks = @contact.alerting_checks_for_media(mk) %> - <% alerting[mk] = alerting_checks unless (alerting_checks.nil? || alerting_checks.empty?) %> + <% @media.each do |med| %> + <% alerting_checks = @alerting_checks_by_media_id[med[:id]] %> + <% media_transport = med[:transport] %> <tr> - <% if 'pagerduty'.eql?(mk) %> + <% if 'pagerduty'.eql?(media_transport) %> <td>PagerDuty</td> <td> - <% @pagerduty_credentials.each_pair do |pk, pv| %> + <% [:pagerduty_subdomain, :pagerduty_user_name, + :pagerduty_password, :pagerduty_token, + :pagerduty_ack_duration].each do |pk| %> + <% pv = med[pk] %> <% unless pv.empty? %> - <p><%= 'password'.eql?(pk) ? h("#{pk}: ...") : h("#{pk}: #{pv}") %></p> + <p><%= :pagerduty_password.eql?(pk) ? h("#{pk}: ...") : h("#{pk}: #{pv}") %></p> <% end %> <% end %> </td> <td></td> <td></td> <td></td> <% else %> - <% if 'sms'.eql?(mk) %> - <td><%= h mk.upcase %></td> + <% if 'sms'.eql?(media_transport) %> + <td><%= h media_transport.upcase %></td> <% else %> - <td><%= h mk.capitalize %></td> + <td><%= h media_transport.capitalize %></td> <% end %> - <td><%= h mv %></td> + <td><%= h med[:address] %></td> <td> - <% if @contact.media_intervals[mk] %> - <%= h @contact.media_intervals[mk] %> seconds + <% if med[:interval] %> + <%= h med[:interval] %> seconds <% else %> no custom interval <% end %> </td> <td> - <% rollup_threshold = @contact.media_rollup_thresholds[mk] %> - <% num_alerting = alerting[mk].nil? ? 0 : alerting[mk].length %> + <% rollup_threshold = med[:rollup_threshold] %> + <% num_alerting = alerting_checks.nil? ? 0 : alerting_checks.length %> <% if rollup_threshold.nil? || (num_alerting < rollup_threshold.to_i) %> No - <% else %> Yes - <% end %> @@ -68,95 +69,82 @@ <% end %> </table> <% end %> <h3>Alerting Checks</h3> -<p>Alerting checks are any that are failing, not acknowledged, not in scheduled maintenance, and currently allowed by this contact's notification rules.</p> +<p>Alerting checks are any that are failing (and have alerted), not acknowledged, not in scheduled maintenance, and currently allowed by this contact's notification rules.</p> -<% if alerting.empty? %> +<% if @alerting_checks_by_media_id.nil? || @alerting_checks_by_media_id.empty? %> <p><em>There are no currently alerting checks.</em></p> <% else %> <table class="table table-bordered table-hover table-condensed"> <tr> - <th>Media</th> + <th>Medium</th> <th>Alerting Checks</th> </tr> - <% alerting.each_pair do |media, checks| %> + <% @alerting_checks_by_media_id.each_pair do |media_id, checks| %> <% if checks.length > 0 %> <tr> - <td><%= h media.capitalize %></td> + <td><%= h @media.detect {|m| m[:id].eql?(media_id) }[:transport].capitalize %></td> <td> - <% checks.each do |entity_check| %> - <% entity, check = entity_check.split(':', 2) %> - <% check_link = "<a href=\"#{@base_url}check?entity=#{u(entity)}&amp;check=#{u(check)}\" title=\"check status\">" + - h(check) + "</a>"%> - <a href="<%= @base_url %>entity/<%= u(entity) %>" title="entity status"><%= h entity %></a> :: - <%= check_link %> <br /> + <% checks.each do |check| %> + <a href="<%= @base_url %>checks/<%= u(check[:id]) %>" title="check status"><%= h(check[:name]) %></a><br /> <% end %> </td> </tr> <% end %> <% end %> </table> <% end %> -<h3>Notification Rules</h3> -<% rules = @contact.notification_rules %> -<% if !rules || rules.empty? %> - <p>No notification rules</p> +<h3>Rules</h3> +<% if !@rules || @rules.empty? %> + <p>No rules</p> <% else %> <table class="table table-bordered table-hover table-condensed"> <tr> - <th>ID</th> - <th>Entities</th> - <th>Entities Regex</th> + <th>Name/ID</th> + <th>Blackhole</th> + <th>Strategy</th> <th>Tags</th> - <th>Tags Regex</th> - <th>Warning Media</th> - <th>Critical Media</th> + <th>Conditions</th> + <th>Media</th> <th>Time Restrictions</th> - <th>Blackholes</th> </tr> - <% rules.each do |rule| %> + <% @rules.each do |rule| %> + <% rule_name = rule[:name].nil? || rule[:name].empty? ? rule[:id] : rule[:name] %> + <% blackhole = rule[:blackhole] ? 'true' : 'false' %> + <% tags = @tags_by_rule_id[rule[:id]] %> + <% tag_names = tags.nil? ? [] : tags.map {|t| t[:name] } %> + <% rule_conds = rule[:conditions_list] %> + <% media = @media_by_rule_id[rule[:id]] %> + <% transports = media.nil? ? [] : media.map {|m| m[:transport] } %> <tr> - <td><%= h rule.id %></td> - <td><%= h( (rule.entities && !rule.entities.empty?) ? rule.entities.join(', ') : '-') %></td> - <td><%= h( (rule.regex_entities && !rule.regex_entities.empty?) ? rule.regex_entities.join(', ') : '-') %></td> - <td><%= h( (rule.tags && !rule.tags.empty?) ? rule.tags.to_a.join(', ') : '-') %></td> - <td><%= h( (rule.regex_tags && !rule.regex_tags.empty?) ? rule.regex_tags.to_a.join(', ') : '-') %></td> - <td><%= h( (rule.warning_media && !rule.warning_media.empty?) ? rule.warning_media.join(', ') : '-')%></td> - <td><%= h( (rule.critical_media && !rule.critical_media.empty?) ? rule.critical_media.join(', ') : '-') %></td> - <td><%= h(rule.time_restrictions) %></td> - <% blackholes = [] %> - <% blackholes << 'Warning' if rule.warning_blackhole %> - <% blackholes << 'Critical' if rule.critical_blackhole %> - <td><%= h(blackholes.join(', ')) %></td> + <td><%= h( rule_name ) %></td> + <td><%= h( blackhole ) %></td> + <td><%= h( rule[:strategy]) %></td> + <td><%= h( !tag_names.empty? ? tag_names.join(', ') : '-') %></td> + <td><%= h( (!rule_conds.nil? && !rule_conds.empty?) ? rule_conds : '-')%></td> + <td><%= h( !transports.empty? ? transports.join(', ') : '-') %></td> + <td><%= h rule[:time_restriction_ical] %></td> </tr> <% end %> </table> <% end %> -<h3>All Entities and Checks</h3> -<% if !@entities_and_checks || @entities_and_checks.empty? %> - <p>No entities</p> +<h3>All Checks</h3> +<% if @checks.empty? %> + <p>No checks</p> <% else %> <table class="table table-bordered table-hover table-condensed"> <tr> - <th>Entity</th> <th>Checks</th> </tr> - <% @entities_and_checks.each do |ec| %> - <% - entity = ec[:entity] - checks = ec[:checks] - %> - <tr> - <td><a href="<%= @base_url %>entity/<%= u(entity.name) %>" title="entity status"><%= h entity.name %></a></td> - <td> - <% checks.each do |check| %> - <%= "<a href=\"#{@base_url}check?entity=#{u(entity.name)}&amp;check=#{u(check)}\" title=\"check status\">#{ h check }</a>" %> - <% end %> - </td> - </tr> - <% end %> + <tr> + <td> + <% @checks.each do |check| %> + <a href="<%= @base_url %>checks/<%= u(check[:id]) %>" title="check status"><%= h check[:name] %></a> + <% end %> + </td> + </tr> </table> <% end %>