{% extends "layout.html" %}
{% block title %}{{title}}{% endblock %}
{% block content %}
<h1>{{title}}</h1>

<div class="table-responsive">
  <table class="table table-striped">
    <thead>
      <tr>
	<th>Property</th>
	<th>Units</th>
	<th>Value</th>
      </tr>
    </thead>
    <tbody>
      <tr>
	<td>Observation</td>
	<td>obsid</td>
        {% if file.obsid %}
	<td><a href="/observations/{{file.obsid}}">{{file.obsid}}</a></td>
        {% else %}
	<td>null</td>
        {% endif %}
      </tr>
      <tr>
	<td>Size</td>
	<td>bytes</td>
	<td>{{file.size}} ({{file.size|filesizeformat}})</td>
      </tr>
      <tr>
	<td>MD5</td>
	<td></td>
	<td><tt>{{file.md5}}</tt></td>
      </tr>
      <tr>
	<td>Source</td>
	<td></td>
	<td>{{file.source}}</td>
      </tr>
      <tr>
	<td>Creation Time</td>
	<td></td>
	<td>{{file.create_time}}</td>
      </tr>
    </tbody>
  </table>
</div>

{% if staging_available %}

<h2>Staging to {{staging_dest_displayed}}</h2>

<p>You can stage this file to {{staging_dest_displayed}}.</p>

<form role="form" action="/" method="post"> <!-- note: POST method since non-idempotent op -->
  <input name="search" type="hidden" value="{&quot;name-is-exactly&quot;: {{file.name_as_json}}}">
  {{macros.staging_form_ui(staging_username_placeholder, staging_dest_path)}}
</form>

<br><br><!-- hack for nicer spacing -->

{% endif %}

<h2>Instances</h2>
{% if instances %}
<div class="table-responsive">
  <table class="table table-striped">
    <thead>
      <tr>
	<th>Store</th>
	<th>Subdirectory</th>
	<th>Deletion Policy</th>
      </tr>
    </thead>
    <tbody>
      {% for i in instances %}
      <tr>
	<td><a href="/stores/{{i.store_name}}">{{i.store_name}}</a></td>
	<td>{{i.parent_dirs}}</td>
	<td>{{i.deletion_policy_text}}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% else %}
<p>This Librarian currently holds no copies of this file.</p>
{% endif %}

<h2>Events</h2>
{% if events %}
<div class="table-responsive">
  <table class="table table-striped">
    <thead>
      <tr>
	<th>Time</th>
	<th>Type</th>
	<th>Data payload</th>
      </tr>
    </thead>
    <tbody>
      {% for e in events %}
      <tr>
	<td>{{e.time}}</td>
	<td>{{e.type}}</td>
	<td>{{e.payload}}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% else %}
<p>This Librarian has recorded no events relating to this file.</p>
{% endif %}

{% endblock %}
