incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962161 - in /incubator/deltacloud/trunk/server: app/controllers/ app/views/instance_states/ config/initializers/ public/stylesheets/ public/stylesheets/sass/
Date Thu, 08 Jul 2010 23:29:48 GMT
Author: lutter
Date: Thu Jul  8 23:29:47 2010
New Revision: 962161

URL: http://svn.apache.org/viewvc?rev=962161&view=rev
Log:
Integrate FSM picture.

Added:
    incubator/deltacloud/trunk/server/app/views/instance_states/show.gv.erb
Modified:
    incubator/deltacloud/trunk/server/app/controllers/instance_states_controller.rb
    incubator/deltacloud/trunk/server/app/views/instance_states/show.html.erb
    incubator/deltacloud/trunk/server/config/initializers/mime_types.rb
    incubator/deltacloud/trunk/server/public/stylesheets/application.css
    incubator/deltacloud/trunk/server/public/stylesheets/sass/application.sass

Modified: incubator/deltacloud/trunk/server/app/controllers/instance_states_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/app/controllers/instance_states_controller.rb?rev=962161&r1=962160&r2=962161&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/app/controllers/instance_states_controller.rb (original)
+++ incubator/deltacloud/trunk/server/app/controllers/instance_states_controller.rb Thu Jul
 8 23:29:47 2010
@@ -15,6 +15,8 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+require 'open3'
+
 class InstanceStatesController < ApplicationController
 
   include DriverHelper
@@ -29,6 +31,18 @@ class InstanceStatesController < Applica
       format.html
       format.json
       format.xml
+      format.gv
+      format.png {
+        gv = render_to_string( :file=>'instance_states/show.gv.erb' )
+        png =  ''
+        cmd = 'dot -Gsize="7.7,7" -Tpng'
+        Open3.popen3( cmd ) do |stdin, stdout, stderr|
+          stdin.write( gv )
+          stdin.close()
+          png = stdout.read
+        end
+        render :text=>png, :content_type=>'image/png'
+      }
     end
   end
 

Added: incubator/deltacloud/trunk/server/app/views/instance_states/show.gv.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/app/views/instance_states/show.gv.erb?rev=962161&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/app/views/instance_states/show.gv.erb (added)
+++ incubator/deltacloud/trunk/server/app/views/instance_states/show.gv.erb Thu Jul  8 23:29:47
2010
@@ -0,0 +1,37 @@
+digraph instance_states {
+  rankdir=LR;
+  <% for state in @machine.states do %>
+    <%= state -%> 
+      [
+        label="<%= state %>",
+        labelloc="t",
+        <% if ( state.name == :start || state.name == :finish ) %>
+          fontname="Liberation Sans Bold",
+          color="<%= state.name == :start ? 'darkgreen' : 'red' %>",
+          style="bold",
+          fontsize="15.0",
+        <% else %>
+          fontname="Liberation Sans",
+          shape="rectangle",
+          fontsize="20.0",
+        <% end %>
+      ]
+  <% end %>
+
+  <% for state in @machine.states do %>
+    <% for transition in state.transitions do %>
+      <%= state %> -> <%= transition.destination %> 
+        [ 
+          label="<%= transition.automatically? ? 'auto' : transition.action %>",
+          fontsize="20",
+          labelloc="t",
+          <% if transition.automatically? %>
+          fontcolor="darkgreen",
+          fontname="Liberation Sans Bold Italic",
+          <% else %>
+          fontname="Liberation Sans Bold",
+          <% end %>
+        ];
+    <% end %>
+  <% end %>
+}

Modified: incubator/deltacloud/trunk/server/app/views/instance_states/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/app/views/instance_states/show.html.erb?rev=962161&r1=962160&r2=962161&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/app/views/instance_states/show.html.erb (original)
+++ incubator/deltacloud/trunk/server/app/views/instance_states/show.html.erb Thu Jul  8 23:29:47
2010
@@ -1,6 +1,10 @@
 
 <h1>States</h1>
 
+<div id="state_graph">
+  <%= image_tag url_for( :format=>:png ) %>
+</div>
+
 <table class="states">
   <tr>
     <th>
@@ -46,3 +50,4 @@
     <% end %>
   <% end %>
 </table>
+

Modified: incubator/deltacloud/trunk/server/config/initializers/mime_types.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/config/initializers/mime_types.rb?rev=962161&r1=962160&r2=962161&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/config/initializers/mime_types.rb (original)
+++ incubator/deltacloud/trunk/server/config/initializers/mime_types.rb Thu Jul  8 23:29:47
2010
@@ -3,3 +3,8 @@
 # Add new mime types for use in respond_to blocks:
 # Mime::Type.register "text/richtext", :rtf
 # Mime::Type.register_alias "text/html", :iphone
+
+#Mime::Type.register 'text/vnd.graphviz', :gv
+Mime::Type.register_alias 'text/plain', :gv
+
+Mime::Type.register 'image/png', :png

Modified: incubator/deltacloud/trunk/server/public/stylesheets/application.css
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/stylesheets/application.css?rev=962161&r1=962160&r2=962161&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/public/stylesheets/application.css (original)
+++ incubator/deltacloud/trunk/server/public/stylesheets/application.css Thu Jul  8 23:29:47
2010
@@ -89,3 +89,8 @@ input[type='radio'] {
   margin-top: 1ex;
   margin-left: 1ex;
   margin-bottom: 1ex; }
+
+#state_graph {
+  display: block;
+  margin-bottom: 2em;
+  text-align: center; }

Modified: incubator/deltacloud/trunk/server/public/stylesheets/sass/application.sass
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/stylesheets/sass/application.sass?rev=962161&r1=962160&r2=962161&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/public/stylesheets/sass/application.sass (original)
+++ incubator/deltacloud/trunk/server/public/stylesheets/sass/application.sass Thu Jul  8
23:29:47 2010
@@ -101,3 +101,9 @@ input[type='radio']
   :margin-top 1ex
   :margin-left 1ex
   :margin-bottom 1ex
+
+#state_graph
+  :display block
+  :margin-bottom 2em
+  :text-align center
+  



Mime
View raw message