cc8eec352f50941797ebbfb146a62f3f0a79e3a3
[arvados.git] / apps / workbench / app / views / collections / show.html.erb
1 <%= content_for :head do %>
2 <style>
3 <%# https://github.com/mbostock/d3/wiki/Ordinal-Scales %>
4 <% n=-1; %w(#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf).each do |color| %>
5 .colorseries-10-<%= n += 1 %>, .btn.colorseries-10-<%= n %>:hover, .label.colorseries-10-<%= n %>:hover {
6   *background-color: <%= color %>;
7   background-color: <%= color %>;
8   background-image: none;
9 }
10 <% end %>
11 .colorseries-nil { }
12 .label a {
13   color: inherit;
14 }
15 </style>
16 <% end %>
17
18 <%#= render :partial => 'nav' %>
19
20 <ul class="nav nav-tabs">
21   <li class="active"><a href="#files" data-toggle="tab">Files (<%= @object.files ? @object.files.size : 0 %>)</a></li>
22   <li><a href="#provenance" data-toggle="tab">Provenance (<%= @provenance.size %>)</a></li>
23   <li><a href="#jobs" data-toggle="tab">Jobs (<%= @provenance.size %>)</a></li>
24   <li><a href="#sourcedata" data-toggle="tab">Source data (<%= @sourcedata.size %>)</a></li>
25   <li><a href="#owner-groups-resources" data-toggle="tab">Owner, groups, resources</a></li>
26 </ul>
27
28 <div class="tab-content">
29   <div id="files" class="tab-pane fade in active">
30     <table class="table table-bordered" style="table-layout: fixed">
31       <thead>
32         <tr>
33           <th style="width: 10em; text-align:right">size</th>
34           <th>
35             <div style="width:3.5em; display:inline-block"></div>
36             path
37           </th>
38         </tr>
39       </thead><tbody>
40         <% if @object then @object.files.sort_by{|f|f[1]}.each do |file| %>
41         <% file_path = "#{file[0]}/#{file[1]}" %>
42         <tr>
43           <td style="text-align:right">
44             <%= raw(human_readable_bytes_html(file[2])) %>
45           </td><td>
46             <div style="width:3.5em; display:inline-block">
47             <%= link_to raw('<i class="icon-download"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'label label-info', title: 'Download'} %>
48             <% if file_path.match /\.(txt|pdf|png|jpe?g|gif|tiff?)$/i %>
49             <%= link_to raw('<i class="icon-play"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {class: 'label label-info', title: 'View in browser'} %>
50             <% end %>
51             </div>
52             <%= file_path %>
53           </td>
54         </tr>
55         <% end; end %>
56       </tbody>
57     </table>
58   </div>
59   <div id="provenance" class="tab-pane fade">
60     <table class="topalign table table-bordered">
61       <thead>
62       </thead>
63       <tbody>
64
65         <% @provenance.reverse.each do |p| %>
66         <% j = p[:job] %>
67
68         <% if j %>
69
70         <tr class="job">
71           <td style="padding-bottom: 3em">
72             <table class="table" style="margin-bottom: 0; background: #f0f0ff">
73               <% j.script_parameters.each do |k,v| %>
74               <tr>
75                 <td style="width: 20%">
76                   <%= k.to_s %>
77                 </td><td style="width: 60%">
78                   <% if v and @output2job.has_key? v %>
79                   <tt class="label colorseries-10-<%= @output2colorindex[v] %>"><%= link_to_if_arvados_object v %></tt>
80                   <% else %>
81                   <span class="deemphasize"><%= link_to_if_arvados_object v %></span>
82                   <% end %>
83                 </td><td style="text-align: center; width: 20%">
84                   <% if v
85                        if @protected[v]
86                          labelclass = 'success'
87                          labeltext = 'keep'
88                        else
89                          labelclass = @output2job.has_key?(v) ? 'warning' : 'danger'
90                          labeltext = 'cache'
91                        end %>
92
93                   <tt class="label label-<%= labelclass %>"><%= labeltext %></tt>
94                   <% end %>
95                 </td>
96               </tr>
97               <% end %>
98             </table>
99             <div style="text-align: center">
100               &darr;
101               <br />
102               <span class="label"><%= j.script %><br /><tt><%= link_to_if j.script_version.match(/[0-9a-f]{40}/), j.script_version, "https://arvados.org/projects/arvados/repository/revisions/#{j.script_version}/entry/crunch_scripts/#{j.script}" if j.script_version %></tt></span>
103               <br />
104               &darr;
105               <br />
106               <tt class="label colorseries-10-<%= @output2colorindex[p[:output]] %>"><%= link_to_if_arvados_object p[:output] %></tt>
107             </div>
108           </td>
109           <td>
110             <tt><span class="deemphasize">job:</span><br /><%= link_to_if_arvados_object j %><br /><span class="deemphasize"><%= j.submit_id %></span></tt>
111           </td>
112         </tr>
113
114         <% else %>
115         <tr>
116           <td>
117             <span class="label label-danger">lookup fail</span>
118             <br />
119             <tt class="deemphasize"><%= p[:target] %></tt>
120           </td><td colspan="5">
121           </td>
122         </tr>
123         <% end %>
124
125         <% end %>
126
127       </tbody>
128     </table>
129   </div>
130   <div id="jobs" class="tab-pane fade">
131     <table class="topalign table table-bordered">
132       <thead>
133         <tr class="contain-align-left">
134           <th>
135             job
136           </th><th>
137             version
138           </th><th>
139             status
140           </th><th>
141             start
142           </th><th>
143             finish
144           </th><th>
145             clock time
146           </th>
147         </tr>
148       </thead>
149       <tbody>
150
151         <% @provenance.reverse.each do |p| %>
152         <% j = p[:job] %>
153
154         <% if j %>
155
156         <tr class="job">
157           <td>
158             <tt><%= j.uuid %></tt>
159             <br />
160             <tt class="deemphasize"><%= j.submit_id %></tt>
161           </td><td>
162             <%= j.script_version %>
163           </td><td>
164             <span class="label <%= if j.success then 'label-success'; elsif j.active then 'label-primary'; else 'label-warning'; end %>">
165               <%= j.success || j.active ? 'ok' : 'failed' %>
166             </span>
167           </td><td>
168             <%= j.started_at %>
169           </td><td>
170             <%= j.finished_at %>
171           </td><td>
172             <% if j.started_at and j.finished_at %>
173             <%= raw(distance_of_time_in_words(j.started_at, j.finished_at).sub('about ','~').sub(' ','&nbsp;')) %>
174             <% elsif j.started_at and j.running %>
175             <%= raw(distance_of_time_in_words(j.started_at, Time.now).sub('about ','~').sub(' ','&nbsp;')) %> (running)
176             <% end %>
177           </td>
178         </tr>
179
180         <% else %>
181         <tr>
182           <td>
183             <span class="label label-danger">lookup fail</span>
184             <br />
185             <tt class="deemphasize"><%= p[:target] %></tt>
186           </td><td colspan="4">
187           </td>
188         </tr>
189         <% end %>
190
191         <% end %>
192
193       </tbody>
194     </table>
195   </div>
196   <div id="sourcedata" class="tab-pane fade">
197     <table class="table table-bordered table-striped">
198       <thead>
199         <tr class="contain-align-left">
200           <th>
201             collection
202           </th><th class="data-size">
203             data size
204           </th><th>
205             storage
206           </th><th>
207             origin
208           </th>
209         </tr>
210       </thead>
211       <tbody>
212
213         <% @sourcedata.values.each do |sourcedata| %>
214
215         <tr class="collection">
216           <td>
217             <tt class="label"><%= sourcedata[:uuid] %></tt>
218           </td><td class="data-size">
219             <%= raw(human_readable_bytes_html(sourcedata[:collection].data_size)) if sourcedata[:collection] and sourcedata[:collection].data_size %>
220           </td><td>
221             <% if @protected[sourcedata[:uuid]] %>
222             <span class="label label-success">keep</span>
223             <% else %>
224             <span class="label label-danger">cache</span>
225             <% end %>
226           </td><td>
227             <% if sourcedata[:data_origins] %>
228             <% sourcedata[:data_origins].each do |data_origin| %>
229             <span class="deemphasize"><%= data_origin[0] %></span>
230             <%= data_origin[2] %>
231             <br />
232             <% end %>
233             <% end %>
234           </td>
235         </tr>
236
237         <% end %>
238
239       </tbody>
240     </table>
241   </div>
242   <div id="owner-groups-resources" class="tab-pane fade">
243     <%= render :partial => 'application/arvados_object' %>
244   </div>
245 </div>