]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5149 Improve display of Stats -> Done the same way it's done on widget
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 18 Jun 2014 09:43:04 +0000 (11:43 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 18 Jun 2014 09:43:13 +0000 (11:43 +0200)
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb

index 36814f63f5a2e0fd40068c6ce0200dce51037a14..43edcb32e8c4c445fd03400d34651206a3874741 100644 (file)
@@ -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
 
 #------------------------------------------------------------------------------
 #
index 2d3c5accc13579fb2ca88a46a670209ebefa3671..b9818a6f0c597fff6477eba066143b063a4dd5fe 100644 (file)
@@ -2,88 +2,62 @@
   <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Rules'} %>
 
   <div class="tabs-panel marginbottom10 ">
-    <p>
-      <% active_rules = @stats.get('countActiveRules').get(0).getValue() if @stats && @stats.get('countActiveRules') %>
-      <% active_rules ||= 0 %>
-      <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}" -%>"><%= active_rules -%> <%= message('coding_rules._rules') -%></a>
-    </p>
-    <% if @stats %>
+    <% active_rules = @stats.get('countActiveRules').get(0).getValue() if @stats && @stats.get('countActiveRules') %>
+    <% active_rules ||= 0 %>
 
-      <% if @deprecated_active_rules > 0 %>
-        <br/>
-        <table class="data" style="width:120px">
-          <%
-            key = 'DEPRECATED'
-            status = key.downcase
-            value = @deprecated_active_rules
-          -%>
-          <tr>
-            <td>
-              <%= message('rules.status.' + status).upcase -%>
-            </td>
-            <td class="thin left">
-              <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|statuses=#{key}" -%>"><%= value -%></a>
-            </td>
-          </tr>
-        </table>
-      <% end -%>
+    <div class="widget-span widget-span-3">
+      <div class="widget-measure-container">
+        <div class="widget-measure widget-measure-main">
+          <span class="widget-label"><%= message('rules') -%></span>
+          <span nowrap>
+            <a class="widget-link" href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}" -%>">
+              <span><%= active_rules -%></span>
+            </a>
+          </span>
 
-      <% inheritance = @stats.get('inheritance')
-         if inheritance.size > 1
-           inheritance_stats = Hash[ *@stats.get('inheritance').collect { |v| [ v.getKey(), v ] }.flatten ] -%>
-        <br/>
-        <table class="data" style="width:120px">
-            <% if inheritance_stats['NONE'] %>
-              <tr>
-                <td>
-                  <%= message('coding_rules.filters.inheritance.not_inherited') -%>
-                </td>
-                <td class="thin left">
-                  <%= inheritance_stats['NONE'].getValue() -%>
-                </td>
-              </tr>
-            <% end -%>
-            <% if inheritance_stats['INHERITED'] %>
-              <tr>
-                <td>
-                  <%= message('coding_rules.filters.inheritance.inherited') -%>
-                </td>
-                <td class="thin left">
-                  <%= inheritance_stats['INHERITED'].getValue() -%>
-                </td>
-              </tr>
-            <% end -%>
-            <% if inheritance_stats['OVERRIDES'] %>
-              <tr>
-                <td>
-                  <%= message('coding_rules.filters.inheritance.overriden') -%>
-                </td>
-                <td class="thin left">
-                  <%= inheritance_stats['OVERRIDES'].getValue() -%>
-                </td>
-              </tr>
-            <% end -%>
-        </table>
-      <% end -%>
+        </div>
+        <% if @deprecated_active_rules > 0 %>
+          <div class="widget-measure">
+            <%= message('quality_profiles.including') %>&nbsp;<a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|statuses=DEPRECATED" -%>"><%= @deprecated_active_rules -%></a>&nbsp;<%= message('quality_profiles.deprecated') %>
+          </div>
+        <% end %>
+      </div>
+    </div>
 
-      <br/>
+    <% if @stats
+         severity_stats = @stats.get('severity')
+         severity_map = Hash[ *severity_stats.collect { |v| [ v.getKey(), v ] }.flatten ]
 
-      <table class="data" style="width:120px">
-        <% @stats.get('severity').each do |stat|
-          key = stat.getKey()
-          severity = stat.getKey().downcase
-          value = stat.getValue()
-        -%>
-          <tr>
-            <td>
-              <i class="icon-severity-<%= severity %>"></i><%= message(severity) -%>
-            </td>
-            <td class="thin left">
-              <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|severities=#{key}" -%>"><%= value -%></a>
-            </td>
-          </tr>
-        <% end -%>
-      </table>
+         max = severity_stats.map { |val| val.getValue() }.max
+      %>
+      <div class="widget-span widget-span-3">
+        <div class="widget-measure-container">
+          <div class="widget-measure widget-measure-main">
+            <table class="data" style="width:120px">
+              <% Severity::KEYS.each do |key|
+                stat = severity_map[key]
+                severity = key.downcase
+                value = 0
+                value = stat.getValue() if stat
+              -%>
+                <tr>
+                  <td>
+                    <i class="icon-severity-<%= severity %>"></i><%= message(severity) -%>
+                  </td>
+                  <td class="thin left">
+                    <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|severities=#{key}" -%>"><%= value -%></a>
+                  </td>
+                  <td class="nowrap">
+                    <% if max > 0 %>
+                      <%= barchart(:width => 70, :percent => (100 * value / max).to_i) %>
+                    <% end %>
+                  </td>
+                </tr>
+              <% end -%>
+            </table>
+          </div>
+        </div>
+      </div>
     <% end -%>
   </div>
 </div>