ref: refs/heads/master commit 6d590ef794aee8e4861e5022393d30cb384fdd1f Author: Stefan Schubert <schubi@suse.de> Date: Thu Jul 23 15:43:10 2009 +0200 showing limits in nicer format --- .../status/app/controllers/status_controller.rb | 18 +++++ plugins/status/app/helpers/status_helper.rb | 8 ++- plugins/status/app/views/status/index.html.erb | 78 ++++++++++++++++++- 3 files changed, 97 insertions(+), 7 deletions(-) diff --git a/plugins/status/app/controllers/status_controller.rb b/plugins/status/app/controllers/status_controller.rb index 114c57a..325a133 100644 --- a/plugins/status/app/controllers/status_controller.rb +++ b/plugins/status/app/controllers/status_controller.rb @@ -154,6 +154,24 @@ class StatusController < ApplicationController def index return unless client_permissions create_data + @limit_hits = [] + @data_group.each do |key, map| + map.each do |graph_key, list_value| + limit_key = "/#{key}/#{graph_key}" + if @limits_list.has_key?(limit_key) + cmp_value = @limits_list[limit_key][0][1] #take thatone cause it has already the right format + #( e.g. MByte for memory) + list_value.each do |value| + if (@limits[limit_key]["maximum"] && value[1]>= cmp_value) || + (!@limits[limit_key]["maximum"] && value[1]<= cmp_value) + @limit_hits << limit_key + break + end + end + end + end + end + logger.debug "limits reached for #{@limit_hits.inspect}" end diff --git a/plugins/status/app/helpers/status_helper.rb b/plugins/status/app/helpers/status_helper.rb index ad1a785..aa77cde 100644 --- a/plugins/status/app/helpers/status_helper.rb +++ b/plugins/status/app/helpers/status_helper.rb @@ -1,6 +1,10 @@ module StatusHelper - def graph id, width, height, last = false - html = "<div id='#{id}' style='width:#{width}px;height:#{height}px;float:left'><img src='/images/spinner.gif'></div>" + def graph id, width, height, last = false, error = false + if error + html = "<div id='#{id}' style='width:#{width}px;height:#{height}px;float:left;border:solid 2px red;'><img src='/images/spinner.gif'></div>" + else + html = "<div id='#{id}' style='width:#{width}px;height:#{height}px;float:left;'><img src='/images/spinner.gif'></div>" + end html += "<br style='clear: both'>" if last return html end diff --git a/plugins/status/app/views/status/index.html.erb b/plugins/status/app/views/status/index.html.erb index 12db9d1..88ca7b5 100644 --- a/plugins/status/app/views/status/index.html.erb +++ b/plugins/status/app/views/status/index.html.erb @@ -19,7 +19,7 @@ <% list_value = map[graph_key] %> <% if key != "df" || !graph_key.end_with?("used") %> <% graph_id = key + "_" + graph_key.tr('/','_') %> - <%= graph(graph_id, 200, 150, column == 4?true:false) %> + <%= graph(graph_id, 200, 150, column == 4?true:false, @limit_hits.include?("/" + key + "/" + graph_key)&&key=="df") %> <% if column == 4 %> <br> <% column = 1 %> @@ -62,13 +62,37 @@ function plotPieGraph (graph_id, graph_title, graph_data ) { }); } +function plotPieGraphError (graph_id, graph_title, graph_data ) { + $.jqplot(graph_id, [graph_data], { + title: { + text: graph_title, + textColor: '#FF0000' + }, + legend: { + show: true + }, + seriesDefaults: { + renderer: $.jqplot.PieRenderer, + rendererOptions: { + sliceMargin: 0, + diameter: 100 + } + }, + + cursor: { + show: false + }, + }); +} + + function plotLineGraph(graph_id, graph_title, graph_data ) { $.jqplot(graph_id, graph_data, { title: graph_title, axes: { xaxis: { - showTicks: false + showTicks: false, }, yaxis: { showTicks: true, @@ -90,6 +114,42 @@ function plotLineGraph(graph_id, graph_title, graph_data ) { }); } +function plotLineGraphError(graph_id, graph_title, graph_data ) { + $.jqplot(graph_id, graph_data, { + title: { + text: graph_title, + textColor: '#FF0000' + }, + grid: { + borderColor: '#FF0000' + }, + axes: { + xaxis: { + showTicks: false, + borderColor: '#FF0000' + }, + yaxis: { + showTicks: true, + min: 0, + borderColor: '#FF0000' + } + }, + series:[{color:'#FF0000', + lineWidth: 1, + markerOptions: { + size: 0 + } + }, + {color:'#E89120', + lineWidth: 1, + markerOptions: { + size: 0 + } + }] + }); +} + + $(function() { <% @data_group.each do |key, map| %> <% map.each do |graph_key, list_value| %> @@ -97,10 +157,18 @@ function plotLineGraph(graph_id, graph_title, graph_data ) { <% if key != "df" %> $('#' + '<%= graph_id %>').html(""); <% limit_key = "/#{key}/#{graph_key}" %> - <% if @limits_list.has_key?(limit_key) %> - plotLineGraph('<%= graph_id %>', '<%= graph_key.tr('/','_').tr('_',' ').capitalize %>', [<%= list_value.inspect %>, <%= @limits_list[limit_key].inspect %>]); + <% if @limits_list.has_key?(limit_key) %> + <% if @limit_hits.include?(limit_key) %> + plotLineGraphError('<%= graph_id %>', '<%= graph_key.tr('/','_').tr('_',' ').capitalize %>', [<%= list_value.inspect %>, <%= @limits_list[limit_key].inspect %>]); + <% else %> + plotLineGraph('<%= graph_id %>', '<%= graph_key.tr('/','_').tr('_',' ').capitalize %>', [<%= list_value.inspect %>, <%= @limits_list[limit_key].inspect %>]); + <% end %> <% else %> - plotLineGraph('<%= graph_id %>', '<%= graph_key.tr('/','_').tr('_',' ').capitalize %>', [<%= list_value.inspect %>]); + <% if @limit_hits.include?(limit_key) %> + plotLineGraphError('<%= graph_id %>', '<%= graph_key.tr('/','_').tr('_',' ').capitalize %>', [<%= list_value.inspect %>]); + <% else %> + plotLineGraph('<%= graph_id %>', '<%= graph_key.tr('/','_').tr('_',' ').capitalize %>', [<%= list_value.inspect %>]); + <% end %> <% end %> <% else %> <% if graph_key.end_with?("free") %> -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org