Jason Guiditta
2008-Aug-27 21:11 UTC
[Ovirt-devel] [PATCH] Sprint 6 - remove svg bar graphs, replace with css.
NOTE: This is only for graphs in a flexigrid, as they did not have the arrow, which will be more problematic if not impossible to do with css (though maybe with js). Load average for host is based on 5 (apparently this is some agreed-upon temporary scale). There is no real load for vm pools in the database, so these are stubbed out for now. Signed-off-by: Jason Guiditta <jguiditt at redhat.com> --- wui/src/app/controllers/hardware_controller.rb | 2 +- wui/src/app/views/host/_grid.rhtml | 6 +++++- wui/src/app/views/resources/_grid.rhtml | 7 ++++++- wui/src/public/javascripts/ovirt.js | 7 +++++++ wui/src/public/stylesheets/components.css | 6 ++++++ wui/src/public/stylesheets/flexigrid/flexigrid.css | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/wui/src/app/controllers/hardware_controller.rb b/wui/src/app/controllers/hardware_controller.rb index 019fdd8..5d6f07b 100644 --- a/wui/src/app/controllers/hardware_controller.rb +++ b/wui/src/app/controllers/hardware_controller.rb @@ -139,7 +139,7 @@ class HardwareController < ApplicationController attr_list << :id if params[:checkboxes] attr_list << :hostname attr_list << [:hardware_pool, :name] if include_pool - attr_list += [:uuid, :hypervisor_type, :num_cpus, :cpu_speed, :arch, :memory_in_mb, :status_str, :id] + attr_list += [:uuid, :hypervisor_type, :num_cpus, :cpu_speed, :arch, :memory_in_mb, :status_str, :load_average] json_list(hosts, attr_list, [:all], find_opts) end diff --git a/wui/src/app/views/host/_grid.rhtml b/wui/src/app/views/host/_grid.rhtml index ac24e0c..553adf9 100644 --- a/wui/src/app/views/host/_grid.rhtml +++ b/wui/src/app/views/host/_grid.rhtml @@ -54,7 +54,11 @@ } function <%= table_id %>_load_widget(celDiv) { - load_widget(celDiv, "host"); + var loadAvg = getAverage($(celDiv).html()); + var loadCss = (loadAvg >50) ? "load_graph_high" : "load_graph_low"; + $(celDiv).html('<div title="' + loadAvg + '% Load" \n\ + class="load_graph ' + loadCss + '" \n\ + style="width: ' + loadAvg + '%;"></div>'); }; </script> diff --git a/wui/src/app/views/resources/_grid.rhtml b/wui/src/app/views/resources/_grid.rhtml index 301a7aa..908eac7 100644 --- a/wui/src/app/views/resources/_grid.rhtml +++ b/wui/src/app/views/resources/_grid.rhtml @@ -35,7 +35,12 @@ } function <%= table_id %>_load_widget(celDiv) { - load_widget(celDiv, "resource"); + //FIXME: there is no real data save for vmpool load, so stub out for now + var loadAvg = getAverage(2.3); + var loadCss = (loadAvg >50) ? "load_graph_high" : "load_graph_low"; + $(celDiv).html('<div title="' + loadAvg + '% Load" \n\ + class="load_graph ' + loadCss + '" \n\ + style="width: ' + loadAvg + '%;"></div>'); }; </script> diff --git a/wui/src/public/javascripts/ovirt.js b/wui/src/public/javascripts/ovirt.js index 829738f..3a0d83a 100644 --- a/wui/src/public/javascripts/ovirt.js +++ b/wui/src/public/javascripts/ovirt.js @@ -28,6 +28,13 @@ function validate_selected(selected_array, name) } } +function getAverage(val) { + if (isNaN(val)) return 0; + //FIXME: currently using a magic number of 5 which should be replaced + //with comething more meaningful. + return (val/5 < 1) ? ((val/5) * 100) : 100; +} + function add_hosts(url) { hosts= get_selected_checkboxes("addhosts_grid_form") diff --git a/wui/src/public/stylesheets/components.css b/wui/src/public/stylesheets/components.css index 56cadf2..16eaf62 100644 --- a/wui/src/public/stylesheets/components.css +++ b/wui/src/public/stylesheets/components.css @@ -253,8 +253,14 @@ /* load graphs in flexigrid */ .load_graph { + padding: 0px !important; + height: 10px; + border:#F5AFA8 solid 1px; } +.load_graph_low {background: url(../images/chart_horiz_blue.png) repeat-x;} +.load_graph_high {background: url(../images/chart_horiz_orange.png) repeat-x;} + /************************* * details pane style * *************************/ diff --git a/wui/src/public/stylesheets/flexigrid/flexigrid.css b/wui/src/public/stylesheets/flexigrid/flexigrid.css index f8f8037..cd1902f 100644 --- a/wui/src/public/stylesheets/flexigrid/flexigrid.css +++ b/wui/src/public/stylesheets/flexigrid/flexigrid.css @@ -469,7 +469,7 @@ div.colCopy { .flexigrid div.bDiv td { border-bottom: 1px solid #fff; - vertical-align: top; + /*vertical-align: top;*/ white-space: nowrap; } -- 1.5.5.1