aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-10-21 13:12:41 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-10-21 13:12:41 +0000
commit938b174bc222412d372730d64c23117100afefaf (patch)
tree53451da83ee373a795bfe8c1d96c796249bdb628
parent4309fc779ee20b873226cb3c0081f9d42145b967 (diff)
downloadsonarqube-938b174bc222412d372730d64c23117100afefaf.tar.gz
sonarqube-938b174bc222412d372730d64c23117100afefaf.zip
SONAR-1830 support rating metric type in drilldowns and timemachine
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb2
6 files changed, 18 insertions, 15 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java
index b12e253fd2f..edbccfeb04c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java
@@ -134,7 +134,7 @@ public final class WSMetrics {
public static class Metric {
public enum ValueType {
- INT, FLOAT, PERCENT, BOOL, STRING, MILLISEC, DATA, LEVEL, DISTRIB
+ INT, FLOAT, PERCENT, BOOL, STRING, MILLISEC, DATA, LEVEL, DISTRIB, RATING
}
private String key;
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
index e46c91ce347..11f71379f6c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
@@ -115,7 +115,7 @@ module ApplicationHelper
show_link=true
alert_link=true
elsif measure.metric.val_type==Metric::VALUE_TYPE_RATING && measure.color
- style = "style='background-color: #{measure.color};padding: 2px 5px'"
+ style = "style='background-color: #{measure.color.html};padding: 2px 5px'"
end
html="<span id='m_#{measure.key}' #{alert_class} #{style}>#{html}</span>"
@@ -223,7 +223,7 @@ module ApplicationHelper
# Display a measure
#
# === Optional parameters
- #
+ # * <tt>:skip_span_id</tt> - skip the generation of the html attribute 'id'. Default is false
# * <tt>:url</tt> - add an url on the measure.
# * <tt>:prefix</tt> - add a prefix. Default is ''.
# * <tt>:suffix</tt> - add a suffix. Default is ''.
@@ -264,12 +264,16 @@ module ApplicationHelper
link_rel=h(m.alert_text)
show_link=true
alert_link = true
-
+
elsif m.metric.val_type==Metric::VALUE_TYPE_RATING && m.color
- style = "style='background-color: #{m.color};padding: 2px 5px'"
+ style = "style='background-color: #{m.color.html};padding: 2px 5px'"
end
- html="<span id='m_#{m.key}' #{alert_class} #{style}>#{html}</span>"
+ span_id=''
+ unless options[:skip_span_id]
+ span_id="id='m_#{m.key}'"
+ end
+ html="<span #{span_id} #{alert_class} #{style}>#{html}</span>"
if options[:prefix]
html="#{options[:prefix]}#{html}"
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb
index 7b761c6ddd3..2f9eb94d88d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb
@@ -91,7 +91,7 @@ class DrilldownColumn
end
@measures=ProjectMeasure.find(:all,
- :select => 'project_measures.id,project_measures.metric_id,project_measures.value,project_measures.text_value,project_measures.snapshot_id',
+ :select => 'project_measures.id,project_measures.metric_id,project_measures.value,project_measures.text_value,project_measures.alert_status,project_measures.snapshot_id',
:joins => :snapshot,
:conditions => [conditions,values],
:order => order,
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb
index 2cda15f22e0..d7ac66adfb9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb
@@ -125,9 +125,9 @@ class ProjectMeasure < ActiveRecord::Base
end
- MIN_COLOR=Color::RGB.from_html("FF0000") # red
- MEAN_COLOR=Color::RGB.from_html("FFB000") # orange
- MAX_COLOR=Color::RGB.from_html("00FF00") # green
+ MIN_COLOR=Color::RGB.from_html("EE0000") # red
+ MEAN_COLOR=Color::RGB.from_html("FFEE00") # orange
+ MAX_COLOR=Color::RGB.from_html("00AA00") # green
def color
@color ||=
@@ -150,13 +150,12 @@ class ProjectMeasure < ActiveRecord::Base
percent=100.0 if percent>100.0
percent=0.0 if percent<0.0
end
-
if percent<0.0
nil
elsif (percent > 50.0)
- MAX_COLOR.mix_with(MEAN_COLOR, percent - 50.0)
+ MAX_COLOR.mix_with(MEAN_COLOR, (percent - 50.0) * 2.0)
else
- MIN_COLOR.mix_with(MEAN_COLOR, 50.0 - percent)
+ MIN_COLOR.mix_with(MEAN_COLOR, (50.0 - percent) * 2.0)
end
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb
index 15ab32286b2..8edb2a39311 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb
@@ -48,7 +48,7 @@
<% end %>
</td>
<td class="right last" >
- <%= measure.formatted_value -%>
+ <%= format_measure(measure, :skip_span_id => true) -%>
<!--[if IE]> &nbsp; &nbsp; <![endif]-->
</td>
</tr>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb
index 47d7c0338ba..0d932fe77a2 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb
@@ -135,7 +135,7 @@
<% @snapshots.each do |snapshot|
measure=row.measure(snapshot)
%>
- <td align="right" width="1%" nowrap="nowrap"><%= html_measure(measure, nil, true, nil, nil, nil, true) %></td>
+ <td align="right" width="1%" nowrap="nowrap"><%= format_measure(measure, :skip_span_id => true) %></td>
<% end %>
<td>
<%