{% set container = entity %}
{% set entity_view = "coverage" %}
{% set entity_type = "container" %}
{% import "entity_macros.html" as entity_macros %}
{% extends "entity_base.html" %}

{% block entity_main %}

<div class="ui centered grid">
  <div class="row">
    <div class="twelve wide column">
      <div class="ui large horizontal statistic">
        <div class="value">{{ "{:,}".format(container._stats.total) }}</div>
        <div class="label" style="text-transform: none;">Known Releases</div>
      </div>
      {% if container._stats.total >= 1 %}
        {{ entity_macros.preservation_bar(container._stats.preservation, extra_class="large") }}
        {{ entity_macros.preservation_table(container._stats.preservation) }}
      {% endif %}
      <p>
      {% if container.extra and container.extra.kbart %}
        There seem to be at least some "dark" preservation holdings in:
        {% for k, v in container.extra.kbart.items() %}
          <code>{{ k }}</code>{{ ", " if not loop.last }}
        {% endfor %}
        .
      {% endif %}
      {% if container.issnl %}
        Our metadata may not be up to date, but you can verify preservation holdings in <a href="https://keepers.issn.org/?q=api/search&search[]=MUST=allissn={{ container.issnl }}&search[]=MUST_EXIST=keepers">Keepers Registery</a> (click "Archival Status").
      {% endif %}
    </div>
  </div>
</div>

{% if container._stats.total >= 1 %}
  <br><br>
  <h2>Perpetual Access Coverage by Year</h2>

  <figure style="margin: 0 0 0 0;">
    <embed type="image/svg+xml" src="/container/{{ container.ident }}/preservation_by_year.svg" />
  </figure>

  <div style="float: right;">
    <a href="/container/{{ container.ident }}/preservation_by_year.json">Download as JSON</a>
  </div>

  <br><br>
  <h2>Perpetual Access Coverage by Volume</h2>

  <figure style="margin: 0 0 0 0;">
    <embed type="image/svg+xml" src="/container/{{ container.ident }}/preservation_by_volume.svg" />
  </figure>

  <div style="float: right;">
    <a href="/container/{{ container.ident }}/preservation_by_volume.json">Download as JSON</a>
  </div>

  <br><br>
  <h2>Perpetual Access Coverage by Release Type</h2>
  <table class="ui table">
    <thead>
      <tr>
        <th>Release Type
        <th class="right aligned">Total Count
        <th>Coverage
    </thead>
    <tbody>
      {% for type_row in container._type_preservation %}
      <tr>
        <td class="two wide">{{ type_row.release_type }}
        <td class="two wide right aligned">{{ "{:,}".format(type_row.total) }}
        <td class="twelve wide">{{ entity_macros.preservation_bar(type_row) }}
      {% endfor %}
    </tbody>
  </table>
{% endif %}

{% endblock %}