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