Fixed url_for() so that links/redirects to workbench records work as expected.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 25 Feb 2014 16:55:51 +0000 (11:55 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 25 Feb 2014 16:55:51 +0000 (11:55 -0500)
Can now click a "play" button next to a pipeline template and create a pipeline instance.

apps/workbench/Gemfile
apps/workbench/Gemfile.lock
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/models/arvados_base.rb
apps/workbench/app/views/application/_selection_checkbox.html.erb
apps/workbench/app/views/pipeline_templates/_show_recent.html.erb

index 66734ef3cd785971034751bc50a6329a41d9c808..6aecdeb7124152a43e414552d7001a604591ce82 100644 (file)
@@ -43,7 +43,7 @@ gem 'less-rails'
 # gem 'capistrano'
 
 # To use debugger
-# gem 'debugger'
+#gem 'byebug'
 
 gem 'rvm-capistrano', :group => :test
 
index 7f4dc8e289150c38165528556f504eb6372dfe4f..247fa30c38437c3fecd61bb3d4608a902eb6b74a 100644 (file)
@@ -36,6 +36,9 @@ GEM
     bootstrap-x-editable-rails (1.5.1.1)
       railties (>= 3.0)
     builder (3.0.4)
+    byebug (2.7.0)
+      columnize (~> 0.3)
+      debugger-linecache (~> 1.2)
     capistrano (2.15.5)
       highline
       net-scp (>= 1.0.0)
@@ -49,8 +52,10 @@ GEM
       coffee-script-source
       execjs
     coffee-script-source (1.6.3)
+    columnize (0.3.6)
     commonjs (0.2.7)
     daemon_controller (1.1.7)
+    debugger-linecache (1.2.0)
     erubis (2.7.0)
     execjs (2.0.2)
     highline (1.6.20)
@@ -152,6 +157,7 @@ DEPENDENCIES
   andand
   bootstrap-sass (~> 3.1.0)
   bootstrap-x-editable-rails
+  byebug
   coffee-rails (~> 3.2.0)
   httpclient
   jquery-rails
index 02ebc8b3a198090c83fe98e5c3f99f18c0993c9d..162fd2870550df5b7dbdf1e2e6628a3d50262449 100644 (file)
@@ -107,8 +107,9 @@ class ApplicationController < ActionController::Base
   end
 
   def create
-    @object ||= model_class.new params[model_class.to_s.singularize.to_sym]
+    @object ||= model_class.new params[model_class.to_s.underscore.singularize.to_sym]
     @object.save!
+
     respond_to do |f|
       f.html {
         redirect_to(params[:return_to] || @object)
index cd8e5279dd0bdf595bbce465c2c9b693c0385a53..48b6bb404d96a5286b5bab8c32684290293349c7 100644 (file)
@@ -67,7 +67,7 @@ module ApplicationHelper
         end
       end
       style_opts[:class] = (style_opts[:class] || '') + ' nowrap'
-      link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
+      link_to link_name, { controller: resource_class.to_s.tableize, action: 'show', id: link_uuid }, style_opts
     else
       attrvalue
     end
index f1d429486cd995ef09e8457da90cadb464f29b94..fbf7ee5e799e48a07c831d553733b8c56bca9855 100644 (file)
@@ -61,13 +61,16 @@ class ArvadosBase < ActiveRecord::Base
     attr_reader :kind
     @columns
   end
+
   def self.column(name, sql_type = nil, default = nil, null = true)
     ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
   end
+
   def self.attribute_info
     self.columns
     @attribute_info
   end
+
   def self.find(uuid, opts={})
     if uuid.class != String or uuid.length < 27 then
       raise 'argument to find() must be a uuid string. Acceptable formats: warehouse locator or string with format xxxxx-xxxxx-xxxxxxxxxxxxxxx'
@@ -84,21 +87,27 @@ class ArvadosBase < ActiveRecord::Base
     end
     new.private_reload(hash)
   end
+
   def self.order(*args)
     ArvadosResourceList.new(self).order(*args)
   end
+
   def self.where(*args)
     ArvadosResourceList.new(self).where(*args)
   end
+
   def self.limit(*args)
     ArvadosResourceList.new(self).limit(*args)
   end
+
   def self.eager(*args)
     ArvadosResourceList.new(self).eager(*args)
   end
+
   def self.all(*args)
     ArvadosResourceList.new(self).all(*args)
   end
+
   def save
     obdata = {}
     self.class.columns.each do |col|
@@ -128,8 +137,11 @@ class ArvadosBase < ActiveRecord::Base
       end
     end
 
+    @new_record = false
+
     self
   end
+
   def save!
     self.save or raise Exception.new("Save failed")
   end
@@ -169,6 +181,7 @@ class ArvadosBase < ActiveRecord::Base
     @links = $arvados_api_client.api Link, '', { _method: 'GET', where: o, eager: true }
     @links = $arvados_api_client.unpack_api_response(@links)
   end
+
   def all_links
     return @all_links if @all_links
     res = $arvados_api_client.api Link, '', {
@@ -181,9 +194,11 @@ class ArvadosBase < ActiveRecord::Base
     }
     @all_links = $arvados_api_client.unpack_api_response(res)
   end
+
   def reload
     private_reload(self.uuid)
   end
+
   def private_reload(uuid_or_hash)
     raise "No such object" if !uuid_or_hash
     if uuid_or_hash.is_a? Hash
@@ -206,8 +221,14 @@ class ArvadosBase < ActiveRecord::Base
       end
     end
     @all_links = nil
+    @new_record = false
     self
   end
+
+  def to_param
+    uuid
+  end
+
   def dup
     super.forget_uuid!
   end
index cb0ec829e7ae7ac80611efaf9978f0ee525fd920..4d47d892c56817386982489119855e25146c99bb 100644 (file)
@@ -1,6 +1,8 @@
+<%if object %>
 <%= check_box_tag 'uuids[]', object.uuid, false, {
   :class => 'persistent-selection', 
   :friendly_type => object.class.name,
   :friendly_name => object.selection_label,
   :href => "#{url_for controller: object.class.name.tableize, action: 'show', id: object.uuid }" 
 } %>
+<% end %>
index c389aa0a481194a41f23823572886ffc9b0ce9c4..f878f5980664c4b775d7386bc7c437832864b1d9 100644 (file)
@@ -1,7 +1,22 @@
+<% content_for :css do %>
+  .playbutton {
+  color: white;
+  background: gray;
+  border: 0px;
+  border-radius: 3px;
+  padding: 0px 3px;
+  }
+  .playbutton:hover {
+  color: white;
+  background: blackh;
+  }
+<% end %>
+
 <table class="table table-hover">
   <thead>
     <tr class="contain-align-left">
       <th>
+      </th><th>
        id
       </th><th>
        name
     <% @objects.sort_by { |ob| ob[:created_at] }.reverse.each do |ob| %>
 
     <tr>
+      <td>
+        <%= form_tag '/pipeline_instances' do |f| %>
+          <%= hidden_field :pipeline_instance, :pipeline_template_uuid, :value => ob.uuid %>
+          <%= button_tag nil, {class: 'playbutton'} do %>
+            <span class="glyphicon glyphicon-play"></span>
+          <% end %>
+        <% end %>
+      </td>
       <td>
         <%= link_to_if_arvados_object ob %>
       </td><td>