{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}

{% block title %}Rowsandall Recent Graphs{% endblock %}

{% block scripts %}
{% include "monitorjobs.html" %}
{% endblock %}

{% block main %}
<h1>Recent Graphs</h1>

<ul class="main-content">
	<li class="grid_2">
    <form id="searchform" action="."
          method="get" accept-charset="utf-8">
      {{ searchform }}
      <input type="submit" value="GO"></input>
    </form>
  </li>
  {% if graphs %}

  <li class="grid_2">
    <p>
      <span>
        {% if graphs.has_previous %}
        {% if request.GET.q %}
        <a href="?page=1&q={{ request.GET.q }}">
          <i class="fas fa-arrow-alt-to-left"></i>
        </a>
        <a href="?page={{ graphs.previous_page_number }}&q={{ request.GET.q }}">
          <i class="fas fa-arrow-alt-left"></i>
        </a>
        {% else %}
        <a href="?page=1">
          <i class="fas fa-arrow-alt-to-left"></i>
        </a>
        <a href="?page={{ graphs.previous_page_number }}">
          <i class="fas fa-arrow-alt-left"></i>
        </a>
        {% endif %}
        {% endif %}

        <span>
          Page {{ graphs.number }} of {{ graphs.paginator.num_pages }}.
        </span>

        {% if graphs.has_next %}
        {% if request.GET.q %}
        <a href="?page={{ graphs.next_page_number }}&q={{ request.GET.q }}">
          <i class="fas fa-arrow-alt-right"></i>
        </a>
        <a href="?page={{ graphs.paginator.num_pages }}&q={{ request.GET.q }}">
          <i class="fas fa-arrow-alt-to-right">
        </a>
        {% else %}
        <a href="?page={{ graphs.next_page_number }}">
          <i class="fas fa-arrow-alt-right"></i>
        </a>
        <a href="?page={{ graphs.paginator.num_pages }}">
          <i class="fas fa-arrow-alt-to-right"></i>
        </a>
        {% endif %}
        {% endif %}
      </span>
    </p>
  </li>
  {% for graph in graphs %}
  <li>
    <p class="caption">
      <a href="/rowers/graph/{{ graph.id }}/">
	<img src="/{{ graph.filename }}"
	     onerror="this.src='/static/img/rowingtimer.gif'"
	     alt="{{ graph.filename }}" width="120" height="100">
      </a>
    </p>
    <p class="caption">{{ graph.workout.name }}</p>
  </li>
  {% endfor %}
  {% else %}
  <li class="grid_4">
    <p>
      No charts found
    </p>
  </li>
  {% endif %}
</ul>

{% endblock %}

{% block sidebar %}
{% include 'menu_workouts.html' %}
{% endblock %}
