3988: Add note to Job.state. Replace logic to compute state based on
[arvados.git] / apps / workbench / app / controllers / jobs_controller.rb
1 class JobsController < ApplicationController
2
3   def generate_provenance(jobs)
4     return if params['tab_pane'] != "Provenance"
5
6     nodes = []
7     collections = []
8     jobs.each do |j|
9       nodes << j
10       collections << j[:output]
11       collections.concat(ProvenanceHelper::find_collections(j[:script_parameters]))
12       nodes << {:uuid => j[:script_version]}
13     end
14
15     Collection.where(uuid: collections).each do |c|
16       nodes << c
17     end
18
19     @svg = ProvenanceHelper::create_provenance_graph nodes, "provenance_svg", {
20       :request => request,
21       :all_script_parameters => true,
22       :script_version_nodes => true}
23   end
24
25   def index
26     @svg = ""
27     if params[:uuid]
28       @objects = Job.where(uuid: params[:uuid])
29       generate_provenance(@objects)
30       render_index
31     else
32       @limit = 20
33       super
34     end
35   end
36
37   def cancel
38     @object.cancel
39     if params[:return_to]
40       redirect_to params[:return_to]
41     else
42       redirect_to @object
43     end
44   end
45
46   def show
47     generate_provenance([@object])
48     super
49   end
50
51   def index_pane_list
52     if params[:uuid]
53       %w(Recent Provenance)
54     else
55       %w(Recent)
56     end
57   end
58
59   def show_pane_list
60     %w(Status Log Details Provenance Advanced)
61   end
62 end