11501: Simplified helper method call. Changed wording of run time description.
[arvados.git] / apps / workbench / app / models / job_work_unit.rb
index 7f1c73f694fefb57fc52f157e73b62e1ac61c1f9..5b1d1b7e35b416e7ee3eb09bcad4a6d60d509b6e 100644 (file)
@@ -1,15 +1,9 @@
 class JobWorkUnit < ProxyWorkUnit
   def children
-    uuid = get(:uuid)
-    items = []
-
-    # Job tasks - for now do not include job tasks
-    # tasks = JobTask.filter([['job_uuid', '=', uuid]]).results
-    # tasks.each do |t|
-    #   items << t.work_unit("task #{items.size}")
-    # end
+    return @my_children if @my_children
 
     # Jobs components
+    items = []
     components = get(:components)
     uuids = components.andand.collect {|_, v| v}
     return items if (!uuids or uuids.empty?)
@@ -25,28 +19,38 @@ class JobWorkUnit < ProxyWorkUnit
         items << obj.work_unit(components.key(obj.uuid))
       end
     end
-    items
-  end
 
-  def progress
-    state = get(:state)
-    if state == 'Complete'
-      return 1.0
-    end
+    @my_children = items
+  end
 
-    tasks_summary = get(:tasks_summary)
-    failed = tasks_summary[:failed] || 0 rescue 0
-    done = tasks_summary[:done] || 0 rescue 0
-    running = tasks_summary[:running] || 0 rescue 0
-    todo = tasks_summary[:todo] || 0 rescue 0
-    if done + running + failed + todo > 0
-      total_tasks = done + running + failed + todo
-      (done+failed).to_f / total_tasks
+  def child_summary
+    if children.any?
+      super
     else
-      0.0
+      get(:tasks_summary)
     end
   end
 
+  def parameters
+    get(:script_parameters)
+  end
+
+  def repository
+    get(:repository)
+  end
+
+  def script
+    get(:script)
+  end
+
+  def script_version
+    get(:script_version)
+  end
+
+  def supplied_script_version
+    get(:supplied_script_version)
+  end
+
   def docker_image
     get(:docker_image_locator)
   end
@@ -55,6 +59,10 @@ class JobWorkUnit < ProxyWorkUnit
     get(:nondeterministic)
   end
 
+  def runtime_constraints
+    get(:runtime_constraints)
+  end
+
   def priority
     get(:priority)
   end
@@ -63,12 +71,18 @@ class JobWorkUnit < ProxyWorkUnit
     get(:log)
   end
 
-  def output
-    get(:output)
+  def outputs
+    items = []
+    items << get(:output) if get(:output)
+    items
   end
 
   def can_cancel?
-    true
+    state_label.in? ["Queued", "Running"]
+  end
+
+  def confirm_cancellation
+    "All unfinished child jobs and pipelines will also be canceled, even if they are being used in another job or pipeline. Are you sure you want to cancel this job?"
   end
 
   def uri
@@ -76,10 +90,6 @@ class JobWorkUnit < ProxyWorkUnit
     "/jobs/#{uuid}"
   end
 
-  def child_summary
-    get(:tasks_summary)
-  end
-
   def title
     "job"
   end