[Ovirt-devel] [PATCH] Remove svg bar graphs, replace with css.
Mohammed Morsi
mmorsi at redhat.com
Fri Sep 5 12:18:08 UTC 2008
Mohammed Morsi wrote:
> Jason Guiditta wrote:
>
>> 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 091ce97..a366e4c 100644
>> --- a/wui/src/app/controllers/hardware_controller.rb
>> +++ b/wui/src/app/controllers/hardware_controller.rb
>> @@ -150,7 +150,7 @@ class HardwareController < PoolController
>> 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 9a0d4b7..af0b9f6 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;
>> +}
>> +
>>
>>
> Just wondering why the value 5 was chosen to divide by, was this an
> arbitrary decision?
>
Scratch that, I should learn to read comments ;-p
>
>
>> 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;
>> }
>>
>>
>>
> Everything thats there looks good, so ACK. I believe you missed the load
> graph on the resource pool / virtual machines tab though.
>
> -Mo
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20080905/680b40d7/attachment.htm>
More information about the ovirt-devel
mailing list