3114: Merge branch 'master' into 3114-copy-to-project
[arvados.git] / apps / workbench / app / views / collections / show.html.erb
index 0c5795d509d79747b59a87559d6c400e5fc78448..0d52b088c47a91f59bc1f46092d4a73e3fc51a34 100644 (file)
-<%= 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;
-}
+<% content_for :tab_line_buttons do %>
+  <%= link_to(
+      choose_projects_path(
+       title: 'Copy to project...',
+       my_root_selectable: true,
+       action_name: 'Copy',
+       action_href: actions_path,
+       action_method: 'post',
+       action_data: {
+         copy_selections_into_project: true,
+         selection: @name_link.andand.uuid || @object.uuid,
+         selection_param: 'uuid',
+         success: 'redirect-to-created-object'
+       }.to_json),
+      { class: "btn btn-sm btn-primary arv-move-to-project", remote: true, method: 'get' }) do %>
+    <i class="fa fa-fw fa-copy"></i> Copy to project...
+  <% end %>
 <% 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" style="table-layout: fixed">
-      <thead>
-        <tr>
-          <th>path</th>
-          <th>file</th>
-          <th style="width:1.5em">d/l</th>
-          <th style="width: 7em; text-align:right">size</th>
-        </tr>
-      </thead><tbody>
-        <% if @object then @object.files.sort_by{|f|f[1]}.each do |file| %>
-        <% file_path = "#{file[0]}/#{file[1]}" %>
-        <tr>
-          <td>
-            <%= file[0] %>
-          </td>
-
-          <td>
-            <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
-          </td>
-
-          <td>
-            <div style="display:inline-block">
-            <%= 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'} %>
-            </div>
-          </td>
-
-          <td style="text-align:right">
-            <%= raw(human_readable_bytes_html(file[2])) %>
-          </td>
 
-        </tr>
-        <% end; end %>
-      </tbody>
-    </table>
+<div class="row row-fill-height">
+  <div class="col-md-6">
+    <div class="panel panel-info">
+      <div class="panel-heading">
+       <h3 class="panel-title">
+         <%= @name_link.andand.name || @object.uuid %>
+       </h3>
+      </div>
+      <div class="panel-body">
+        <img src="/favicon.ico" class="pull-right" alt="" style="opacity: 0.3"/>
+       <p><i>Content hash:</i><br />
+         <span class="arvados-uuid"><%= @object.uuid %></span></p>
+
+        <%= render partial: "show_source_summary" %>
+      </div>
+    </div>
   </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: 20%">
-                  <%= k.to_s %>
-                </td><td style="width: 60%">
-                 <% if v and @output2job.has_key? v %>
-                 <tt class="label colorseries-10-<%= @output2colorindex[v] %>"><%= link_to_if_arvados_object v %></tt>
-                  <% else %>
-                 <span class="deemphasize"><%= link_to_if_arvados_object v %></span>
-                  <% end %>
-                </td><td style="text-align: center; width: 20%">
-                  <% if v
-                       if @protected[v]
-                         labelclass = 'success'
-                         labeltext = 'keep'
-                       else
-                         labelclass = @output2job.has_key?(v) ? 'warning' : 'danger'
-                         labeltext = 'cache'
-                       end %>
-
-                 <tt class="label label-<%= labelclass %>"><%= labeltext %></tt>
-                  <% end %>
-                </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://arvados.org/projects/arvados/repository/revisions/#{j.script_version}/entry/crunch_scripts/#{j.script}" if j.script_version %></tt></span>
-              <br />
-              &darr;
-              <br />
-             <tt class="label colorseries-10-<%= @output2colorindex[p[:output]] %>"><%= link_to_if_arvados_object p[:output] %></tt>
-            </div>
-         </td>
-          <td>
-           <tt><span class="deemphasize">job:</span><br /><%= link_to_if_arvados_object j %><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 class="col-md-3">
+    <div class="panel panel-default">
+      <div class="panel-heading">
+       <h3 class="panel-title">
+         Activity
+       </h3>
+      </div>
+      <div class="panel-body smaller-text">
+        <!--
+       <input type="text" class="form-control" placeholder="Search"/>
+        -->
+       <div style="height:0.5em;"></div>
+        <% name_or_object = @name_link.andand.uuid ? @name_link : @object %>
+        <% if name_or_object.created_at and not @logs.andand.any? %>
+          <p>
+            Created: <%= name_or_object.created_at.to_s(:long) %>
+          </p>
+          <p>
+            Last modified: <%= name_or_object.modified_at.to_s(:long) %> by <%= link_to_if_arvados_object name_or_object.modified_by_user_uuid, friendly_name: true %>
+          </p>
+        <% else %>
+          <%= render_arvados_object_list_start(@logs, 'Show all activity',
+                logs_path(filters: [['object_uuid','=',name_or_object.uuid]].to_json)) do |log| %>
+          <p>
+          <%= time_ago_in_words(log.event_at) rescue 'unknown time' %> ago: <%= log.summary %>
+            <% if log.object_uuid %>
+            <%= link_to_if_arvados_object log.object_uuid, link_text: raw('<i class="fa fa-hand-o-right"></i>') %>
+            <% end %>
+          </p>
+          <% end %>
+        <% end %>
+      </div>
+    </div>
   </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 class="col-md-3">
+    <div class="panel panel-default">
+      <div class="panel-heading">
+       <h3 class="panel-title">
+         Sharing and permissions
+       </h3>
+      </div>
+      <div class="panel-body">
+        <!--
+       <input type="text" class="form-control" placeholder="Search"/>
+        -->
+
+        <div id="sharing-button">
+          <%= render partial: 'sharing_button' %>
+        </div>
+
+       <div style="height:0.5em;"></div>
+        <% if @projects.andand.any? %>
+          <p>Included in projects:<br />
+          <%= render_arvados_object_list_start(@projects, 'Show all projects',
+                links_path(filters: [['head_uuid', '=', @object.uuid],
+                                     ['link_class', '=', 'name']].to_json)) do |project| %>
+            <%= link_to_if_arvados_object(project, friendly_name: true) %><br />
+          <% end %>
+          </p>
+        <% end %>
+        <% if @permissions.andand.any? %>
+          <p>Readable by:<br />
+          <%= render_arvados_object_list_start(@permissions, 'Show all permissions',
+                links_path(filters: [['head_uuid', '=', @object.uuid],
+                                    ['link_class', '=', 'permission']].to_json)) do |link| %>
+          <%= link_to_if_arvados_object(link.tail_uuid, friendly_name: true) %><br />
+          <% end %>
+          </p>
+        <% end %>
+
+      </div>
+    </div>
   </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>
+</div>
 
-       <% end %>
+<% content_for :tab_line_buttons do %>
+  <span style="padding-left: 1em">Collection storage status:</span>
+  <%= render partial: 'toggle_persist', locals: { uuid: @object.uuid, current_state: (@is_persistent ? 'persistent' : 'cache') } %>
+<% end %>
 
-      </tbody>
-    </table>
-  </div>
-  <div id="owner-groups-resources" class="tab-pane fade">
-    <%= render :partial => 'application/arvados_object' %>
-  </div>
-</div>
+<%= render file: 'application/show.html.erb', locals: local_assigns %>