aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-07 16:17:50 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-07 16:17:50 +0000
commit0cd519b35d499f60fceec66f08dc7ca80301f127 (patch)
tree8c9a547da0ee1ce5c1bf20e9d139f1f705b42bec /sonar-server
parentc1cfffea2098a53ab078deb9bebe47b627c389cf (diff)
downloadsonarqube-0cd519b35d499f60fceec66f08dc7ca80301f127.tar.gz
sonarqube-0cd519b35d499f60fceec66f08dc7ca80301f127.zip
SONAR-1937 add the field 'age' to violations web service + display the select box to filter violations by period
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb24
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb21
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project/index.html.erb49
6 files changed, 45 insertions, 57 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb
index 43576d79496..7820bc17503 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb
@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
module DrilldownHelper
+ include DashboardHelper
def measure_or_variation_value(measure)
if measure
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb
index 181b4332bf3..3b4e73b4de7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb
@@ -23,21 +23,34 @@ class RuleFailure < ActiveRecord::Base
belongs_to :rule
belongs_to :snapshot
+ def age_in_days
+ if created_at
+ ((snapshot.created_at - created_at)/(60 * 60 * 24)).to_i
+ else
+ nil
+ end
+ end
+
def to_hash_json
json = {}
json['message'] = message
json['line'] = line if line
json['priority'] = Sonar::RulePriority.to_s(failure_level).upcase
- json['createdAt'] = format_datetime(created_at) if created_at
+ if created_at
+ json['createdAt'] = format_datetime(created_at)
+ json['age'] = age_in_days
+ end
json['rule'] = {
:key => rule.key,
- :name => rule.name}
+ :name => rule.name
+ }
json['resource'] = {
:key => snapshot.project.key,
:name => snapshot.project.name,
:scope => snapshot.project.scope,
:qualifier => snapshot.project.qualifier,
- :language => snapshot.project.language}
+ :language => snapshot.project.language
+ }
json
end
@@ -46,7 +59,10 @@ class RuleFailure < ActiveRecord::Base
xml.message(message)
xml.line(line) if line
xml.priority(Sonar::RulePriority.to_s(failure_level))
- xml.createdAt(format_datetime(created_at)) if created_at
+ if created_at
+ xml.createdAt(format_datetime(created_at))
+ xml.age(age_in_days)
+ end
xml.rule do
xml.key(rule.key)
xml.name(rule.name)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb
index 6e60e64b5d6..331bea8eb7c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb
@@ -17,10 +17,9 @@
<div id="snapshot_title" class="page_title">
<h4>
<%
- version_event=@snapshot.event(EventCategory::KEY_VERSION)
profile_measure=@snapshot.measure(Metric::PROFILE)
%>
- <%= link_to_favourite(@project) -%> <%= "#{version_event.fullname} - " if version_event %> <%= l @snapshot.created_at %>
+ <%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
- Compare to
<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
@@ -29,6 +28,8 @@
<%= variation_select_option(@snapshot, 1) -%>
<%= variation_select_option(@snapshot, 2) -%>
<%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
</select>
</form>
</h4>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
index 2a5b503eeca..b59824efa91 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
@@ -1,4 +1,23 @@
-<%= render :partial => 'project/snapshot_title' -%>
+<div id="snapshot_title" class="page_title">
+<h4>
+<%
+ profile_measure=@snapshot.measure(Metric::PROFILE)
+ %>
+<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
+<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
+- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
+ <select id="select-comparison" name="var" onchange="submit()" class="small">
+ <option value="">All violations</option>
+ <%= variation_select_option(@snapshot, 1) -%>
+ <%= variation_select_option(@snapshot, 2) -%>
+ <%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
+ </select>
+ </form>
+</h4>
+</div>
+
<%= render :partial => 'gwt/base', :locals => {:resource => @highlighted_resource, :popup => false, :metric => 'violations'} %>
<%= render :partial => 'gwt/resource_viewers', :locals => {:resource => @project} %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb
index c5a57fb1533..cecfecef2e3 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb
@@ -5,7 +5,7 @@
version_event=@snapshot.event(EventCategory::KEY_VERSION)
profile_measure=@snapshot.measure(Metric::PROFILE)
%>
-<%= link_to_favourite(@project) -%> <%= "#{version_event.fullname} - " if version_event %> <%= l @snapshot.created_at %>
+<%= link_to_favourite(@project) -%> Version <%= "#{@snapshot.version} -%> - <%= l @snapshot.created_at %>
<% if profile_measure %> - profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
</h4>
</div>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/index.html.erb
index 4789e49b0f8..e69de29bb2d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/index.html.erb
@@ -1,49 +0,0 @@
-<div id='dashboard'>
-<%= render :partial => 'project/snapshot_title' %>
-<table><tr>
- <td width="390px" valign="top" style="padding: 0 4px 0 0">
-
- </td>
- <td width="390px" valign="top" style="padding: 0 0 0 4px">
-
-<% @widgets.each do |widget|
- begin
- widget_body=render :inline => widget.getTarget().getTemplate()
- rescue => error
- logger.error("Can not render widget #{widget.getId()}: " + error)
- logger.error(error.backtrace.join("\n"))
- widget_body="<p>Can not render widget #{widget.getTitle()}. See logs.</p>"
- end
- if widget_body.include? '<'
-%>
-<div id="<%= widget.getId() -%>" class="widget">
-<%= widget_body %>
-<div class="clear"></div>
-</div>
-<% else %>
-<div id="<%= widget.getId() -%>" ></div>
-<% end
-end %>
- </td>
-</tr></table>
-<script type="text/javascript">
- function selectReviewMetric(){
- $$('.review_description_update').each(function(element) {
- element.hide();
- });
- review = $('review_metric_id').value;
- $('review_description_'+review).show();
- $('review_value_'+review).show();
- }
-
- function selectEventCateg(){
- $$('#event_cat_desc .comments').each(function(elt) {
- elt.hide();
- });
- selected_categ = $('event_category').value;
- if (selected_categ!=null && selected_categ!='') {
- $('event_cat_desc_'+selected_categ).show();
- }
- }
-</script>
-</div> \ No newline at end of file