[Ovirt-devel] [PATCH server] Add fallback message when flexchart is missing

Steve Linabery
Fri, 24 Jul 2009 19:50:37 -0000

Check filesystem to see if flexchart.swf is present. If not,
offer location of precompiled swf hosted at ovirt.org.
---
 src/app/helpers/graph_helper.rb          |    9 +++++++++
 src/app/views/graph/history_graphs.rhtml |    7 +++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/app/helpers/graph_helper.rb b/src/app/helpers/graph_helper.rb
index bb1f05b..c57ddda 100644
--- a/src/app/helpers/graph_helper.rb
+++ b/src/app/helpers/graph_helper.rb
@@ -1,5 +1,14 @@
 module GraphHelper

+    def swf_is_present
+
File.exists?(Rails.root.join('public','swfs','flexchart.swf'))
+    end
+
+    def swf_bits_download_url
+        "http://ovirt.org/flexchart/flexchart.swf"
+    end
+
+
     # generate some json for the snapshot graph
     def snapshot_graph_json(target, snapshots)
         data = snapshots[:avg][target]
diff --git a/src/app/views/graph/history_graphs.rhtml
b/src/app/views/graph/history_graphs.rhtml
index 7a7e1e1..2683952 100644
--- a/src/app/views/graph/history_graphs.rhtml
+++ b/src/app/views/graph/history_graphs.rhtml
@@ -1,4 +1,7 @@
 <%= javascript_include_tag "jquery.flash.js" %>
+
+<% if swf_is_present %>
+


 $(document).ready(function(){
@@ -16,3 +19,7 @@ $('#flex_history_chart').flash(
     );
 });

+
+<% else %>
+ Missing Performance Chart
(/swfs/flexchart.swf), which can be obtained at <%=
link_to(swf_bits_download_url,swf_bits_download_url) %>
+<% end %>
--
1.6.0.6