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