{% extends "app_home/base.html" %}
{% load static %}
{% load i18n %}

{% block navbar_app %}
{% include 'app_home/_sidebar.html' %}
{% endblock %}

{% block title %}
<H2><i class="fa fa-archive"></i> {% translate 'ARCHIVE' %}</H2>
<small class="text-muted">{{ count }} {% translate "entries" %}</small>
<hr>
{% endblock %}


{% block content %}

{% if bigset %}
<div class="btn-group">

    <div>
    <form class="d-flex" role="search" action="" method="post">{% csrf_token %}
    <button class="btn btn-success" type="submit"><i class="fa fa-search"></i></button> &nbsp;&nbsp;
    <input class="form-control" type="search" name="query" placeholder="{% translate 'Filter' %}" value="{{ query }}">
    </form>
    </div>

    &nbsp;&nbsp;&nbsp;

    {% if page_last > 1 %}
    <div class="my-2">{% translate 'Page' %}</div>
    <div class="mx-3">
    <ul class="pagination mb-0">
      <li class="page-item"><a class="page-link" href="?page={{ page_prev }}&size={{ size }}">&laquo;</a></li>
      {% if page_first %}
      <li class="page-item"><a class="page-link active" href="?page=1&size={{ size }}">1</a></li>
      {% else %}
      <li class="page-item"><a class="page-link" href="?page=1&size={{ size }}">1</a></li>
      {% endif %}
      &nbsp;&nbsp;&nbsp;
      {% if page_current %}
      <li class="page-item"><a class="page-link active" href="?page={{ page }}&size={{ size }}">{{ page }}</a></li>
      {% else %}
      <li class="page-item"><a class="page-link disabled">...</a></li>
      {% endif %}
      &nbsp;&nbsp;&nbsp;
      {% if page_last_active %}
      <li class="page-item"><a class="page-link active" href="?page={{ page_last }}&size={{ size }}">{{ page_last }}</a></li>
      {% else %}
      <li class="page-item"><a class="page-link" href="?page={{ page_last }}&size={{ size }}">{{ page_last }}</a></li>
      {% endif %}
      <li class="page-item"><a class="page-link" href="?page={{ page_next }}&size={{ size }}">&raquo;</a></li>
    </ul>
    </div>
    {% endif %}

    <div>
      <a class="btn btn-outline-primary dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
      {{ size }} {% translate 'per page' %}</a>
      <div class="dropdown-menu">
        <a class="dropdown-item" href="{% url 'app_sirene:archive' %}?size=20">20</a>
        <a class="dropdown-item" href="{% url 'app_sirene:archive' %}?size=50">50</a>
        <a class="dropdown-item" href="{% url 'app_sirene:archive' %}?size=100">100</a>
        <a class="dropdown-item" href="{% url 'app_sirene:archive' %}?size=200">200</a>
        <a class="dropdown-item" href="{% url 'app_sirene:archive' %}?size=500">500</a>
        <a class="dropdown-item" href="{% url 'app_sirene:archive' %}?size=1000">1000</a>
      </div>
    </div>

</div>
{% endif %}

<hr>

<table class="table table-striped table-hover small">
    <thead class="thead-dark">
        <tr>
            <th>{% translate 'Date' %}</th>
            <th class="text-center">{% translate 'Severity' %}</th>
            <th class="text-center">{% translate 'Category' %}</th>
            <th>{% translate 'Title' %}</th>
            <th class="text-center">{% translate 'Public Page' %}</th>
            <th class="text-center">{% translate 'Restricted' %}</th>
        </tr>
    </thead>

{% for page in pages %}
    <tr>
        <td class="py-1 px-1 mx-0">
        <a class="text-decoration-none" href="{% url 'app_sirene:detail' page.id %}">
        {{ page.created_at }}
        </a>
        </td>

        <td class="py-1 text-center h6">
        <span class="badge text-bg-{{ page.bgcolor }} w-100">
            {{ page.severity }}</span>
        </td>

        <td class="py-1 px-1">{{ page.category }}</td>

        <td class="py-1 px-1">{{ page.displayname }}</td>

        <td class="py-1">{{ page.publicpage|default:'' }}</td>

        <td class="py-1">{{ page.is_restricted|yesno:"X,," }}</td>

    </tr>{% endfor %}
</table>

{% endblock %}


