From 914d329ad4f75b0248c44fdfa0cea958a5388c8b Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Tue, 8 Mar 2011 13:23:38 +0100 Subject: [PATCH] SONAR-2218 improve UI --- .../core/widgets/code_coverage.html.erb | 4 +- .../app/controllers/drilldown_controller.rb | 2 +- .../app/controllers/resource_controller.rb | 10 +- .../WEB-INF/app/helpers/application_helper.rb | 8 +- .../WEB-INF/app/helpers/dashboard_helper.rb | 34 +++++ .../WEB-INF/app/helpers/drilldown_helper.rb | 32 ----- .../app/views/drilldown/_rule_priority.erb | 4 +- .../app/views/drilldown/measures.html.erb | 2 +- .../app/views/drilldown/violations.html.erb | 10 +- .../views/resource/_header_coverage.html.erb | 112 ++++++++-------- .../resource/_header_violations.html.erb | 124 ++++++++++++------ .../app/views/resource/_options.html.erb | 13 +- .../app/views/resource/_rules_filter.html.erb | 80 ++++++++--- .../WEB-INF/app/views/resource/index.html.erb | 2 +- .../src/main/webapp/stylesheets/style.css | 2 +- 15 files changed, 269 insertions(+), 170 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb index 79c0d1787fb..3e165313f01 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb @@ -40,7 +40,7 @@ new_line_coverage=measure('new_line_coverage') new_branch_coverage=measure('new_branch_coverage') %>
-

On new/changed code:

+

On new code:

<% if new_lines.to_i>0 %> <% if new_coverage %>

@@ -48,7 +48,7 @@

<% end %>

- <%= new_lines.to_i -%> new lines to cover + <%= new_lines.to_i -%> lines to cover

<% if new_line_coverage %>

diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb index 46910f85fb4..90a2cce018b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb @@ -20,7 +20,7 @@ class DrilldownController < ApplicationController before_filter :init_project - helper ProjectHelper + helper ProjectHelper, DashboardHelper SECTION=Navigation::SECTION_RESOURCE diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index e965b1a748b..afcc3f2722e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -171,8 +171,8 @@ class ResourceController < ApplicationController if @period date=@snapshot.period_datetime(@period) if date - conditions+=' AND created_at>=?' - values< 1) else conditions+=' AND id=-1' end @@ -213,10 +213,10 @@ class ResourceController < ApplicationController def filter_lines_by_date if @period - date=@snapshot.period_datetime(@period) - if date + to=@snapshot.period_datetime(@period) + if to @lines.each do |line| - line.hidden=true if line.datetime==nil || line.datetime#{label}" + end + else + nil + end + + end + + def measure_or_variation_value(measure) + if measure + @period_index ? measure.variation(@period_index) : measure.value + else + nil + end + end end \ No newline at end of file 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 19537519d4d..400d4af0886 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 @@ -19,37 +19,5 @@ # module DrilldownHelper - def period_select_options(snapshot, index) - return nil if snapshot.nil? || snapshot.project_snapshot.nil? - mode=snapshot.project_snapshot.send "period#{index}_mode" - mode_param=snapshot.project_snapshot.send "period#{index}_param" - date=snapshot.project_snapshot.send "period#{index}_date" - if mode - if mode=='days' - label = "Added over %s days" % mode_param - elsif mode=='version' - label = "Added since version %s" % mode_param - elsif mode=='previous_analysis' - label = "Added since previous analysis (%s)" % date.strftime("%Y %b. %d") - elsif mode=='date' - label = "Added since #{date.strftime("%Y %b %d")}" - end - if label - selected=(params[:period]==index.to_s ? 'selected' : '') - "" - end - else - nil - end - - end - - def measure_or_variation_value(measure) - if measure - @period_index ? measure.variation(@period_index) : measure.value - else - nil - end - end end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb index aff4f99f88a..14c91ad345a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb @@ -1,8 +1,8 @@ <%= image_tag "priority/#{priority_id}.png" %> - <%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period_index} %> + <%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period} %> - <%= @period_index ? format_variation(measure, :index => @period_index, :style => 'light') : format_measure(measure) -%> + <%= @period ? format_variation(measure, :index => @period, :style => 'light') : format_measure(measure) -%> <% value = measure_or_variation_value(measure) %> 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 329dfd64cfb..6da915f8c1b 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 @@ -13,7 +13,7 @@ <% end %> <% for period_index in 1..5 do %> - <%= period_select_options(@snapshot, 1) if @drilldown.display_period?(period_index) -%> + <%= period_select_options(@snapshot, period_index) if @drilldown.display_period?(period_index) -%> <% end %> 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 434bf469bb4..06e4f5d34f5 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 @@ -12,11 +12,11 @@ -

<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb index 3f58b908b1a..a7a297576bd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb @@ -1,68 +1,64 @@
- - - - - <%= render :partial => 'measure', :locals => {:measure => measure('line_coverage'), :title => 'Line coverage'} -%> + <% if @period && measure('new_coverage') %> +

