10079: add "parent" to work_unit to aid the child display
[arvados.git] / apps / workbench / app / views / work_units / _component_detail.html.erb
1 <%
2   collections = current_obj.outputs.flatten.uniq
3   collections << current_obj.docker_image
4   collections = collections.compact.uniq
5   collections_pdhs = collections.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
6   collections_uuids = collections - collections_pdhs
7   preload_collections_for_objects collections_uuids if collections_uuids.any?
8   preload_for_pdhs collections_pdhs if collections_pdhs.any?
9
10   preload_objects_for_dataclass(Repository, [current_obj.repository], :name) if current_obj.repository
11 %>
12
13       <div class="container">
14         <div class="row">
15           <div class="col-md-5">
16             <% if current_obj.uuid.nil? %>
17               No <%= current_obj.title %> has been submitted yet.
18             <% else %>
19             <table>
20               <% keys = [:uuid, :modified_by_user_uuid, :created_at, :started_at, :finished_at, :container_uuid, :priority] %>
21               <% keys << :log_collection if @object.uuid != current_obj.uuid %>
22               <% keys << :outputs %>
23               <% keys.each do |k| %>
24                 <% val = current_obj.send(k) if current_obj.respond_to?(k) %>
25                 <% has_val = val %>
26                 <% has_val = val.andand.any? if k == :outputs %>
27                 <% has_val = true if k == :log_collection and current_obj.state_label == "Running" %>
28                 <% if has_val %>
29                 <tr>
30                   <td style="padding-right: 1em">
31                     <%= k.to_s %>:
32                   </td>
33                   <td>
34                     <% if k == :uuid %>
35                       <%= link_to_arvados_object_if_readable(val, val, link_text: val) %>
36                     <% elsif k.to_s.end_with? 'uuid' %>
37                       <%= link_to_arvados_object_if_readable(val, val, friendly_name: true) %>
38                     <% elsif k.to_s.end_with? '_at' %>
39                       <%= render_localized_date(val) %>
40                     <% elsif k == :outputs and val.any? %>
41                       <% if val.size == 1 %>
42                         <%= link_to_arvados_object_if_readable(val[0], 'Output data not available', friendly_name: true) %>
43                       <% else %>
44                         <%= render partial: 'work_units/show_outputs', locals: {id: current_obj.uuid, outputs: val, align:""} %>
45                       <% end %>
46                     <% elsif k == :log_collection %>
47                       <%= render partial: 'work_units/show_log_link', locals: {wu: current_obj} %>
48                     <% else %>
49                       <%= val %>
50                     <% end %>
51                   </td>
52                 </tr>
53                 <% end %>
54               <% end %>
55             </table>
56             <% end %>
57           </div>
58           <div class="col-md-6">
59             <table>
60               <% # link to repo tree/file only if the repo is readable and the commit is a sha1
61                  repo = (/^[0-9a-f]{40}$/ =~ current_obj.script_version and
62                          current_obj.repository and
63                          object_for_dataclass(Repository, current_obj.repository, :name))
64                  repo = nil unless repo.andand.http_fetch_url
65                  %>
66               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic,
67                   :command, :cwd, :environment, :mounts, :output_path].each do |k| %>
68                 <% val = current_obj.send(k) if current_obj.respond_to?(k) %>
69                 <% if val %>
70                 <tr>
71                   <td style="padding-right: 1em">
72                     <%= k.to_s %>:
73                   </td>
74                   <td>
75                     <% if repo and k == :repository %>
76                       <%= link_to val, show_repository_tree_path(id: repo.uuid, commit: current_obj.script_version, path: '/') %>
77                     <% elsif repo and k == :script %>
78                       <%= link_to val, show_repository_blob_path(id: repo.uuid, commit: current_obj.script_version, path: 'crunch_scripts/'+current_obj.script) %>
79                     <% elsif repo and k == :script_version %>
80                       <%= link_to val, show_repository_commit_path(id: repo.uuid, commit: current_obj.script_version) %>
81                     <% else %>
82                       <%= val %>
83                     <% end %>
84                   </td>
85                 </tr>
86                 <% end %>
87               <% end %>
88               <% if current_obj.runtime_constraints.andand[:docker_image] and current_obj.docker_image %>
89                 <tr>
90                   <td style="padding-right: 1em">
91                     docker_image:
92                   </td>
93                   <td>
94                     <%= current_obj.runtime_constraints[:docker_image] %>
95                   </td>
96                 </tr>
97                 <tr>
98                   <td style="padding-right: 1em">
99                     docker_image_locator:
100                   </td>
101                   <td>
102                     <%= link_to_arvados_object_if_readable(current_obj.docker_image,
103                       current_obj.docker_image, friendly_name: true) %>
104                   </td>
105                 </tr>
106               <% elsif current_obj.docker_image %>
107                 <tr>
108                   <td style="padding-right: 1em">
109                     docker_image_locator:
110                   </td>
111                   <td>
112                     <%= link_to_arvados_object_if_readable(current_obj.docker_image,
113                       current_obj.docker_image, friendly_name: true) %>
114                   </td>
115                 </tr>
116               <% end %>
117             </table>
118           </div>
119         </div>
120
121         <% if current_obj.parameters and !current_obj.parameters.empty? %>
122         <div class="row">
123           <div class="col-md-6">
124             <p>script_parameters:</p>
125             <pre><%= JSON.pretty_generate(current_obj.parameters) rescue nil %></pre>
126           </div>
127         </div>
128         <% end %>
129       </div>