From: radhika Date: Sun, 23 Oct 2016 01:47:51 +0000 (-0400) Subject: 10079: add "parent" to work_unit to aid the child display X-Git-Tag: 1.1.0~635^2~1 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/8d6ffdf2fba938e7fbb5f128664d828d2669bcfe 10079: add "parent" to work_unit to aid the child display --- diff --git a/apps/workbench/app/controllers/work_units_controller.rb b/apps/workbench/app/controllers/work_units_controller.rb index a7d0feb7d0..fe6bff1cee 100644 --- a/apps/workbench/app/controllers/work_units_controller.rb +++ b/apps/workbench/app/controllers/work_units_controller.rb @@ -128,21 +128,37 @@ class WorkUnitsController < ApplicationController def show_child_component data = JSON.load(params[:action_data]) - current_obj = data['current_obj'] - current_obj_type = data['current_obj_type'] + current_obj = {} + current_obj_uuid = data['current_obj_uuid'] current_obj_name = data['current_obj_name'] - if current_obj['uuid'] - resource_class = resource_class_for_uuid current_obj['uuid'] - obj = object_for_dataclass(resource_class, current_obj['uuid']) + current_obj_type = data['current_obj_type'] + current_obj_parent = data['current_obj_parent'] + if current_obj_uuid + resource_class = resource_class_for_uuid current_obj_uuid + obj = object_for_dataclass(resource_class, current_obj_uuid) current_obj = obj if obj end - if current_obj_type == JobWorkUnit.to_s - wu = JobWorkUnit.new(current_obj, current_obj_name) - elsif current_obj_type == PipelineInstanceWorkUnit.to_s - wu = PipelineInstanceWorkUnit.new(current_obj, current_obj_name) - elsif current_obj_type == ContainerWorkUnit.to_s - wu = ContainerWorkUnit.new(current_obj, current_obj_name) + if current_obj.is_a?(Hash) and !current_obj.any? + if current_obj_parent + resource_class = resource_class_for_uuid current_obj_parent + parent = object_for_dataclass(resource_class, current_obj_parent) + parent_wu = parent.work_unit + children = parent_wu.children + if current_obj_uuid + wu = children.select {|c| c.uuid == current_obj_uuid}.first + else current_obj_name + wu = children.select {|c| c.label.to_s == current_obj_name}.first + end + end + else + if current_obj_type == JobWorkUnit.to_s + wu = JobWorkUnit.new(current_obj, current_obj_name, current_obj_parent) + elsif current_obj_type == PipelineInstanceWorkUnit.to_s + wu = PipelineInstanceWorkUnit.new(current_obj, current_obj_name, current_obj_parent) + elsif current_obj_type == ContainerWorkUnit.to_s + wu = ContainerWorkUnit.new(current_obj, current_obj_name, current_obj_parent) + end end respond_to do |f| diff --git a/apps/workbench/app/models/container.rb b/apps/workbench/app/models/container.rb index 0a7c288718..e683a6e4f2 100644 --- a/apps/workbench/app/models/container.rb +++ b/apps/workbench/app/models/container.rb @@ -4,6 +4,6 @@ class Container < ArvadosBase end def work_unit(label=nil) - ContainerWorkUnit.new(self, label) + ContainerWorkUnit.new(self, label, self.uuid) end end diff --git a/apps/workbench/app/models/container_request.rb b/apps/workbench/app/models/container_request.rb index 0148de51f7..aae712b343 100644 --- a/apps/workbench/app/models/container_request.rb +++ b/apps/workbench/app/models/container_request.rb @@ -12,6 +12,6 @@ class ContainerRequest < ArvadosBase end def work_unit(label=nil) - ContainerWorkUnit.new(self, label) + ContainerWorkUnit.new(self, label, self.uuid) end end diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb index b6e72dc526..88aab306ce 100644 --- a/apps/workbench/app/models/container_work_unit.rb +++ b/apps/workbench/app/models/container_work_unit.rb @@ -1,7 +1,7 @@ class ContainerWorkUnit < ProxyWorkUnit attr_accessor :container - def initialize proxied, label + def initialize proxied, label, parent super if @proxied.is_a?(ContainerRequest) container_uuid = get(:container_uuid) @@ -12,7 +12,7 @@ class ContainerWorkUnit < ProxyWorkUnit end def children - return self.my_children if self.my_children + return @my_children if @my_children container_uuid = nil container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end @@ -25,7 +25,7 @@ class ContainerWorkUnit < ProxyWorkUnit end end - self.my_children = items + @my_children = items end def title diff --git a/apps/workbench/app/models/job.rb b/apps/workbench/app/models/job.rb index bf202c4eaa..7bfed6d44b 100644 --- a/apps/workbench/app/models/job.rb +++ b/apps/workbench/app/models/job.rb @@ -54,6 +54,6 @@ class Job < ArvadosBase end def work_unit(label=nil) - JobWorkUnit.new(self, label) + JobWorkUnit.new(self, label, self.uuid) end end diff --git a/apps/workbench/app/models/job_task.rb b/apps/workbench/app/models/job_task.rb index 9fb04737ba..654e0a37e0 100644 --- a/apps/workbench/app/models/job_task.rb +++ b/apps/workbench/app/models/job_task.rb @@ -1,5 +1,5 @@ class JobTask < ArvadosBase def work_unit(label=nil) - JobTaskWorkUnit.new(self, label) + JobTaskWorkUnit.new(self, label, self.uuid) end end diff --git a/apps/workbench/app/models/pipeline_instance.rb b/apps/workbench/app/models/pipeline_instance.rb index 62bbc54319..e9fa04ab6d 100644 --- a/apps/workbench/app/models/pipeline_instance.rb +++ b/apps/workbench/app/models/pipeline_instance.rb @@ -133,7 +133,7 @@ class PipelineInstance < ArvadosBase end def work_unit(label=nil) - PipelineInstanceWorkUnit.new(self, label || self.name) + PipelineInstanceWorkUnit.new(self, label || self.name, self.uuid) end private diff --git a/apps/workbench/app/models/pipeline_instance_work_unit.rb b/apps/workbench/app/models/pipeline_instance_work_unit.rb index dd5685ac3d..293a77c099 100644 --- a/apps/workbench/app/models/pipeline_instance_work_unit.rb +++ b/apps/workbench/app/models/pipeline_instance_work_unit.rb @@ -18,10 +18,10 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit if job[:uuid] and jobs[job[:uuid]] items << jobs[job[:uuid]].work_unit(name) else - items << JobWorkUnit.new(job, name) + items << JobWorkUnit.new(job, name, uuid) end else - items << JobWorkUnit.new(c, name) + items << JobWorkUnit.new(c, name, uuid) end else @unreadable_children = true diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb index b5349ec595..48bc3a04bc 100644 --- a/apps/workbench/app/models/proxy_work_unit.rb +++ b/apps/workbench/app/models/proxy_work_unit.rb @@ -6,23 +6,24 @@ class ProxyWorkUnit < WorkUnit attr_accessor :my_children attr_accessor :unreadable_children - def initialize proxied, label + def initialize proxied, label, parent @lbl = label @proxied = proxied + @parent = parent end def label @lbl end - def proxied - @proxied - end - def uuid get(:uuid) end + def parent + @parent + end + def modified_by_user_uuid get(:modified_by_user_uuid) end diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb index 727180ecfa..dd4a706f9d 100644 --- a/apps/workbench/app/models/work_unit.rb +++ b/apps/workbench/app/models/work_unit.rb @@ -5,14 +5,14 @@ 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 + def parent + # returns the parent uuid of this work unit + end + def children # returns an array of child work units end diff --git a/apps/workbench/app/views/work_units/_show_child.html.erb b/apps/workbench/app/views/work_units/_show_child.html.erb index 277aa37852..8bb33b54cb 100644 --- a/apps/workbench/app/views/work_units/_show_child.html.erb +++ b/apps/workbench/app/views/work_units/_show_child.html.erb @@ -51,7 +51,7 @@ <% content_url = url_for(controller: :work_units, action: :show_child_component, id: @object.uuid, object_type: @object.class.to_s) %> -
+