]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3354 Display empty table instead of message if no measures
authorFabrice Bellingard <bellingard@gmail.com>
Tue, 27 Mar 2012 08:34:42 +0000 (10:34 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Tue, 27 Mar 2012 08:34:42 +0000 (10:34 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties

index ea8e590b19421551113182656688f15edf14c46d..3d5f376e6c478fc29359c94f9e6af2cb8b929908 100644 (file)
@@ -1,10 +1,14 @@
 <%
+   rows_by_metric_id={}
+   
    # Retrieve widget settings
    metric_ids = []
    (1..10).each do |index|
      metric=widget_properties["metric#{index}"]
      if metric
        metric_ids << metric.id
+       row=Sonar::TimemachineRow.new(metric)
+       rows_by_metric_id[metric.id]=row
      end
    end
    if metric_ids.empty?
    )
 
    
-   if measures.size > 0
-     # Prepare the rows to display
-     snapshot_by_id={}
-     snapshots.each do |s|
-       snapshot_by_id[s.id]=s
-     end
-     rows_by_metric_id={}
-     measures.each do |measure|
-       next unless measure.metric
-
-       if measure.metric.timemachine? && (measure.value || measure.text_value)
-         row=rows_by_metric_id[measure.metric_id]
-         unless row
-           row=Sonar::TimemachineRow.new(measure.metric)
-           rows_by_metric_id[measure.metric_id]=row
-         end
+   # Prepare the rows to display
+   snapshot_by_id={}
+   snapshots.each do |s|
+     snapshot_by_id[s.id]=s
+   end
+   measures.each do |measure|
+     next unless measure.metric
 
-         #optimization : avoid eager loading of snapshots
-         measure.snapshot=snapshot_by_id[measure.snapshot_id]
-         row.add_measure(measure)
-       end
+     if measure.metric.timemachine? && (measure.value || measure.text_value)
+       row=rows_by_metric_id[measure.metric_id]
+       
+       #optimization : avoid eager loading of snapshots
+       measure.snapshot=snapshot_by_id[measure.snapshot_id]
+       row.add_measure(measure)
      end
+   end
 
-     # Create the list of rows to display in the same order as defined by the user
-     rows=[]
-     metric_ids.each do |metric_id|
-       row = rows_by_metric_id[metric_id]
-       if row
-         rows<<row
-       end
+   # Create the list of rows to display in the same order as defined by the user
+   rows=[]
+   metric_ids.each do |metric_id|
+     row = rows_by_metric_id[metric_id]
+     if row
+       rows<<row
      end
+   end
 
-     # Should display the sparkline?
-     sparkline_urls_by_row = {}
-     if widget_properties["displaySparkLine"]
-       rows.each do |row|
-         sparkline_url = row.sparkline_url
-         sparkline_urls_by_row[row] = sparkline_url if sparkline_url
-       end
+   # Should display the sparkline?
+   sparkline_urls_by_row = {}
+   if widget_properties["displaySparkLine"]
+     rows.each do |row|
+       sparkline_url = row.sparkline_url
+       sparkline_urls_by_row[row] = sparkline_url if sparkline_url
      end
-     display_sparkline = !sparkline_urls_by_row.empty?
+   end
+   display_sparkline = !sparkline_urls_by_row.empty?
 %>
 
 <div style="overflow: auto;font-size: 12px;padding: 1px;">
              sparkline_url = sparkline_urls_by_row[row]
         %>
           <td width="1%">
-            <%= image_tag(sparkline_url) %>
+            <%= image_tag(sparkline_url) if sparkline_url %>
           </td>
         <% end %>
       </tr>
   </table>
 
 </div>
-
-<% else %>
-
-<span class="empty_widget"><%= message('widget.time_machine.no_data_for_selected_metrics') -%></span>
-
-<% end %>
\ No newline at end of file
index dd803c7689349b0220b3ded2a8d52a6cabbe5527..d41cd3320c90d18f6999ee2b8ea8810d55725eff 100644 (file)
@@ -677,7 +677,6 @@ widget.timeline.timeline_not_displayed=No history
 
 widget.time_machine.name=History Table
 widget.time_machine.description=Displays up to 10 metrics in a table, showing their value for a specified number of past snapshots.
-widget.time_machine.no_data_for_selected_metrics=No data for selected metrics
 
 widget.ckjm.name=Chidamber & Kemerer
 widget.ckjm.description=Reports on LCOM4 and RFC average and distribution.