]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3354 Display an explicit message if no measure is available
authorFabrice Bellingard <bellingard@gmail.com>
Fri, 23 Mar 2012 15:41:26 +0000 (16:41 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Fri, 23 Mar 2012 15:41:26 +0000 (16:41 +0100)
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 91526be032b6bbaa51f1e911bbc1d8733b801767..ea8e590b19421551113182656688f15edf14c46d 100644 (file)
                                     ]
    )
 
-   # And 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 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
+       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
 
-       #optimization : avoid eager loading of snapshots
-       measure.snapshot=snapshot_by_id[measure.snapshot_id]
-       row.add_measure(measure)
+         #optimization : avoid eager loading of snapshots
+         measure.snapshot=snapshot_by_id[measure.snapshot_id]
+         row.add_measure(measure)
+       end
      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
+     # 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
-   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
+     # 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
      end
-   end
-   display_sparkline = !sparkline_urls_by_row.empty?
+     display_sparkline = !sparkline_urls_by_row.empty?
 %>
 
 <div style="overflow: auto;font-size: 12px;padding: 1px;">
 
   </table>
 
-</div>
\ No newline at end of file
+</div>
+
+<% else %>
+
+<span class="empty_widget"><%= message('widget.time_machine.no_data_for_selected_metrics') -%></span>
+
+<% end %>
\ No newline at end of file
index d41cd3320c90d18f6999ee2b8ea8810d55725eff..dd803c7689349b0220b3ded2a8d52a6cabbe5527 100644 (file)
@@ -677,6 +677,7 @@ 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.