]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3825 ability to customize treemap
authorSimon Brandhof <simon.brandhof@gmail.com>
Sun, 2 Dec 2012 08:08:40 +0000 (09:08 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Sun, 2 Dec 2012 08:08:40 +0000 (09:08 +0100)
sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb
sonar-server/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/measures/_sidebar.html.erb
sonar-server/src/main/webapp/images/cross-gray.png [new file with mode: 0644]
sonar-server/src/main/webapp/stylesheets/layout.css
sonar-server/src/main/webapp/stylesheets/select2.css

index 4ae790d9307810a2e0cdd714bc1c7be1a73f0786..5ca58e8c3ca27ad2fb788e292384d5005772f1f4 100644 (file)
@@ -28,13 +28,13 @@ class MeasureFilterDisplayTreemap < MeasureFilterDisplay
     super(filter, options)
 
     @size_metric = Metric.by_key(@filter.criteria('tmSize')||'ncloc')
-    @color_metric = Metric.by_key(@filter.criteria('tmColor')||'violations_density')
+    @color_metric = Metric.by_key(@filter.criteria('tmColor'))
     @html_id = options[:html_id]
     @filter.metrics=([@size_metric, @color_metric].compact)
     @height = (@filter.criteria('tmHeight')||'600').to_i
     @id_count = 0
 
-    filter.set_criteria_value('sort', "metric:#{@size_metric.key}")
+    filter.set_criteria_value('sort', "metric:#{@size_metric.key}") if @size_metric
     filter.set_criteria_value('asc', 'true')
     filter.pagination.per_page = 500
     filter.pagination.page = 1
@@ -64,7 +64,7 @@ class MeasureFilterDisplayTreemap < MeasureFilterDisplay
   private
 
   def build_tree(node)
-    if @filter.results
+    if @filter.results && @size_metric
       @filter.results.each do |result|
         size_measure=result.measure(@size_metric)
         if size_measure
index 589eb1fb02f8bccd7d3e7e58e0a23b01904f46e9..a3dc044f302b39a8fa95efa5d0829632abd4a2d4 100644 (file)
                   <span class="note"><%= human_short_date s.created_at -%></span>
 
                   <div style="width: 100%; text-align: center;">
-                    <a href="#" onclick="removeFromList(<%= index -%>, $j('#sids'))"><img src="<%= ApplicationController.root_context -%>/images/controls/cross.png" title="<%= message('comparison.remove_resource') -%>"/></a>
+                    <a href="#" onclick="removeFromList(<%= index -%>, $j('#sids'))"><img src="<%= ApplicationController.root_context -%>/images/cross-gray.png" title="<%= message('comparison.remove_resource') -%>"/></a>
                   </div>
                 </td>
                 <td class="thin" style="vertical-align: bottom;">
                 <% if index < last_index %>
                   <a href="#" onclick="moveDown(<%= index -%>)"><img src="<%= ApplicationController.root_context -%>/images/controls/move_down.png" title="<%= message('comparison.move_down') -%>"/></a>
                 <% end %>
-                <a href="#" onclick="removeFromList(<%= index -%>, $j('#metrics'))"><img src="<%= ApplicationController.root_context -%>/images/controls/cross.png" title="<%= message('comparison.remove_metric') -%>"/></a>
+                <a href="#" onclick="removeFromList(<%= index -%>, $j('#metrics'))"><img src="<%= ApplicationController.root_context -%>/images/cross-gray.png" title="<%= message('comparison.remove_metric') -%>"/></a>
               </div>
             </td>
 
index 54128af8d8648132b7576cd8f6584fe18e38305f..e97a0ad8b6eef52c635aa94d28622126fe7f16c5 100644 (file)
   %>
 
 <% if edit_mode %>
-  <table class="data width100 admin">
+  <table class="spaced width100 admin">
     <tr>
       <td>
-        <%= metric_select_tag 'metric', Metric.all.reject { |m| m.data? },
+        <%= metric_select_tag 'metric', Metric.all.reject { |m| m.hidden || m.data? },
                               :html_id => 'select-metric',
                               :allow_empty => true,
                               :key_prefix => 'metric:',
index 9f9fce68896cd6400dea4511e6c1932ae90cd831..36455b848fa86055c06c088b76dd7c8ece579fbd 100644 (file)
@@ -1,3 +1,50 @@
+<% if edit_mode %>
+  <table class="spaced width100 admin">
+    <tr>
+      <td valign="top" class="thin nowrap">
+        <span class="comments"><%= message('size') -%></span>
+        <br/>
+        <%= metric_select_tag 'tmSize', Metric.all.select { |m| m.treemap_size? },
+                              :html_id => 'select-tm-size',
+                              :selected_key => @filter.display.size_metric.key -%>
+      </td>
+      <td valign="top" class="thin nowrap">
+        <span class="comments"><%= message('color') -%></span>
+        <span id="tm-gradient" class="note"></span>
+        <br/>
+        <%= metric_select_tag 'tmColor', Metric.all.select { |m| m.treemap_color? },
+                              :html_id => 'select-tm-color',
+                              :allow_empty => true,
+                              :selected_key => (@filter.display.color_metric ? @filter.display.color_metric.key : nil) -%>
+
+        <button id="update-treemap">Update</button>
+      </td>
+      <td class="right" valign="bottom">
+        <a href="#" class="button" id="exit-edit">Done</a>
+      </td>
+    </tr>
+  </table>
+  <% content_for :script do %>
+    <script>
+      $j(document).ready(function () {
+        $j("#update-treemap").on("click", function (e) {
+          var url = removeUrlAttr(decodeURI(window.location.href), 'tmSize');
+          url = removeUrlAttr(url, 'tmColor');
+          url += '&tmSize=' + $j('#select-tm-size').val();
+          var color = $j('#select-tm-color').val();
+          if (color != null && color != '') {
+            url += '&tmColor=' + color;
+          }
+          window.location = url;
+        });
+        $j("#exit-edit").on("click", function (e) {
+          window.location = removeUrlAttr(decodeURI(window.location.href), 'edit');
+        });
+      });
+    </script>
+  <% end %>
+<% end %>
+
 <div class="treemap" style="width: 100%; height:<%= @filter.display.height %>px;">
   <%= @filter.display.html -%>
 </div>
\ No newline at end of file
index 2d8b5a07a54601a81ed550a0566be320bc65eb8b..8625a0c55dec5e08be3f3ce86410605f75a7afd3 100644 (file)
       <%= check_box_tag 'onFavourites', 'true', @filter.criteria['onFavourites']=='true' -%>
     </li>
 
-    <% condition_metrics = Metric.all.select { |m| m.numeric? } %>
+    <% condition_metrics = Metric.all.select { |m| m.numeric? && !m.hidden } %>
     <% for i in 1..3 %>
       <li id="criteria-metric-<%= i -%>" style="<%= "display: none" if hidden_condition_indexes.include?(i) -%>">
         <%= metric_select_tag "c#{i}_metric", condition_metrics, :allow_empty => true, :selected_key => @filter.criteria("c#{i}_metric"), :width => '100%', :placeholder => 'Metric' -%>
diff --git a/sonar-server/src/main/webapp/images/cross-gray.png b/sonar-server/src/main/webapp/images/cross-gray.png
new file mode 100644 (file)
index 0000000..16ec36b
Binary files /dev/null and b/sonar-server/src/main/webapp/images/cross-gray.png differ
index 240cbc0f254ec79a42055c484c5a571e908ce773..30fae43d0dbdb5bbef5a34fc172627a717e059b3 100644 (file)
@@ -265,6 +265,10 @@ ul.sidebar li.spacer {
   margin: 0;
   padding: 0;
 }
+ul.sidebar select, ul.sidebar input {
+  font-size: 93%;
+}
+
 
 #logo {
   text-align: center;
index 746c8993703a7ae7754fd23925e505ff008216f8..4b5d4efddca68cd4b944b78bf17d93fca935ab5b 100755 (executable)
@@ -48,9 +48,10 @@ Version: 3.2 Timestamp: Mon Sep 10 10:38:04 PDT 2012
   white-space: nowrap;
   position: relative;
 
-  /* sonar: reduce height */
+  /* sonar: reduce height and font-size */
   height: 20px;
   line-height: 20px;
+  font-size: 93%;
   padding: 0 0 0 8px;
   color: #444;
   text-decoration: none;