diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-07-29 17:12:05 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-07-29 17:12:11 +0200 |
commit | a3ce51c43bdb2e684dfc863e9e9f4435238ec206 (patch) | |
tree | 79d45272609e6a55416738fd14cf84d796de1528 /plugins | |
parent | 7ab793b20adc4143b8f0ac84c9d8d7c54fc06aa9 (diff) | |
download | sonarqube-a3ce51c43bdb2e684dfc863e9e9f4435238ec206.tar.gz sonarqube-a3ce51c43bdb2e684dfc863e9e9f4435238ec206.zip |
SONAR-5482 The list of languages in the "Size" widget can be too long on views
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb index 7ee4fb0e229..8ea173543c5 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb @@ -32,13 +32,13 @@ <% if ncloc_language_dist_hash %> <% if ncloc_language_dist_hash.size > 1 %> - <table class="data widget-barchar"> + <table class="data widget-barchar" id="size-widget-language-dist"> <% - max = ncloc_language_dist_hash.max_by{|_k,v| v.to_i}[1].to_i + max = Math.sqrt(ncloc_language_dist_hash.max_by{|_k,v| v.to_i}[1].to_i) - # Sort lines language distribution by language name + # Sort lines language distribution by lines count languages_by_key = Hash[languages.collect { |l| [l.getKey(), l.getName] }] - ncloc_language_dist_hash.sort {|v1,v2| (languages_by_key[v1[0]] ? languages_by_key[v1[0]].to_s : v1[0]) <=> (languages_by_key[v2[0]] ? languages_by_key[v2[0]].to_s : v2[0]) }.each do |language_key, language_ncloc| + ncloc_language_dist_hash.sort {|v1,v2| v2[1].to_i <=> v1[1].to_i }.each do |language_key, language_ncloc| %> <tr> <td> @@ -49,11 +49,25 @@ <%= ncloc.format_numeric_value(language_ncloc) %> </td> <td> - <%= barchart(:width => 70, :percent => (40 * language_ncloc.to_i / max).to_i) %> + <%= barchart(:width => 70, :percent => (40 * Math.sqrt(language_ncloc.to_i) / max).to_i) %> </td> </tr> <% end %> </table> + <script> + jQuery(function () { + var chart = jQuery('#size-widget-language-dist'), + count = chart.find('tr').length; + if (count > 3) { + chart.find('tr:gt(2)').hide(); + var moreLinkBox = jQuery('<div></div>').addClass('widget-barchart-more').insertAfter(chart), + moreLink = jQuery('<a><%= message('more') -%></a>').appendTo(moreLinkBox).on('click', function () { + jQuery(this).hide(); + chart.find('tr').show(); + }); + } + }); + </script> <% else %> <% language_key = ncloc_language_dist_hash.first[0] |