2809: Merge branch 'master' into 2809-workbench-rails4 refs #2809
[arvados.git] / apps / workbench / app / controllers / jobs_controller.rb
index 1cd3c3e28e894f4d188cbd52399834c5d44117ca..4746635c72a3ea141b64648a1efc675620be2657 100644 (file)
@@ -1,5 +1,49 @@
 class JobsController < ApplicationController
+
+  def generate_provenance(jobs)
+    nodes = []
+    collections = []
+    jobs.each do |j|
+      nodes << j
+      collections << j[:output]
+      collections.concat(ProvenanceHelper::find_collections(j[:script_parameters]))
+      nodes << {:uuid => j[:script_version]}
+    end
+
+    Collection.where(uuid: collections).each do |c|
+      nodes << c
+    end
+
+    @svg = ProvenanceHelper::create_provenance_graph nodes, "provenance_svg", {
+      :request => request,
+      :all_script_parameters => true, 
+      :script_version_nodes => true}
+  end
+
   def index
-    @jobs = Job.all
+    @svg = ""
+    if params[:uuid]
+      @objects = Job.where(uuid: params[:uuid])
+      generate_provenance(@objects)
+    else
+      @limit = 20
+      super
+    end
+  end
+
+  def show
+    generate_provenance([@object])
+  end
+
+  def index_pane_list
+    if params[:uuid]
+      %w(Recent Provenance)
+    else
+      %w(Recent)
+    end
+  end
+
+  def show_pane_list
+    %w(Attributes Provenance Metadata JSON API)
   end
 end