[PATCH/foreman 1/1] statistics pie is now a thumbnail that expand in a modal dialog

Signed-off-by: Amos Benari <abenari@redhat.com>

··· --- app/helpers/application_helper.rb | 1 + app/helpers/statistics_helper.rb | 20 ++++++------ app/views/statistics/index.html.erb | 12 +++--- public/javascripts/application.js | 61 ----------------------------------- public/javascripts/charts.js | 55 +++++++++++++++++++++++++++++-- public/stylesheets/style.css | 6 ++-- 6 files changed, 71 insertions(+), 84 deletions(-)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e8b7d40…fd84968 100644
— a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -162,6 +162,7 @@ module ApplicationHelper
end

def pie_chart name, title, data, options = {}

  • content_tag(:h4,title,:class=>‘ca’) +
    content_tag(:div, nil,
    { :id => name,
    :class => ‘statistics_pie’,
    diff --git a/app/helpers/statistics_helper.rb b/app/helpers/statistics_helper.rb
    index f687ef9…d654e1f 100644
    — a/app/helpers/statistics_helper.rb
    +++ b/app/helpers/statistics_helper.rb
    @@ -1,16 +1,16 @@
    module StatisticsHelper
  • def charts
  • options = {:class => “statistics_pie small”, :expandable => true, :‘border’ => 0, :show_title => false}
    [
  •  pie_chart("os_dist" ,"OS Distribution", @os_count, :class => "statistics_pie small"),
    
  •  pie_chart("arch_dist" ,"Architecture Distribution", @arch_count, :class => "statistics_pie small"),
    
  •  pie_chart("env_dist" ,"Environments Distribution", @env_count, :class => "statistics_pie small"),
    
  •  pie_chart("cpu_num" ,"Number of CPUs", @cpu_count, :class => "statistics_pie small"),
    
  •  pie_chart("hardware" ,"Hardware", @model_count, :class => "statistics_pie small"),
    
  •  pie_chart("class_dist" ,"Class Distribution", @klass_count, :class => "statistics_pie small"),
    
  •  pie_chart("mem_usage" ,"Average memory usage", [["free memory (GB)",@mem_free],["used memory (GB)",@mem_size-@mem_free]], :class => "statistics_pie small"),
    
  •  pie_chart("swap_usage" ,"Average swap usage", [["free swap (GB)",@swap_free],["used swap (GB)",@swap_size-@swap_free]], :class => "statistics_pie small"),
    
  •  pie_chart("mem_totals" ,"Total memory usage", [["free memory (GB)", @mem_totfree],["used memory (GB)",@mem_totsize-@mem_totfree]], :class => "statistics_pie small"),
    
  •  pie_chart("os_dist" ,"OS Distribution", @os_count, options),
    
  •  pie_chart("arch_dist" ,"Architecture Distribution", @arch_count, options),
    
  •  pie_chart("env_dist" ,"Environments Distribution", @env_count, options),
    
  •  pie_chart("cpu_num" ,"Number of CPUs", @cpu_count,options),
    
  •  pie_chart("hardware" ,"Hardware", @model_count, options),
    
  •  pie_chart("class_dist" ,"Class Distribution", @klass_count, options),
    
  •  pie_chart("mem_usage" ,"Average memory usage", [["free memory (GB)",@mem_free],["used memory (GB)",@mem_size-@mem_free]], options),
    
  •  pie_chart("swap_usage" ,"Average swap usage", [["free swap (GB)",@swap_free],["used swap (GB)",@swap_size-@swap_free]], options),
    
  •  pie_chart("mem_totals" ,"Total memory usage", [["free memory (GB)", @mem_totfree],["used memory (GB)",@mem_totsize-@mem_totfree]],options),
    
    ]
    end
    end
    diff --git a/app/views/statistics/index.html.erb b/app/views/statistics/index.html.erb
    index 14876bb…91807ce 100644
    — a/app/views/statistics/index.html.erb
    +++ b/app/views/statistics/index.html.erb
    @@ -1,7 +1,7 @@
    -<% charts.in_groups(3,nil) do |ch| -%>
  • <% ch.each do |c| -%>
  •  <div class="span-one-third"><%= c %></div>
    
  • <% end -%>

+


\ No newline at end of file
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 3e45e0c…4d9cec6 100644
— a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -68,65 +68,6 @@ function template_info(div, url) {
}
});
}

-function get_pie_chart(div, url) {

-function pie_chart(div, title, data) {

$(document).ready(function() {
var common_settings = {
method : ‘PUT’,
@@ -177,8 +118,6 @@ $(document).ready(function() {
};
$(this).editable($(this).attr(‘data-url’), $.extend(common_settings, settings));
});

});

// adds buttons classes to all links
diff --git a/public/javascripts/charts.js b/public/javascripts/charts.js
index 40186fe…caf053c 100644
— a/public/javascripts/charts.js
+++ b/public/javascripts/charts.js
@@ -3,9 +3,12 @@ $(function(){
var el = $(element);
var name = el.attr(‘chart-name’);
var title = el.attr(‘chart-title’);

$(".statistics_bar").each(function(index, element){
@@ -46,12 +49,56 @@ $(function(){

});

-function stat_pie(name, title, data) {

+function get_pie_chart(div, url) {

+function stat_pie(name, title, data, border, expandable, show_title) {

diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css
index 700a658…48c55f8 100644
— a/public/stylesheets/style.css
+++ b/public/stylesheets/style.css
@@ -182,9 +182,8 @@ table.list td {
border: solid 1px #f00;
}
.statistics_pie.small{

.fixed-width{table-layout:fixed;}
+select{padding: initial;}

[class*=“tbl-column”]{ overflow: hidden; white-space: nowrap;}
table th.small{width:60px; max-width:60px;}

1.7.4.2