[ARVADOS] updated: cf1e0b3f31b643899b556c3c7ae59630a0ec7495

git at public.curoverse.com git at public.curoverse.com
Wed Feb 26 17:09:24 EST 2014


Summary of changes:
 apps/workbench/Gemfile                             |    1 +
 apps/workbench/Gemfile.lock                        |    2 +
 apps/workbench/app/assets/javascripts/editable.js  |    1 +
 apps/workbench/app/assets/javascripts/selection.js |   50 +++++++++++++++++-
 .../controllers/pipeline_instances_controller.rb   |   35 ++++++++++++-
 apps/workbench/app/helpers/application_helper.rb   |   54 ++++++++++++++------
 apps/workbench/app/models/pipeline_instance.rb     |    2 +-
 .../pipeline_instances/_show_components.html.erb   |   53 +++++++++-----------
 8 files changed, 150 insertions(+), 48 deletions(-)

       via  cf1e0b3f31b643899b556c3c7ae59630a0ec7495 (commit)
      from  52838f7dfc576e8a11411fd9f1710a758573a6e7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit cf1e0b3f31b643899b556c3c7ae59630a0ec7495
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Feb 26 17:10:37 2014 -0500

    Editing input values of pipeline_instances mostly works, but needs polishing.

diff --git a/apps/workbench/Gemfile b/apps/workbench/Gemfile
index 6aecdeb..6ae12f7 100644
--- a/apps/workbench/Gemfile
+++ b/apps/workbench/Gemfile
@@ -54,3 +54,4 @@ gem 'RedCloth'
 gem 'piwik_analytics'
 gem 'httpclient'
 gem 'themes_for_rails'
+gem "deep_merge", :require => 'deep_merge/rails_compat'
\ No newline at end of file
diff --git a/apps/workbench/Gemfile.lock b/apps/workbench/Gemfile.lock
index 7f4dc8e..c7ffeb0 100644
--- a/apps/workbench/Gemfile.lock
+++ b/apps/workbench/Gemfile.lock
@@ -51,6 +51,7 @@ GEM
     coffee-script-source (1.6.3)
     commonjs (0.2.7)
     daemon_controller (1.1.7)
+    deep_merge (1.0.1)
     erubis (2.7.0)
     execjs (2.0.2)
     highline (1.6.20)
@@ -153,6 +154,7 @@ DEPENDENCIES
   bootstrap-sass (~> 3.1.0)
   bootstrap-x-editable-rails
   coffee-rails (~> 3.2.0)
+  deep_merge
   httpclient
   jquery-rails
   less
diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/editable.js
index 804eeb2..29cf2b8 100644
--- a/apps/workbench/app/assets/javascripts/editable.js
+++ b/apps/workbench/app/assets/javascripts/editable.js
@@ -1,5 +1,6 @@
 $.fn.editable.defaults.ajaxOptions = {type: 'put', dataType: 'json'};
 $.fn.editable.defaults.send = 'always';
