{% extends "master.html" %}

{% block title %}Logs · Anitya{% endblock %}

{%block header %}
{% if refresh %}
<meta http-equiv="refresh" content="5" >
{% endif %}
{% endblock %}


{% block body %}

<div class="page-header">
  <h1>Logs</h1>
  {% if refresh %}
  <p>This page should refresh automatically every 5 seconds</p>
  <a href="{{ url_for('anitya_ui.browse_logs') }}?page={{page}}">
    <button type="submit" class="btn btn-danger" id="checknow">
      <span class="glyphicon glyphicon-remove-sign"></span>
      Remove auto-refresh
    </button>
  </a>
  {% else %}
  <a href="{{ url_for('anitya_ui.browse_logs') }}?page={{page}}&refresh=True">
    <button type="submit" class="btn btn-success" id="checknow">
      <span class="glyphicon glyphicon-refresh"></span>
      Activate auto-refresh
    </button>
  </a>
  {% endif %}
</div>

<div class="row show-grid">
  <div class="col-sm-4">
    {% if total_page > 1 %}
    <ul class="pagination pagination-sm">
        <li>
            {% if page > 1 %}
              <a href="{{ url_for('anitya_ui.browse_logs', page=page-1) }}">
                «
              </a>
            {% else %}
              <a> « </a>
            {% endif %}
        </li>
        <li>
            <a> {{ page }} / {{ total_page }} </a>
        </li>
        <li>
            {% if page < total_page %}
              <a href="{{ url_for('anitya_ui.browse_logs', page=page+1) }}">
                »
              </a>
            {% else %}
              <a> » </a>
            {% endif %}
        </li>
    </ul>
    {% endif %}
  </div>

</div>

<table class="table table-striped logs-table-seperator">
    <tr>
        <th>Name</th>
        <th>Updated</th>
        <th>Status</th>
        <th>Description</th>
    </tr>
{% for project in projects %}
    <tr>
        <td>
            <a href="{{ url_for('anitya_ui.project', project_id=project.id) }}">
              {{ project.name }}</a>
        </td>
        <td width="240px">
            {{ project.last_check.strftime('%Y-%m-%d %H:%M:%S') }} (UTC)
        </td>
        {% if project.check_successful is none %}
        <td>Not updated</td>
        {% elif not project.check_successful %}
        <td style="color:red;">Fail</td>
        {% else %}
        <td style="color:green;">OK</td>
        {% endif %}
        <td>{{ project.logs }}</td>
    </tr>
{% endfor %}
</table>

{% endblock %}

{% block jscript %}
{{ super() }}
{% endblock %}
