{% extends "master.html" %}

{% block title %}Projects Monitored · Anitya{% endblock %}

{% block body %}

<div class="page-header">
  <h1>Projects {% if distroname %}of {{ distroname }} {% endif %}monitored</h1>
</div>

{% if distroname %}
{% set page_url = url_for('anitya_ui.distro', distroname=distroname) %}
{% else %}
{% set page_url = url_for('anitya_ui.projects') %}
{% endif %}

<div class="row show-grid">
  <div class="col-sm-6">
    {% if total_page > 1 %}
    <ul class="pagination pagination-sm">
        <li>
            {% if page > 1%}
              <a href="{{ page_url }}?page={{page - 1}}">
                «
              </a>
            {% else %}
              <a> « </a>
            {% endif %}
        </li>
        <li>
            <a> {{ page }} / {{ total_page }} </a>
        </li>
        <li>
            {% if page < total_page %}
              <a href="{{ page_url }}?page={{page + 1}}">
                »
              </a>
            {% else %}
              <a> » </a>
            {% endif %}
        </li>
    </ul>
    {% endif %}
  </div>

  <div class="col-sm-6">
    {% if distroname %}
    <form action="{{ url_for('anitya_ui.distro_projects_search', distroname=distroname)}}" role="form" class="form-inline">
    {% else %}
    <form action="{{ url_for('anitya_ui.projects_search') }}" role="form" class="form-inline">
    {% endif %}
      <div class="form-group">
        <input type="text" name="pattern" placeholder="Project name" class="form-control input-sm"/>
        <button type="submit" class="btn btn-sm btn-default">
          Search {% if distroname %} {{ distroname }} {% endif %}
        </button>
      </div>
    </form>
  </div>
</div>

<div class="row">
  <p>{{ projects_count }} projects found</p>
  <div class="list-group">
    {% if projects %}
    <span class="list-group-item">
      <h4 class="list-group-item-heading">
        <table class="table table-condensed">
            <tr>
              <th>Name</th>
              <th>Homepage</th>
              <th>Backend</th>
            </tr>
        {% for project in projects %}
            <tr>
              <td>
                <a href="{{ url_for('anitya_ui.project', project_id=project.id) }}">
                {{project.name}}
                </a>
              </td>
              <td>
                <a href="{{ project.homepage }}" target="_blank" rel="noopener noreferrer">
                  {{ project.homepage }}
                </a>
              </td>
              <td>{{ project.backend }}</td>
            </tr>
          {% endfor %}
          </table>
      </h4>
      <div class="clearfix"></div>
    </span>
  {% else %}
  <blockquote>
      Oups this is embarrassing, it seems that no projects are being
      monitored currently.
  </blockquote>
  {% endif %}
  </div>
</div>

<div class="row show-grid">
  <div class="col-sm-6">
    {% if total_page > 1 %}
    <ul class="pagination pagination-sm">
        <li>
            {% if page > 1%}
              <a href="{{ page_url }}?page={{page - 1}}">
                «
              </a>
            {% else %}
              <a> « </a>
            {% endif %}
        </li>
        <li>
            <a> {{ page }} / {{ total_page }} </a>
        </li>
        <li>
            {% if page < total_page %}
              <a href="{{ page_url }}?page={{page + 1}}">
                »
              </a>
            {% else %}
              <a> » </a>
            {% endif %}
        </li>
    </ul>
    {% endif %}
  </div>
</div>
{% endblock %}
