]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1352 add period select on alerts quality profiles page
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 28 Nov 2012 16:41:50 +0000 (17:41 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 28 Nov 2012 17:51:39 +0000 (18:51 +0100)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/helpers/alerts_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_edit.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_new.html.erb

index 8ab87ede62fbfe3cae25ad754330197b45e2d932..95436a19e3b62814d4147bce34032def722988a6 100644 (file)
@@ -220,6 +220,7 @@ since_version_detailed=since version {0} ({1})
 since_previous_version=since previous version
 since_previous_version_detailed=since previous version ({0})
 time_changes=Time changes
+absolute_value=Absolute value
 
 #------------------------------------------------------------------------------
 #
index 87355bd7c946d134addaf9ede2a72d94259ab816..d94f56c2d0ed2024a3a373cf9b201964e0ca5887 100644 (file)
@@ -88,4 +88,14 @@ module AlertsHelper
     end
   end
 
+  def period_select_options(alert, index)
+    if index
+      selected = (alert.period == index ? 'selected' : '')
+      "<option value='#{index}' #{selected}>&Delta; Period #{index}</option>"
+    else
+      selected = (alert.period ? 'selected' : '')
+      "<option value='' #{selected}>#{message('absolute_value')}</option>"
+    end
+  end
+
 end
\ No newline at end of file
index 273f8c23a7d5dfad9c34aea06279fe02dfefc5c2..c539bdc0c8f649978ca78f35889b795e986e26ca 100644 (file)
@@ -4,6 +4,14 @@
   <td nowrap>
     <%= h alert.name %>
   </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) -%>
+    </select>
+  </td>
   <td width="10%" nowrap>
     <select id="alert_operator" name="alert[operator]">
       <% operators_for_select(alert).each do |key| %>
index 028a58d96915c60fa09c028600299b6c1e5c7979..82af723cb1abe70af3e0b0b2801b991110eff710 100644 (file)
@@ -3,25 +3,36 @@
 <table class="spaced">
 <tr>
   <td valign="top">
-  <script type="text/javascript">
-    //<![CDATA[
-    function selectMetric() {
-      <%= remote_function(:url => {:controller => 'alerts', :action => 'new', :profile_id => @profile.id}, :with => "'alert[metric_id]=' + $('alert_metric_id').value", :method => 'get') %>;
-    }
-    //]]>
-  </script>
+    <script type="text/javascript">
+      //<![CDATA[
+      function selectMetric() {
+        <%= remote_function(:url => {:controller => 'alerts', :action => 'new', :profile_id => @profile.id}, :with => "'alert[metric_id]=' + $('alert_metric_id').value", :method => 'get') %>;
+      }
+      //]]>
+    </script>
 
-  <select id="alert_metric_id" name="alert[metric_id]" onChange="javascript:selectMetric()">
-    <option value="" <%= 'selected' if @alert.metric.nil? %>><%= message('alerts.select_metric') -%></option>
-  <% 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| %>
-      <option value="<%= metric.id -%>" <%= 'selected' if @alert.metric_id==metric.id -%>><%= metric.short_name %></option>
-    <% end %>
-  </optgroup>
-  <% end %>
-  </select>
+    <select id="alert_metric_id" name="alert[metric_id]" onChange="javascript:selectMetric()">
+      <option value="" <%= 'selected' if @alert.metric.nil? %>><%= message('alerts.select_metric') -%></option>
+      <% 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| %>
+          <option value="<%= metric.id -%>" <%= 'selected' if @alert.metric_id==metric.id -%>><%= metric.short_name %></option>
+        <% end %>
+      </optgroup>
+      <% end %>
+    </select>
+  </td>
+
+  <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 %>
+    </select>
   </td>
 
   <td width="10%"  valign="top">