end
end
- def period_select_options(alert, index)
+ def period_select_options(alert)
+ if alert.metric
+ select = ''
+ select << period_select_option(alert, nil) if !alert.metric.name.start_with?("new_")
+ for index in 1..3 do
+ select << period_select_option(alert, index)
+ end
+ select
+ end
+ end
+
+ def period_select_option(alert, index)
if index
selected = (alert.period == index ? 'selected' : '')
"<option value='#{index}' #{selected}>Δ #{Api::Utils.period_label(index)}</option>"
</td>
<td width="10%" nowrap>
<select id="alert_period" name="alert[period]">
- <%= period_select_options(alert, nil) -%>
- <%= period_select_options(alert, 1) -%>
- <%= period_select_options(alert, 2) -%>
- <%= period_select_options(alert, 3) -%>
+ <%= period_select_options(alert) -%>
</select>
</td>
<td width="10%" nowrap>
<% Metric.domains.each do |domain| %>
<optgroup label="<%= h domain -%>">
<%# 'new_' metrics excluded due to SONAR-2396 %>
- <% Metric.by_domain(domain).select{ |m| m.alertable? && !m.name.start_with?("new_") }.each do |metric| %>
+ <% Metric.by_domain(domain).select{ |m| m.alertable? }.each do |metric| %>
<option value="<%= metric.id -%>" <%= 'selected' if @alert.metric_id==metric.id -%>><%= metric.short_name %></option>
<% end %>
</optgroup>
<td width="10%" valign="top">
<select id="alert_period" name="alert[period]">
- <% if !@alert.metric.nil? %>
- <%= period_select_options(@alert, nil) -%>
- <%= period_select_options(@alert, 1) -%>
- <%= period_select_options(@alert, 2) -%>
- <%= period_select_options(@alert, 3) -%>
- <% end %>
+ <%= period_select_options(@alert) -%>
</select>
</td>