10079: reuse objects and address the case where no uuid exists on a chile (not started).
authorradhika <radhika@curoverse.com>
Tue, 18 Oct 2016 22:18:09 +0000 (18:18 -0400)
committerradhika <radhika@curoverse.com>
Tue, 18 Oct 2016 22:18:09 +0000 (18:18 -0400)
apps/workbench/app/assets/javascripts/work_unit_component.js
apps/workbench/app/controllers/work_units_controller.rb
apps/workbench/app/models/proxy_work_unit.rb
apps/workbench/app/models/work_unit.rb
apps/workbench/app/views/work_units/_show_child.html.erb
apps/workbench/config/routes.rb

index 3a3dead276e401c2e3a20fb5d3815ca3b8d0e2de..d068d89367931755d815e9247da9db1389340926 100644 (file)
@@ -7,7 +7,8 @@ $(document).
 
       var content_div = href.find('.work-unit-component-detail-body');
       var content_url = href.attr('content-url');
-      $.ajax(content_url, {dataType: 'html'}).
+      var action_data = href.attr('action-data');
+      $.ajax(content_url, {dataType: 'html', type: 'POST', data: {action_data}}).
           done(function(data, status, jqxhr) {
               content_div.html(data);
           }).fail(function(jqxhr, status, error) {
index dd2dd825e7b7e51d0b2fcc3e896ac1fad4e5579a..b5cf7ea3e3f26027cbc7063169956ee4c7d75ec6 100644 (file)
@@ -113,18 +113,23 @@ class WorkUnitsController < ApplicationController
   end
 
   def show_component
-    @object ||= object_for_dataclass resource_class_for_uuid(params['main_obj']), params['main_obj']
-
-    resource_class = resource_class_for_uuid params['wu']
-    obj = object_for_dataclass(resource_class, params['wu'])
-    if resource_class == Job
-      wu = JobWorkUnit.new(obj, params['name'])
-    elsif resource_class == PipelineInstance
-      wu = PipelineInstanceWorkUnit.new(obj, params['name'])
-    elsif resource_class == Container or resource_class == ContainerRequest
-      wu = ContainerWorkUnit.new(obj, params['name'])
+    data = JSON.load(params[:action_data])
+
+    current_obj = data['current_obj']
+    current_obj_type = data['current_obj_type']
+    if current_obj_type == JobWorkUnit.to_s
+      current_obj = arvados_api_client.unpack_api_response current_obj, 'arvados#job'
+      wu = JobWorkUnit.new(current_obj, params['name'])
+    elsif current_obj_type == PipelineInstanceWorkUnit.to_s
+      current_obj = arvados_api_client.unpack_api_response current_obj, 'arvados#pipelineInstance'
+      wu = PipelineInstanceWorkUnit.new(current_obj, params['name'])
+    elsif current_obj_type == ContainerWorkUnit.to_s
+      current_obj = arvados_api_client.unpack_api_response current_obj, 'arvados#containerRequest'
+      wu = ContainerWorkUnit.new(current_obj, params['name'])
     end
 
+    @object ||= arvados_api_client.unpack_api_response data['main_obj'], data['main_obj_kind']
+
     respond_to do |f|
       f.html { render(partial: "show_component", locals: {wu: wu}) }
     end
index 44905be061d9808d58b34950d9fa0d36edac1bb2..321370a5f51f936367078a7d84292d00e10b8ff2 100644 (file)
@@ -15,6 +15,10 @@ class ProxyWorkUnit < WorkUnit
     @lbl
   end
 
+  def proxied
+    @proxied
+  end
+
   def uuid
     get(:uuid)
   end
index 0c384bb209d905f0e8d3efa164c79383b0088059..727180ecfa8ab23d02b38a2ffe7f7665606e6c8f 100644 (file)
@@ -5,6 +5,10 @@ class WorkUnit
     # returns the label that was assigned when creating the work unit
   end
 
+  def proxied
+    # returns the proxied object of this work unit
+  end
+
   def uuid
     # returns the arvados UUID of the underlying object
   end
index 823b5cf816952e4a8f3c1b8c352d6afb721be3fa..f6a6a6997c4add6fdcb4057153215f27a952b914 100644 (file)
@@ -51,8 +51,8 @@
   </div>
 
   <% name = if current_obj.respond_to?('name') then current_obj.name else '' end %>
-  <% content_url = url_for(controller: :work_units, action: :show_component, wu: current_obj.uuid,  name: name, main_obj: @object.uuid) %>
-  <div id="collapse<%=i%>" class="work-unit-component-detail panel-collapse collapse <%= if expanded then 'in' end %>" content-url="<%=content_url%>">
+  <% content_url = url_for(controller: :work_units, action: :show_component, name: name, main_obj: @object.uuid) %>
+  <div id="collapse<%=i%>" class="work-unit-component-detail panel-collapse collapse <%= if expanded then 'in' end %>" content-url="<%=content_url%>" action-data="<%={current_obj_type: current_obj.class.to_s, current_obj: current_obj.proxied, main_obj: @object, main_obj_kind: @object.kind}.to_json%>">
     <div class="panel-body work-unit-component-detail-body">
     </div>
   </div>
index 5ac72fcb0cde6ba96454929429770b048e04ae8b..d5f341a5750bc8efd5779e3a327ee85abbb55198 100644 (file)
@@ -16,7 +16,7 @@ ArvadosWorkbench::Application.routes.draw do
   get "all_processes" => 'work_units#index', :as => :all_processes
   get "choose_work_unit_templates" => 'work_unit_templates#choose', :as => :choose_work_unit_templates
   resources :work_units
-  get "work_units_show_component" => 'work_units#show_component', :as => :work_units_show_component
+  post "work_units_show_component" => 'work_units#show_component', :as => :work_units_show_component
   resources :nodes
   resources :humans
   resources :traits