On new code:

+
<%= format_measure('coverage', :default => '-') -%>
+ + - - <%= render :partial => 'measure', :locals => {:measure => measure('branch_coverage'), :title => 'Branch coverage'} -%> - - - - <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_lines'), :title => 'Uncovered lines', :ratio => measure('lines_to_cover')} -%> - - <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_conditions'), :title => 'Uncovered conditions', :ratio => measure('conditions_to_cover')} -%> - + - <% if @period && measure('new_coverage') - new_uncovered_lines=measure('new_uncovered_lines') - %> - - - + <% if m=measure('new_line_coverage') %> + + + <% else %> + + <% end %> - - + + <% if m=measure('new_branch_coverage') %> + + + <% else %> + + <% end %> + + + + <% if m=measure('new_uncovered_lines') %> + + + <% else %> + + <% end %> - - - <% if m=measure('new_line_coverage') %> - - - <% else %> - - <% end %> + + <% if m=measure('new_uncovered_conditions') %> + + + <% else %> + + <% end %> + +
<%= format_variation('new_coverage', :period => @period, :style => 'none') -%>

On new/changed code:
Line coverage:<%= format_variation(m, :period => @period, :style => 'none') -%>
<%= format_variation('new_coverage', :period => @period, :style => 'none') -%> Branch coverage:<%= format_variation(m, :period => @period, :style => 'none') -%>
Uncovered lines:<%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_lines_to_cover', :period => @period, :style => 'none') -%> Line coverage:<%= format_variation(m, :period => @period, :style => 'none') -%> Uncovered conditions: <%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_conditions_to_cover', :period => @period, :style => 'none') -%>
+ <% else %> + + + + + <%= render :partial => 'measure', :locals => {:measure => measure('line_coverage'), :title => 'Line coverage'} -%> - - <% if m=measure('new_branch_coverage') %> - - - <% else %> - - <% end %> - - - - - <% if new_uncovered_lines %> - - - <% else %> - - <% end %> - - - <% if m=measure('new_uncovered_conditions') %> - - - <% else %> - - <% end %> - + + <%= render :partial => 'measure', :locals => {:measure => measure('branch_coverage'), :title => 'Branch coverage'} -%> + + + + <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_lines'), :title => 'Uncovered lines', :ratio => measure('lines_to_cover')} -%> + + <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_conditions'), :title => 'Uncovered conditions', :ratio => measure('conditions_to_cover')} -%> + +
<%= format_measure('coverage', :default => '-') -%> Branch coverage:<%= format_variation(m, :period => @period, :style => 'none') -%>
Uncovered lines:<%= format_variation(new_uncovered_lines, :period => @period, :style => 'none') -%>/<%= format_variation('new_lines_to_cover', :period => @period, :style => 'none') -%> Uncovered conditions: <%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_conditions_to_cover', :period => @period, :style => 'none') -%>
<% end %> - - + <%= render :partial => 'options' -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb index 67e1d36eff8..fc97be464c7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb @@ -1,46 +1,88 @@
+ <% if @period && measure('new_violations') %> + + + + +
<%= format_variation('new_violations', :default => 0, :period => @period, :style => 'none') -%> new violations
+ + + + + + +
<%= image_tag 'priority/BLOCKER.png' -%>Blocker:<%= format_variation('new_blocker_violations', :default => 0, :period => @period, :style => 'none') -%>
+ + + + + + +
<%= image_tag 'priority/CRITICAL.png' -%>Critical:<%= format_variation('new_critical_violations', :default => 0, :period => @period, :style => 'none') -%>
+ + + + + + +
<%= image_tag 'priority/MAJOR.png' -%>Major:<%= format_variation('new_major_violations', :default => 0, :period => @period, :style => 'none') -%>
+ + + + + + +
<%= image_tag 'priority/MINOR.png' -%>Minor:<%= format_variation('new_minor_violations', :default => 0, :period => @period, :style => 'none') -%>
+ + + + + + +
<%= image_tag 'priority/INFO.png' -%>Info:<%= format_variation('new_info_violations', :default => 0, :period => @period, :style => 'none') -%>
- - - - -
<%= format_measure('violations', :default => 0) -%> violations
- - - - - - - -
<%= image_tag 'priority/BLOCKER.png' -%>Blocker:<%= format_measure('blocker_violations', :default => 0) -%>
- - - - - - -
<%= image_tag 'priority/CRITICAL.png' -%>Critical:<%= format_measure('critical_violations', :default => 0) -%>
- - - - - - -
<%= image_tag 'priority/MAJOR.png' -%>Major:<%= format_measure('major_violations', :default => 0) -%>
- - - - - - -
<%= image_tag 'priority/MINOR.png' -%>Minor:<%= format_measure('minor_violations', :default => 0) -%>
- - - - - - -
<%= image_tag 'priority/INFO.png' -%>Info:<%= format_measure('info_violations', :default => 0) -%>
+ <% else %> + + + + +
<%= format_measure('violations', :default => 0) -%> violations
+ + + + + + +
<%= image_tag 'priority/BLOCKER.png' -%>Blocker:<%= format_measure('blocker_violations', :default => 0) -%>
+ + + + + + +
<%= image_tag 'priority/CRITICAL.png' -%>Critical:<%= format_measure('critical_violations', :default => 0) -%>
+ + + + + + +
<%= image_tag 'priority/MAJOR.png' -%>Major:<%= format_measure('major_violations', :default => 0) -%>
+ + + + + + +
<%= image_tag 'priority/MINOR.png' -%>Minor:<%= format_measure('minor_violations', :default => 0) -%>
+ + + + + + +
<%= image_tag 'priority/INFO.png' -%>Info:<%= format_measure('info_violations', :default => 0) -%>
+ <% end %> <%= render :partial => 'options' -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb index ab81eaae342..87460906560 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb @@ -40,7 +40,7 @@ <% first=false end %> - <% if @snapshot.project_snapshot.periods? %> + <% if @snapshot.project_snapshot.periods? && !@display_violations %> + + <%= violation_period_select_options(@snapshot, 1) -%> + <%= violation_period_select_options(@snapshot, 2) -%> + <%= violation_period_select_options(@snapshot, 3) -%> + <%= violation_period_select_options(@snapshot, 4) -%> + <%= violation_period_select_options(@snapshot, 5) -%> + + + <%= render :partial => 'rules_filter' -%> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb index 900711898b0..0bd942683bd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb @@ -1,16 +1,29 @@ <% - blocker_violations = @snapshot.measure('blocker_violations') + if @period + blocker_violations = @snapshot.measure('new_blocker_violations') + critical_violations = @snapshot.measure('new_critical_violations') + major_violations = @snapshot.measure('new_major_violations') + minor_violations = @snapshot.measure('new_minor_violations') + info_violations = @snapshot.measure('new_info_violations') + violation_metric_key='new_violations' + else + blocker_violations = @snapshot.measure('blocker_violations') critical_violations = @snapshot.measure('critical_violations') major_violations = @snapshot.measure('major_violations') minor_violations = @snapshot.measure('minor_violations') info_violations = @snapshot.measure('info_violations') + violation_metric_key='violations' + end rule_counts={} rules=[] - rule_measures=ProjectMeasure.find(:all, :include => 'rule', :conditions => ['metric_id=? AND snapshot_id=? AND rule_id IS NOT NULL AND characteristic_id IS NULL', Metric.by_key('violations').id, @snapshot.id]) + rule_measures=ProjectMeasure.find(:all, :include => 'rule', :conditions => ['metric_id=? AND snapshot_id=? AND rule_id IS NOT NULL AND characteristic_id IS NULL', Metric.by_key(violation_metric_key).id, @snapshot.id]) rule_measures.each do |rule_measure| - rule_counts[rule_measure.rule_id]=rule_measure.value.to_i - rules<0 + rule_counts[rule_measure.rule_id]=count.to_i + rules< - <% if blocker_violations && blocker_violations.value>0 %> - - <% end %> - <% if critical_violations && critical_violations.value>0 %> - - <% end %> - <% if major_violations && major_violations.value>0 %> - - <% end %> - <% if minor_violations && minor_violations.value>0 %> - - <% end %> - <% if info_violations && info_violations.value>0 %> - - <% end %> + <% if blocker_violations + value=(@period ? blocker_violations.variation(@period) : blocker_violations.value) + if value && value>0 + %> + + <% end + end %> + + <% if critical_violations + value=(@period ? critical_violations.variation(@period) : critical_violations.value) + if value && value>0 + %> + + <% end + end + %> + + <% if major_violations + value=(@period ? major_violations.variation(@period) : major_violations.value) + if value && value>0 + %> + + <% end + end + %> + + <% if minor_violations + value=(@period ? minor_violations.variation(@period) : minor_violations.value) + if value && value>0 + %> + + <% end + end + %> + + <% if info_violations + value=(@period ? info_violations.variation(@period) : info_violations.value) + if value && value>0 + %> + + <% end + end + %> + diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb index e4eb4bc335e..2fe57e4da47 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb @@ -64,7 +64,7 @@ <% if @display_scm if current_revision!=line.revision current_revision=line.revision - title = "Revision #{h(line.revision)} (#{l(line.datetime)})" + title = "Revision #{h(line.revision)} » #{l(line.datetime) if line.datetime}" %> <%= l(line.date) -%> <%= h(line.author) -%> <% else %> diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index d418289baf0..55d19caca73 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -757,7 +757,7 @@ span.rulename a:hover { vertical-align: top; } .tab_header table.bottomcol { - margin-right: 20px; + margin-right: 10px; display: inline-block; vertical-align: bottom; } -- 2.39.5