+//$.fn.editable.defaults.mode = 'inline';
 $.fn.editable.defaults.params = function (params) {
     var a = {};
     var key = params.pk.key;
diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js
index 29c52d6..d4af321 100644
--- a/apps/workbench/app/assets/javascripts/selection.js
+++ b/apps/workbench/app/assets/javascripts/selection.js
@@ -4,8 +4,9 @@
 /** Javascript for local persistent selection. */
 
 get_selection_list = null;
+form_selection_sources = {};
 
-(function($){
+jQuery(function($){
     var storage = localStorage; // sessionStorage
 
     get_selection_list = function() {
@@ -110,4 +111,49 @@ get_selection_list = null;
 
 
     $(window).on('load storage', update_count);
-})(jQuery);
\ No newline at end of file
+});
+
+add_form_selection_sources = null;
+select_form_sources  = null;
+
+(function() {
+    var form_selection_sources = {};
+    add_form_selection_sources = function (src) {
+        for (var i = 0; i < src.length; i++) {
+            var t = form_selection_sources[src[i].type];
+            if (!t) {
+                t = form_selection_sources[src[i].type] = {};
+            }
+            if (!t[src[i].uuid]) {
+                t[src[i].uuid] = src[i];
+            }
+        }
+    };
+
+    select_form_sources = function(type) {
+        var ret = [];
+
+        if (get_selection_list) {
+            var lst = get_selection_list();
+            if (lst.length > 0) {
+                ret.push({text: "--- Selections ---", value: ""});
+
+                for (var i = 0; i < lst.length; i++) {
+                    if (lst[i].type == type) {
+                        ret.push({text: lst[i].name, value: lst[i].uuid})
+                    }
+                }
+            }
+        }
+        ret.push({text: "--- Recent ---", value: ""});
+
+        var t = form_selection_sources[type];
+        for (var key in t) {
+            if (t.hasOwnProperty(key)) {
+                var obj = t[key];
+                ret.push({text: obj.name, value: obj.uuid})
+            }
+        }
+        return ret;
+    };
+})();
\ No newline at end of file
diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb
index a8a35b5..0922017 100644
--- a/apps/workbench/app/controllers/pipeline_instances_controller.rb
+++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb
@@ -47,7 +47,31 @@ class PipelineInstancesController < ApplicationController
   def show
     if @object.components.empty? and @object.pipeline_template_uuid
       template = PipelineTemplate.find(@object.pipeline_template_uuid)
-      @object.components= template.components
+      pipeline = {}
+      template.components.each do |component_name, component_props|
+        pipeline[component_name] = {}
+        component_props.each do |k, v|
+          if k == :script_parameters
+            pipeline[component_name][:script_parameters] = {}
+            v.each do |param_name, param_value|
+              if param_value.is_a? Hash
+                if param_value[:value]
+                  pipeline[component_name][:script_parameters][param_name] = param_value[:value]
+                elsif param_value[:optional] and param_value.length == 1
+                    pipeline[component_name][:script_parameters][param_name] = ""
+                else
+                  pipeline[component_name][:script_parameters][param_name] = param_value
+                end
+              else
+                pipeline[component_name][:script_parameters][param_name] = param_value
+              end
+            end
+          else
+            pipeline[component_name][k] = v
+          end
+        end
+      end
+      @object.components= pipeline
       @object.save
     end
 
@@ -147,6 +171,15 @@ class PipelineInstancesController < ApplicationController
     %w(Compare Graph)
   end 
 
+  def update
+    updates = params[@object.class.to_s.underscore.singularize.to_sym]
+    if updates["components"]
+      require 'deep_merge/rails_compat'
+      updates["components"] = updates["components"].deeper_merge(@object.components)
+    end
+    super
+  end
+
   protected
   def for_comparison v
     if v.is_a? Hash or v.is_a? Array
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index b669042..921122f 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -108,39 +108,59 @@ module ApplicationHelper
   def render_editable_subattribute(object, attr, subattr, template, htmloptions={})
     attrvalue = object.send(attr)
     subattr.each do |k|
-      attrvalue = attrvalue[k]
+      if attrvalue and attrvalue.is_a? Hash
+        attrvalue = attrvalue[k]
+      else
+        break
+      end
     end
 
     datatype = nil
     if template
+      puts "Template is #{template.class} #{template.is_a? Hash} #{template}"
       if template.is_a? Hash
         if template[:output_of]
-          return "Output of \"#{template[:output_of]}\""
+          return raw("<span class='label label-default'>#{template[:output_of]}</span>")
         elsif template[:datatype]
           datatype = template[:datatype]
         end
-      elsif attrvalue == nil
-        attrvalue = template
       end
     end
 
     return attrvalue if !object.attribute_editable? attr
 
     if not datatype
-      dataclass = ArvadosBase.resource_class_for_uuid(attrvalue)
+      dataclass = ArvadosBase.resource_class_for_uuid(template)
       if dataclass
         datatype = 'select'
       else
-        if /^\d+$/.match(attrvalue) 
-          datatype = 'number'
-        elsif
-          datatype = 'text'
+        if template.is_a? Array
+          # ?!?
+        elsif template.is_a? String
+          if /^\d+$/.match(template)
+            datatype = 'number'
+          else
+            datatype = 'text'
+          end
         end
       end
     end
 
-    subattr.insert(0, attr)
     id = "#{object.uuid}-#{subattr.join('-')}"
+    dn = "[#{attr}]"
+    subattr.each do |a|
+      dn += "[#{a}]"
+    end
+
+    if dataclass
+      items = []
+      dataclass.where(uuid: attrvalue).each do |item|
+        items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
+      end
+      dataclass.limit(19).each do |item|
+        items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
+      end
+    end
 
     lt = link_to attrvalue, '#', {
       "data-emptytext" => "none",
@@ -148,17 +168,21 @@ module ApplicationHelper
       "data-type" => datatype,
       "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
       "data-title" => "Update #{subattr[-1].to_s.titleize}",
-      "data-name" => subattr.to_json,
+      "data-name" => dn,
+      "data-value" => attrvalue,
       "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
       :class => "editable",
       :id => id
     }.merge(htmloptions)
 
-    lt += raw(%{
-<script>
-  $('##{id}').editable({source: select_#{dataclass}_source});
-</script>})
+    lt += raw(<<EOF
 
+<script>
+    add_form_selection_sources(#{items.to_json});
+    $('##{id}').editable({source: function() { return select_form_sources('#{dataclass}'); } });
+</script>
+EOF
+)
     lt 
   end
 end
diff --git a/apps/workbench/app/models/pipeline_instance.rb b/apps/workbench/app/models/pipeline_instance.rb
index 14eb89a..ccb8835 100644
--- a/apps/workbench/app/models/pipeline_instance.rb
+++ b/apps/workbench/app/models/pipeline_instance.rb
@@ -16,7 +16,7 @@ class PipelineInstance < ArvadosBase
       end
     end
   end
-
+  
   def attribute_editable?(attr)
     attr.to_sym == :name || (attr.to_sym == :components and self.active == nil)
   end
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
index 395ef77..4a39c19 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -23,19 +23,6 @@ table.pipeline-components-table td {
 
 <% end %>
 
-<% content_for :js do %>
-  function select_Collection_source() {
-    var ret = [];
-    var lst = get_selection_list();
-    for (var i = 0; i < lst.length; i++) {
-      if (lst[i].type == 'Collection') {
-        ret.push({text: lst[i].name, value: lst[i].uuid})
-      }
-    }
-    return ret;
-  };
-<% end %>
-
 <% if @object.active != nil %>
 <table class="table pipeline-components-table">
   <colgroup>
@@ -62,11 +49,23 @@ table.pipeline-components-table td {
     <% render_pipeline_jobs.each do |pj| %>
     <tr>
       <td>
+        <% label = if pj[:job].andand[:uuid] 
+                       if pj[:job][:running]
+                         'label-info'
+                       elsif pj[:job][:success]
+                         'label-success'
+                       else
+                         'label-danger'
+                       end 
+                     else
+                       'label-default'
+                     end %>
         <% if pj[:job].andand[:uuid] %>
-        <%= link_to pj[:name], job_url(id: pj[:job][:uuid]) %>
+        <%= link_to pj[:name], job_url(id: pj[:job][:uuid]), class: "label #{label}" %>
         <% else %>
-        <%= pj[:name] %>
+          <span class="label <%= label %>"><%= pj[:name] %></span>
         <% end %>
+        </span>
       </td><td>
         <%= pj[:script] %>
         <br /><span class="deemphasize"><%= pj[:script_version] %></span>
@@ -117,7 +116,7 @@ setInterval(function(){$('a.refresh').click()}, 30000);
       <th>
         component
       </th><th>
-        script, version
+        script
       </th><th>
         parameter
       </th><th>
@@ -129,32 +128,28 @@ setInterval(function(){$('a.refresh').click()}, 30000);
     <% template = PipelineTemplate.find(@object.pipeline_template_uuid) %>
     <% template.components.each do |k, v| %>
 
-    <% sp = v[:script_parameters].collect do |k, v| [k, v] end %>
+    <% sp = v[:script_parameters].collect do |x, y| [x, y] end %>
 
     <tr>
-      <td><%= k %></td>
+      <td><span class="label label-default"><%= k %></span></td>
 
-      <td><%= v[:script] %>
-        <br /><span class="deemphasize"> <%= v[:script_version] %></span>
-      </td>
+      <td><%= v[:script] %></td>
 
-      <td>
-        <%= sp[0][0] %>
-      </td>
+      <td>script_version</td>
 
       <td>
-        <%= render_editable_subattribute @object, :components, [k, :script_parameters, sp[0][0].to_sym], sp[0][1] %>
+        <%= render_editable_subattribute @object, :components, [k, :script_version], v[:script_version] %>
       </td>
-      </tr>
+    </tr>
 
-    <% if sp.length > 1 %>
+    <% if sp.length > 0 %>
     <tr>
       <td style="border-top: none"></td>
       <td style="border-top: none"></td>
 
-      <% sp[1..-1].each do |p| %>
+      <% sp.each do |p| %>
         <td><%= p[0] %></td>
-        <td><%= p[1] %></td>
+        <td><%= render_editable_subattribute @object, :components, [k, :script_parameters, p[0].to_sym], p[1] %></td>
       <% end %>
     </tr>
   <% end %>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list