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