From 5214bb3dcde1171a6ae8aa289c46eb9d44e417af Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 18 Jun 2014 11:43:04 +0200 Subject: [PATCH] SONAR-5149 Improve display of Stats -> Done the same way it's done on widget --- .../resources/org/sonar/l10n/core.properties | 2 + .../WEB-INF/app/views/profiles/show.html.erb | 130 +++++++----------- 2 files changed, 54 insertions(+), 78 deletions(-) diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 36814f63f5a..43edcb32e8c 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1623,6 +1623,8 @@ quality_profiles.copy_x_title=Copy Profile {0} quality_profiles.copy_new_name=New name quality_profiles.restore_built_in_profiles=Restore Built-in Profiles quality_profiles.restore_built_in_profiles_confirmation=Are you sure you want to restore '{0}' profile(s) for '{1}' ? +quality_profiles.including=including +quality_profiles.deprecated=deprecated #------------------------------------------------------------------------------ # diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb index 2d3c5accc13..b9818a6f0c5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb @@ -2,88 +2,62 @@ <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Rules'} %>
-

- <% active_rules = @stats.get('countActiveRules').get(0).getValue() if @stats && @stats.get('countActiveRules') %> - <% active_rules ||= 0 %> - "><%= active_rules -%> <%= message('coding_rules._rules') -%> -

- <% if @stats %> + <% active_rules = @stats.get('countActiveRules').get(0).getValue() if @stats && @stats.get('countActiveRules') %> + <% active_rules ||= 0 %> - <% if @deprecated_active_rules > 0 %> -
- - <% - key = 'DEPRECATED' - status = key.downcase - value = @deprecated_active_rules - -%> - - - - -
- <%= message('rules.status.' + status).upcase -%> - - "><%= value -%> -
- <% end -%> +
+
+
+ <%= message('rules') -%> + + "> + <%= active_rules -%> + + - <% inheritance = @stats.get('inheritance') - if inheritance.size > 1 - inheritance_stats = Hash[ *@stats.get('inheritance').collect { |v| [ v.getKey(), v ] }.flatten ] -%> -
- - <% if inheritance_stats['NONE'] %> - - - - - <% end -%> - <% if inheritance_stats['INHERITED'] %> - - - - - <% end -%> - <% if inheritance_stats['OVERRIDES'] %> - - - - - <% end -%> -
- <%= message('coding_rules.filters.inheritance.not_inherited') -%> - - <%= inheritance_stats['NONE'].getValue() -%> -
- <%= message('coding_rules.filters.inheritance.inherited') -%> - - <%= inheritance_stats['INHERITED'].getValue() -%> -
- <%= message('coding_rules.filters.inheritance.overriden') -%> - - <%= inheritance_stats['OVERRIDES'].getValue() -%> -
- <% end -%> +
+ <% if @deprecated_active_rules > 0 %> +
+ <%= message('quality_profiles.including') %> "><%= @deprecated_active_rules -%> <%= message('quality_profiles.deprecated') %> +
+ <% end %> +
+
-
+ <% if @stats + severity_stats = @stats.get('severity') + severity_map = Hash[ *severity_stats.collect { |v| [ v.getKey(), v ] }.flatten ] - - <% @stats.get('severity').each do |stat| - key = stat.getKey() - severity = stat.getKey().downcase - value = stat.getValue() - -%> - - - - - <% end -%> -
- <%= message(severity) -%> - - "><%= value -%> -
+ max = severity_stats.map { |val| val.getValue() }.max + %> +
+
+
+ + <% Severity::KEYS.each do |key| + stat = severity_map[key] + severity = key.downcase + value = 0 + value = stat.getValue() if stat + -%> + + + + + + <% end -%> +
+ <%= message(severity) -%> + + "><%= value -%> + + <% if max > 0 %> + <%= barchart(:width => 70, :percent => (100 * value / max).to_i) %> + <% end %> +
+
+
+
<% end -%>
-- 2.39.5