From 4464c719e065e714fc2726b1d04a86b85c6a0222 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Tue, 1 Mar 2011 17:31:21 +0100 Subject: [PATCH] SONAR-2218 improve experimental resource viewer - support period filtering on all tabs --- .../app/controllers/browse_controller.rb | 60 ++++++++++++++----- .../WEB-INF/app/helpers/application_helper.rb | 2 +- .../app/views/browse/_violation.html.erb | 9 ++- .../WEB-INF/app/views/browse/index.html.erb | 49 +++++++++++++-- 4 files changed, 98 insertions(+), 22 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb index 5ae0ae64c12..5021fe3eefc 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb @@ -20,7 +20,8 @@ class BrowseController < ApplicationController SECTION=Navigation::SECTION_RESOURCE - + helper DashboardHelper + def index @resource = Project.by_key(params[:id]) @@ -36,27 +37,24 @@ class BrowseController < ApplicationController def render_resource + @period = params[:period].to_i unless params[:period].blank? + @expanded=(params[:expand]=='true') + @source = @snapshot.source if @source source_lines=Java::OrgSonarServerUi::JRubyFacade.new.colorizeCode(@source.data, @snapshot.project.language).split("\n") load_scm() @lines=[] - current_revision=nil source_lines.each_with_index do |source, index| line=Line.new(source) @lines< 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| @@ -137,18 +143,40 @@ class BrowseController < ApplicationController @global_violations<=0 && i<@lines.size + end + elsif line.hidden==nil + line.hidden=true + end + end + end end def load_source_tab + filter_lines_by_date() + end + def filter_lines_by_date + if @period + date=@snapshot.period_datetime(@period) + if date + @lines.each do |line| + line.hidden=true if line.datetime==nil || line.datetime !small, :empty => !no_tendency_img}) + trend_icon(metric_or_measure, {:big => !small, :empty => !no_tendency_img}) end def boolean_icon(boolean_value, options={}) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_violation.html.erb index e0803a8ec42..c3feeb1f0b4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_violation.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_violation.html.erb @@ -2,4 +2,11 @@ <%= h(violation.rule.name) -%> » -<%= h(violation.message) -%> \ No newline at end of file +<%= h(violation.message) -%> +<% + if violation.created_at + duration=Date.today - violation.created_at.to_date + +%> + <%= duration==0 ? 'today' : "#{duration} days ago" -%> +<% end %> \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb index d05ecd6f3c6..a5ae5545a92 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb @@ -52,6 +52,10 @@ span.rulename, span.rulename a { color: #4183C4; text-decoration: none; } +span.violation_date { + color: #AAA; + font-size: 11px; +} span.rulename a:hover { text-decoration: underline; } @@ -121,12 +125,41 @@ span.rulename a:hover {
<%= qualifier_icon(@resource) -%> <%= @resource.long_name -%> <% if @lines %> - | raw + | raw <% end %>
- -
+ + +
+
+ + <% if @scm_available %> + onclick="submit()"/> + + <% end %> + + <% if @snapshot.project_snapshot.periods? %> + + <% end %> + + <% if @expandable %> + onclick="submit()"/> + + <% end %> +
+
<% if @display_violations && @global_violations && @global_violations.size>0 -%> @@ -141,7 +174,10 @@ span.rulename a:hover { <% if @lines && @lines.size>0 %>
<% + current_revision=nil @lines.each_with_index do |line, index| + next if line.hidden + status=hits_status=conditions_status='' if @display_coverage && line.hits hits_status=(line.hits>0 ? 'ok' : 'ko') @@ -165,10 +201,11 @@ span.rulename a:hover { %> <% if @display_scm - if line.display_scm - title = "Revision #{h(line.revision)} (#{line.date})" + if current_revision!=line.revision + current_revision=line.revision + title = "Revision #{h(line.revision)} (#{l(line.datetime)})" %> - + <% else %> <% end -- 2.39.5
<%= line.date[0..9] -%> <%= h(line.author) -%><%= l(line.date) -%> <%= h(line.author) -%>