moved explorer into new directory structure
[arvados.git] / apps / explorer / app / views / collections / show.html.erb
diff --git a/apps/explorer/app/views/collections/show.html.erb b/apps/explorer/app/views/collections/show.html.erb
new file mode 100644 (file)
index 0000000..d9d06b3
--- /dev/null
@@ -0,0 +1,236 @@
+<%= content_for :head do %>
+<style>
+<%# https://github.com/mbostock/d3/wiki/Ordinal-Scales %>
+<% n=-1; %w(#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf).each do |color| %>
+.colorseries-10-<%= n += 1 %>, .btn.colorseries-10-<%= n %>:hover, .label.colorseries-10-<%= n %>:hover {
+  *background-color: <%= color %>;
+  background-color: <%= color %>;
+  background-image: none;
+}
+<% end %>
+.colorseries-nil { }
+.label a {
+  color: inherit;
+}
+</style>
+<% end %>
+
+<%= render :partial => 'nav' %>
+
+<ul class="nav nav-tabs">
+  <li class="active"><a href="#files" data-toggle="tab">Files (<%= @object.files ? @object.files.size : 0 %>)</a></li>
+  <li><a href="#provenance" data-toggle="tab">Provenance (<%= @provenance.size %>)</a></li>
+  <li><a href="#jobs" data-toggle="tab">Jobs (<%= @provenance.size %>)</a></li>
+  <li><a href="#sourcedata" data-toggle="tab">Source data (<%= @sourcedata.size %>)</a></li>
+  <li><a href="#owner-groups-resources" data-toggle="tab">Owner, groups, resources</a></li>
+</ul>
+
+<div class="tab-content">
+  <div id="files" class="tab-pane fade in active">
+    <table class="table table-bordered">
+      <thead>
+        <tr><th style="text-align:right">size (bytes)</th><th>filename</th></tr>
+      </thead><tbody>
+        <% if @object then @object.files.each do |file| %>
+        <tr>
+          <td style="text-align:right">
+            <%= raw(human_readable_bytes_html(file[2])) %>
+          </td><td>
+            <%= file[0] %>/<%= file[1] %>
+          </td>
+        </tr>
+        <% end; end %>
+      </tbody>
+    </table>
+  </div>
+  <div id="provenance" class="tab-pane fade">
+    <table class="topalign table table-bordered">
+      <thead>
+      </thead>
+      <tbody>
+
+       <% @provenance.reverse.each do |p| %>
+       <% j = p[:job] %>
+
+       <% if j %>
+
+       <tr class="job">
+         <td style="padding-bottom: 3em">
+            <table class="table" style="margin-bottom: 0; background: #f0f0ff">
+             <% j.script_parameters.each do |k,v| %>
+              <tr>
+                <td style="width: 60%">
+                  <% re = v.match(/^([0-9a-f]+)/) %>
+                  <% justhash = (re and re[1].length == 32) ? re[1] : nil %>
+                 <% if justhash and @output2job.has_key? justhash %>
+                 <tt class="label colorseries-10-<%= @output2colorindex[v] %>"><%= v %></tt>
+                  <% elsif justhash %>
+                 <tt class="label colorseries-nil"><%= justhash %></tt><br /><span class="deemphasize"><%= v %></span>
+                  <% else %>
+                 <span class="deemphasize"><%= v %></span>
+                  <% end %>
+                </td><td style="text-align: center; width: 20%">
+                  <% if justhash
+                       if @protected[justhash]
+                         labelclass = 'success'
+                         labeltext = 'keep'
+                       else
+                         labelclass = @output2job.has_key?(v) ? 'warning' : 'danger'
+                         labeltext = 'cache'
+                       end %>
+
+                 <tt class="label label-<%= labelclass %>"><%= labeltext %></tt>
+                  <% end %>
+                </td><td style="width: 20%">
+                  <%= k.to_s %>
+                </td>
+              </tr>
+             <% end %>
+            </table>
+            <div style="text-align: center">
+              &darr;
+              <br />
+             <span class="label"><%= j.script %><br /><tt><%= link_to_if j.script_version.match(/[0-9a-f]{40}/), j.script_version, "https://redmine.clinicalfuture.com/projects/freefactories/repository/revisions/#{j.script_version}/entry/mapreduce/mr-#{j.script}" if j.script_version %></tt></span>
+              <br />
+              &darr;
+              <br />
+             <tt class="label colorseries-10-<%= @output2colorindex[p[:output]] %>"><%= p[:output] %></tt>
+            </div>
+         </td>
+          <td>
+           <tt><span class="deemphasize">job:</span><br /><%= j.uuid %><br /><span class="deemphasize"><%= j.submit_id %></span></tt>
+          </td>
+       </tr>
+
+       <% else %>
+       <tr>
+         <td>
+           <span class="label label-danger">lookup fail</span>
+           <br />
+           <tt class="deemphasize"><%= p[:target] %></tt>
+         </td><td colspan="5">
+         </td>
+       </tr>
+       <% end %>
+
+       <% end %>
+
+      </tbody>
+    </table>
+  </div>
+  <div id="jobs" class="tab-pane fade">
+    <table class="topalign table table-bordered">
+      <thead>
+       <tr class="contain-align-left">
+         <th>
+           job
+         </th><th>
+           version
+         </th><th>
+           status
+         </th><th>
+           start
+         </th><th>
+           finish
+         </th><th>
+           clock time
+         </th>
+       </tr>
+      </thead>
+      <tbody>
+
+       <% @provenance.reverse.each do |p| %>
+       <% j = p[:job] %>
+
+       <% if j %>
+
+       <tr class="job">
+         <td>
+           <tt><%= j.uuid %></tt>
+           <br />
+           <tt class="deemphasize"><%= j.submit_id %></tt>
+         </td><td>
+           <%= j.script_version %>
+         </td><td>
+            <span class="label <%= if j.success then 'label-success'; elsif j.active then 'label-primary'; else 'label-warning'; end %>">
+             <%= j.success || j.active ? 'ok' : 'failed' %>
+            </span>
+         </td><td>
+           <%= j.started_at %>
+         </td><td>
+           <%= j.finished_at %>
+         </td><td>
+           <% if j.started_at and j.finished_at %>
+           <%= raw(distance_of_time_in_words(j.started_at, j.finished_at).sub('about ','~').sub(' ','&nbsp;')) %>
+           <% elsif j.started_at and j.running %>
+           <%= raw(distance_of_time_in_words(j.started_at, Time.now).sub('about ','~').sub(' ','&nbsp;')) %> (running)
+           <% end %>
+         </td>
+       </tr>
+
+       <% else %>
+       <tr>
+         <td>
+           <span class="label label-danger">lookup fail</span>
+           <br />
+           <tt class="deemphasize"><%= p[:target] %></tt>
+         </td><td colspan="4">
+         </td>
+       </tr>
+       <% end %>
+
+       <% end %>
+
+      </tbody>
+    </table>
+  </div>
+  <div id="sourcedata" class="tab-pane fade">
+    <table class="table table-bordered table-striped">
+      <thead>
+       <tr class="contain-align-left">
+         <th>
+           collection
+         </th><th class="data-size">
+           data size
+         </th><th>
+           storage
+         </th><th>
+           origin
+         </th>
+       </tr>
+      </thead>
+      <tbody>
+
+       <% @sourcedata.values.each do |sourcedata| %>
+
+       <tr class="collection">
+         <td>
+           <tt class="label"><%= sourcedata[:uuid] %></tt>
+         </td><td class="data-size">
+           <%= raw(human_readable_bytes_html(sourcedata[:collection].data_size)) if sourcedata[:collection] and sourcedata[:collection].data_size %>
+         </td><td>
+           <% if @protected[sourcedata[:uuid]] %>
+           <span class="label label-success">keep</span>
+           <% else %>
+           <span class="label label-danger">cache</span>
+           <% end %>
+         </td><td>
+           <% if sourcedata[:data_origins] %>
+           <% sourcedata[:data_origins].each do |data_origin| %>
+           <span class="deemphasize"><%= data_origin[0] %></span>
+           <%= data_origin[2] %>
+           <br />
+           <% end %>
+           <% end %>
+         </td>
+       </tr>
+
+       <% end %>
+
+      </tbody>
+    </table>
+  </div>
+  <div id="owner-groups-resources" class="tab-pane fade">
+    <%= render :partial => 'application/orvos_object' %>
+  </div>
+</div>