{% extends "base.html" %}

{% block head_content %}
  <script defer type="text/javascript" language="javascript" src="{{ url_for('static', filename='js/reporter/reports.js') }}"></script>
{% endblock %}

{% block content %}

<div class="alert alert-header"><strong>Reports</strong></div>

{% if storage_services %}

  <!-- First row: Storage Service and Start date -->
  <div class="report-opts">
    <div>
      <span class="fixed-width-menu-span-left">
        <i class="fa-solid fa-database" aria-hidden="true"></i>
        Storage Service
      </span>
      <select id="ss" method="GET" action="/">
          {% for ss in storage_services %}
            {% if ss.id == storage_service.id %}
              <option value="{{ ss.id }}" SELECTED>{{ ss.name }}</option>
            {% else %}
              <option value="{{ ss.id }}">{{ ss.name }}</option>
            {% endif %}
          {% endfor %}
      </select>
    </div>
    <div>
      <span class="fixed-width-menu-span-right">
        <i class="fa-solid fa-calendar-days" aria-hidden="true"></i>
            Start date
      </span>
      <input type="text" id="startdate" value="{{ start_date }}">
    </div>
  </div>
  <!-- Second row: Location and End date -->
  <div class="report-opts">
    <div>
      <span class="fixed-width-menu-span-left">
        <i class="fa-solid fa-box-archive" aria-hidden="true"></i>
        Storage Location
      </span>
      <select id="sl" method="GET" action="/">
          <option value="">All locations</option>
          {% for sl in storage_locations %}
            {% if sl.id == storage_location.id %}
              <option value="{{ sl.id }}" SELECTED>{{ sl.description }}</option>
            {% else %}
              <option value="{{ sl.id }}">{{ sl.description }}</option>
            {% endif %}
          {% endfor %}
      </select>
    </div>
    <div>
      <span class="fixed-width-menu-span-right">
        <i class="fa-solid fa-calendar-days" aria-hidden="true"></i>
            End date
      </span>
      <input type="text" id="enddate" value="{{ end_date }}">
    </div>
  </div>

  <!-- Original file formats indicates data has been fetched for this Storage Service -->
  {% if original_file_formats %}

  <table class="table table-striped table-bordered" style="margin-top: 1.25rem;">

      <tr class="table-header">
          <th>Report</th>
          <th>Description</th>
          <th>Format</th>
      </tr>

      <tr>
          <td>
              <strong>Storage locations</strong>
          </td>
          <td><span class="text-muted"><span class="text-muted">List all locations in this Storage Service, including total AIPs and storage volume.
            <br>Filter by date range.</span></span></td>
          <td>
              <a href="#"><button type="button" id="storageLocations" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a>
              <a href="#"><button type="button" id="storageLocationsTimeseries" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Time Series</button></a>
          </td>
      </tr>

      <tr>
          <td>
            <strong>Largest AIPs</strong>
            <br><input id="largestAipsLimit" value="20">
          </td>
          <td>
            <span class="text-muted">Top</span> <span class="text-muted font-italic">n</span> <span class="text-muted">largest AIPs in the Storage Service.
            <br>Filter by date range and storage location.</span>
          </td>
          <td><a href="#"><button type="button" id="largestAIPs" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      <tr>
          <td>
            <strong>Largest files</strong>
            <br><input id="largestFilesLimit" value="20">
          </td>
          <td>
            <span class="text-muted">Top</span> <span class="text-muted font-italic">n</span> <span class="text-muted">largest files in the Storage Service.
            <br>Filter by date range and storage location.
            <br>Filter by originals or preservation copies (in report).</span>
          </td>
          <td><a href="#"><button type="button" id="largestFiles" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      <tr>
          <td><strong>File format count</strong></td>
          <td><span class="text-muted">Number of files per format and the volume of storage each uses.
            <br>Filter by date range and storage location.</span></td>
          <td><a href=""><button type="button" id="report1a" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a><a href=""><button type="button" id="report1b" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Pie Chart</button></a><a href=""><button type="button" id="report1c" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Scatter Plot</button></a></td>
      </tr>

      <tr>
          <td><strong>Format version count</strong></td>
          <td><span class="text-muted"><span class="text-muted">Number of files per format version (PUID) and the volume of storage each uses.
            <br>Filter by date range and storage location.</span></td>
          <td><a href="#"><button type="button" id="report3a" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      <tr>
          <td><strong>AIP contents</strong>
        </td>
          <td><span class="text-muted">Types of file formats in AIPs, including file count per format. 
            <br>Filter by date range and storage location.</span></td>
        <td><a href="#"><button type="button" id="aipContents" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      <tr>
          <td>
              <strong>AIPs by original format</strong>
              <br>
              <select id="originalFormatSelect" method="GET" action="/" class="form-control" style="width:90%;">
              {% for file_format in original_file_formats %}
                <option value="{{ file_format }}">{{ file_format }}</option>
              {% endfor %}
            </select>
          </td>
          <td>
             <span class="text-muted">AIPs containing original files in the selected format.
              <br>Filter by storage location.</span>
          </td>
          <td><a href="#"><button type="button" id="aipsByOriginalFormat" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      {% if preservation_file_formats %}
          <tr>
              <td>
                  <strong>AIPs by preservation format</strong>
                  <br>
                   <select id="preservationFormatSelect" method="GET" action="/" class="form-control" style="width:90%;">
                  {% for file_format in preservation_file_formats %}
                    <option value="{{ file_format }}">{{ file_format }}</option>
                  {% endfor %}
                </select>
              </td>
              <td>
                    <span class="text-muted">AIPs containing preservation copies in the selected format.
                    <br>Filter by storage location.</span>
              </td>
              <td><a href="#"><button type="button" id="aipsByPreservationFormat" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
          </tr>
      {% endif %}

      <tr>
          <td>
              <strong>AIPs by PUID</strong>
              <br>
              <select id="originalPUIDSelect" method="GET" action="/" class="form-control" style="width:90%;">
              {% for puid in original_puids %}
                <option value="{{ puid }}">{{ puid }}</option>
              {% endfor %}
            </select>
          </td>
          <td>
            <span class="text-muted">AIPs containing original files matching the selected PRONOM Unique Identifier (file format versions)
              <br>Filter by storage location.</span>
          </td>
          <td><a href="#"><button type="button" id="aipsByOriginalPUID" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      {% if preservation_puids %}
          <tr>
              <td>
                  <strong>AIPs by preservation copy PUID</strong>
                  <br>
                  <select id="preservationPUIDSelect" method="GET" action="/" class="form-control" style="width:90%;">
                  {% for puid in preservation_puids %}
                    <option value="{{ puid }}">{{ puid }}</option>
                  {% endfor %}
                </select>
              </td>

          <td>
            <span class="text-muted">AIPs containing preservation copies matching the selected PRONOM Unique Identifier (file format versions).
              <br>Filter by storage location.</span>
          </td>

          <td><a href="#"><button type="button" id="aipsByPreservationPUID" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
          </tr>
      {% endif %}

      <tr>
          <td><strong>Preservation derivatives</strong></td>
          <td><span class="text-muted"><span class="text-muted">Map original files to their preservation copy counterpart.
            <br>Filter by storage location.
            <br>Filter by AIP (in report).</td>
          <td><a href="#"><button type="button" id="preservationDerivatives" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a></td>
      </tr>

      <tr>
          <td><strong>User ingest log</strong></td>
          <td><span class="text-muted">List all Archivematica ingest events, per user.
            <br>Filter by date range and storage location.</span></td>
          <td>
              <a href="#"><button type="button" id="transferLogTabular" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Tabular</button></a>
              <a href="#"><button type="button" id="transferLogGantt" class="btn btn-info" style="margin-left:5px; margin-bottom:5px;">Gantt Chart</button></a>
          </td>
      </tr>

  </table>

  {% else %}

  <div style="padding:1em;">
      No data available. Run a Fetch Job to populate AIPscan with data from this Storage Service or select a different Storage Service.
  </div>

  {% endif %}

{% else %}

  <div style="padding:1em;">
      Storage Service information is not yet available for reporting. <a href="{{ url_for('aggregator.storage_services') }}">Configure a Storage Service</a> and run a Fetch Job to get started.</a>
  </div>

{% endif %}

{% endblock %}
