8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / app / views / work_units / _component_detail.html.erb
1 <%
2   collections = [current_obj.outputs, current_obj.docker_image].flatten.compact.uniq
3   collections_pdhs = collections.select {|x| !CollectionsHelper.match(x).nil?}.uniq.compact
4   collections_uuids = collections - collections_pdhs
5   preload_collections_for_objects collections_uuids if collections_uuids.any?
6   preload_links_for_objects collections_uuids if collections_uuids.any?
7
8   preload_objects_for_dataclass(Repository, [current_obj.repository], :name) if current_obj.repository
9
10   # if container_X, preload mounted collections
11   if @object.is_a? Container or @object.is_a? ContainerRequest
12     # get any collections in mounts
13     mounts = current_obj.send(:mounts) if current_obj.respond_to?(:mounts)
14     input_obj = mounts.andand[:"/var/lib/cwl/cwl.input.json"].andand[:content]
15     if input_obj
16       input_obj.to_s.scan(/([0-9a-f]{32}\+\d+)/).each {|cs| collections_pdhs += cs}
17     end
18
19     command = current_obj.send(:command) if current_obj.respond_to?(:command)
20     if command
21       command.to_s.scan(/([0-9a-f]{32}\+\d+)/).each {|cs| collections_pdhs += cs}
22     end
23   end
24
25   collections_pdhs.compact.uniq
26   preload_for_pdhs collections_pdhs if collections_pdhs.any?
27   preload_links_for_objects collections_pdhs if collections_pdhs.any?
28 %>
29
30       <div class="container">
31         <div class="row">
32           <div class="col-md-6" style="overflow-x: auto">
33             <% if current_obj.uuid.nil? %>
34               No <%= current_obj.title %> has been submitted yet.
35             <% else %>
36             <table class="table table-condensed">
37               <% keys = [:uuid, :modified_by_user_uuid, :created_at, :started_at, :finished_at, :container_uuid] %>
38               <% keys << :log_collection if @object.uuid != current_obj.uuid %>
39               <% keys << :outputs %>
40               <% keys.each do |k| %>
41                 <%
42                   val = current_obj.send(k) if current_obj.respond_to?(k)
43                   if k == :outputs
44                     has_val = val.andand.any?
45                   elsif k == :log_collection and current_obj.state_label == "Running"
46                     has_val = true
47                   else
48                     has_val = val
49                   end
50                 %>
51                 <% if has_val %>
52                 <tr>
53                   <td style="padding-right: 1em">
54                     <%= k.to_s %>:
55                   </td>
56                   <td>
57                     <% if k == :uuid %>
58                       <%= link_to_arvados_object_if_readable(val, val, link_text: val) %>
59                     <% elsif k.to_s.end_with? 'uuid' %>
60                       <%= link_to_arvados_object_if_readable(val, val, friendly_name: true) %>
61                     <% elsif k.to_s.end_with? '_at' %>
62                       <%= render_localized_date(val) %>
63                     <% elsif k == :outputs and val.any? %>
64                       <% if val.size == 1 %>
65                         <%= link_to_arvados_object_if_readable(val[0], 'Output data not available', friendly_name: true) %>
66                       <% else %>
67                         <%= render partial: 'work_units/show_outputs', locals: {id: current_obj.uuid, outputs: val, align:""} %>
68                       <% end %>
69                     <% elsif k == :log_collection %>
70                       <%= render partial: 'work_units/show_log_link', locals: {wu: current_obj} %>
71                     <% else %>
72                       <%= val %>
73                     <% end %>
74                   </td>
75                 </tr>
76                 <% end %>
77               <% end %>
78             </table>
79             <% end %>
80           </div>
81           <div class="col-md-6">
82             <table class="table table-condensed">
83               <% # link to repo tree/file only if the repo is readable and the commit is a sha1
84                  repo = (/^[0-9a-f]{40}$/ =~ current_obj.script_version and
85                          current_obj.repository and
86                          object_for_dataclass(Repository, current_obj.repository, :name))
87                  repo = nil unless repo.andand.http_fetch_url
88                  %>
89               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic,
90                   :priority, :runtime_constraints, :requesting_container_uuid].each do |k| %>
91                 <% val = current_obj.send(k) if current_obj.respond_to?(k) %>
92                 <% if val %>
93                 <tr valign="top">
94                   <td style="padding-right: 1em">
95                     <%= k.to_s %>:
96                   </td>
97                   <td>
98                     <% if repo and k == :repository %>
99                       <%= link_to val, show_repository_tree_path(id: repo.uuid, commit: current_obj.script_version, path: '/') %>
100                     <% elsif repo and k == :script %>
101                       <%= link_to val, show_repository_blob_path(id: repo.uuid, commit: current_obj.script_version, path: 'crunch_scripts/'+current_obj.script) %>
102                     <% elsif repo and k == :script_version %>
103                       <%= link_to val, show_repository_commit_path(id: repo.uuid, commit: current_obj.script_version) %>
104                     <% elsif k == :runtime_constraints and val.any? %>
105                       <%= render partial: 'work_units/show_table_data', locals: {id: current_obj.uuid, name: k, data_map: val} %>
106                     <% elsif k.to_s.end_with? 'uuid' %>
107                       <%= link_to_arvados_object_if_readable(val, val, friendly_name: true) %>
108                     <% else %>
109                       <%= val %>
110                     <% end %>
111                   </td>
112                 </tr>
113                 <% end %>
114               <% end %>
115
116               <%
117                 mounts = current_obj.send(:mounts) if current_obj.respond_to?(:mounts)
118                 mount_wf = mounts.andand[:"/var/lib/cwl/workflow.json"]
119                 mount_wf = mount_wf[5..-1] if mount_wf.andand.is_a?(String) and mount_wf.start_with?('keep:')
120                 mount_wf_cls = resource_class_for_uuid(mount_wf) if mount_wf
121               %>
122               <tr>
123                 <% if mount_wf_cls == Collection %>
124                   <td style="padding-right: 1em">
125                     workflow.json:
126                   </td>
127                   <td>
128                     <%= link_to_if_arvados_object mount_wf, friendly_name: true %>
129                   </td>
130                 <% end %>
131               </tr>
132
133               <% if current_obj.runtime_constraints.andand[:docker_image] and current_obj.docker_image %>
134                 <tr>
135                   <td style="padding-right: 1em">
136                     docker_image:
137                   </td>
138                   <td>
139                     <%= current_obj.runtime_constraints[:docker_image] %>
140                   </td>
141                 </tr>
142                 <tr>
143                   <td style="padding-right: 1em">
144                     docker_image_locator:
145                   </td>
146                   <td>
147                     <%= link_to_arvados_object_if_readable(current_obj.docker_image,
148                       current_obj.docker_image, friendly_name: true) %>
149                   </td>
150                 </tr>
151               <% elsif current_obj.docker_image %>
152                 <tr>
153                   <td style="padding-right: 1em">
154                     docker_image_locator:
155                   </td>
156                   <td>
157                     <%= link_to_arvados_object_if_readable(current_obj.docker_image,
158                       current_obj.docker_image, friendly_name: true) %>
159                   </td>
160                 </tr>
161               <% end %>
162             </table>
163           </div>
164
165           <div class="col-md-12">
166             <table class="table table-condensed" style="table-layout:fixed;">
167               <col width="15%" />
168               <col width="85%" />
169               <% [:command].each do |k| %>
170                 <% val = current_obj.send(k) if current_obj.respond_to?(k) %>
171                 <% if val %>
172                 <tr>
173                   <td valign="top">
174                     <%= k.to_s %>:
175                   </td>
176                   <td style="word-wrap: break-all;">
177                     <% if k == :command %>
178                         <% val = JSON.pretty_generate(val) %>
179                         <%= render partial: 'show_text_with_locators', locals: {data_height: 200, text_data: val} %>
180                     <% else %>
181                       <%= val %>
182                     <% end %>
183                   </td>
184                 </tr>
185                 <% end %>
186               <% end %>
187
188               <%
189                 mounts = current_obj.send(:mounts) if current_obj.respond_to?(:mounts)
190                 input_obj = mounts.andand[:"/var/lib/cwl/cwl.input.json"].andand[:content]
191                 mnt_inputs = JSON.pretty_generate(input_obj) if input_obj
192               %>
193               <% if mnt_inputs %>
194                 <tr>
195                   <td valign="top">
196                     cwl.input.json:
197                   </td>
198                   <td style="word-wrap: break-all;">
199                     <%= render partial: 'show_text_with_locators', locals: {data_height: 400, text_data: mnt_inputs} %>
200                   </td>
201                 </tr>
202               <% end %>
203             </table>
204           </div>
205
206         </div>
207
208         <% if current_obj.parameters and !current_obj.parameters.empty? %>
209         <div class="row">
210           <div class="col-md-6">
211             <p>script_parameters:</p>
212             <pre><%= JSON.pretty_generate(current_obj.parameters) rescue nil %></pre>
213           </div>
214         </div>
215         <% end %>
216       </div>