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