{% extends "report_base.html" %}

{% block content %}

<div class="alert alert-secondary">

  {% include "report_buttons.html" %}

  <strong>Report: Preservation derivatives</strong><br>
  <strong>Storage Service:</strong> {{ storage_service_name }}
  <br>
  {% if storage_location_description %}
    <strong>Location:</strong> {{ storage_location_description }}
    <br>
  {% endif %}
  {{ total_files }} preservation derivatives found across {{ aips|length }} AIPs
</div>

<h1 class="h2" style="margin-bottom: 20px;">Preservation derivatives report</h1>

<!-- Hidden elements we want available from JS for URL generation -->
<span id="storageServiceID" style="display:none;">{{ storage_service_id }}</span>
<span id="storageLocationID" style="display:none;">{{ storage_location_id }}</span>

<!-- AIP selector -->
<div class="noprint" style="margin-bottom: 10px;">
  <strong>AIP:</strong>
  <select id="aipSelector" class="form-control" style="width:auto;">
    <option value="">All AIPs</option>
    {% for aip in aips %}
      <option value="{{ aip['AIPUUID'] }}"{% if aip["AIPUUID"]==selected_aip %} selected{% endif %}>{{ aip["AIPName"] }} ({{ aip["AIPUUID"] }})</option>
    {% endfor %}
  </select>
</div>

{% if files %}
    <table id="preservation-derivatives" class="table table-striped table-bordered">
      <thead>
        <tr>
          {% for column in columns %}
          <th><strong>{{ column }}</strong></th>
          {% endfor %}
        </tr>
      </thead>
      <tbody>
      {% for file_ in files %}
        <tr>
          <td>
            {{ file_["AIPName"] }}
            <br>
            <span class="text-muted"><small>UUID: {{ file_["AIPUUID"] }}</small></span>
          </td>
          <td>
            {% if file_["OriginalName"] %}
              {{ file_["OriginalName"] }}
              <br>
              <span class="text-muted"><small>UUID: {{ file_["OriginalUUID"] }}</small></span>
            {% else %}
              n/a
            {% endif %}
          </td>
          <td>
            {% if file_["OriginalFormat"] %}
              {{ file_["OriginalFormat"] }}
              {% if file_["OriginalVersion"] %}
                <span> ({{ file_["OriginalVersion"] }})</span>
              {% endif %}
              <br>
              <span class="text-muted"><small>PUID: {{ file_["OriginalPUID"] }}</small></span>
            {% else %}
              n/a
            {% endif %}
          </td>
          <td>
            {{ file_["Name"] }}
            <br>
            <span class="text-muted"><small>UUID: {{ file_["UUID"] }}</small></span>
          </td>
          <td>{{ file_["Format"] }}</td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  {% else %}
    <p class="h4" style="margin-top:20px;">No preservation derivatives to display.</p>
  {% endif %}

{% endblock %}
