{% extends "report_base.html" %}

{% block content %}

<div class="alert alert-secondary">

  {% include "report_buttons.html" %}

  <strong>Report: Largest files</strong>
  <br>
  <strong>Storage Service:</strong> {{ storage_service_name }}
  <br>
  {% if storage_location_description %}
    <strong>Location:</strong> {{ storage_location_description }}
    <br>
  {% endif %}
  {% if file_type == "original" %}
    <strong>File type:</strong> Original files
  {% elif file_type == "preservation" %}
    <strong>File type:</strong> Preservation files
  {% else %}
    <strong>File type:</strong> All files
  {% endif %}
  <br>
  <strong>Start date:</strong> {{ start_date.strftime('%Y-%m-%d') }}
  <br>
  <strong>End date:</strong> {{ end_date.strftime('%Y-%m-%d') }}
  <br>

  <!-- 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>
  <span id="startDate" style="display:none;">{{ start_date.strftime('%Y-%m-%d') }}</span>
  <span id="endDate" style="display:none;">{{ end_date.strftime('%Y-%m-%d') }}</span>
  <span id="limit" style="display:none;">{{ limit }}</span>
</div>

<div class="noprint" style="margin-bottom: 10px;">
  <strong>File type:</strong>
  <select id="fileTypeSelector" class="form-control" style="width:auto;">
  {% if file_type == "original" %}
    <option value="all">All files</option>
    <option value="original" selected>Original files</option>
    <option value="preservation">Preservation files</option>
  {% elif file_type == "preservation" %}
    <option value="all">All files</option>
    <option value="original">Original files</option>
    <option value="preservation" selected>Preservation files</option>
  {% else %}
    <option value="all" selected>All files</option>
    <option value="original">Original files</option>
    <option value="preservation">Preservation files</option>
  {% endif %}
  </select>
</div>

{% if files %}
  <table id="largest-files-1" class="table table-striped table-bordered">
  	<thead>
      <tr>
      {% for column in columns %}
        <th>{{ column }}</th>
      {% endfor %}
      </tr>
    </thead>
    <tbody>
      {% for file_ in files %}
        <tr>
          <td>
            {{ file_["Name"] }}
            <br>
            <span class="text-muted"><small>UUID: {{ file_["UUID"] }}</small></span>
          </td>
          <td>{{ file_["Size"] | filesizeformat }}</td>
          {% if file_["Version"] %}
            <td>{{ file_["Format"] }} ({{ file_["Version"] }})</td>
          {% else %}
            <td>{{ file_["Format"] }}</td>
          {% endif %}
          {% if file_["PUID"] %}
            <td>{{ file_["PUID"] }}</td>
          {% else %}
            <td>n/a</td>
          {% endif %}
          <td>{{ file_["FileType"] }}</td>
          <td>
            {{ file_["AIPName"] }}
            <br>
            <span class="text-muted"><small>UUID: {{ file_["AIPUUID"] }}</small></span>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% else %}
  <p class="h4" style="margin-top:20px;">No files to display.</p>
{% endif %}

</div>

{% endblock %}
