{% extends 'layout_repo.html' %}
{% from 'include/empty.html' import empty %}
{% from 'components/log.html' import pre_code %}
{% set active_page='repo' %}
{% set active_repo_page='logs' %}
{% block title %}
  {% trans %}Repository Logs{% endtrans %}
{% endblock %}
{% block content %}
  <div class="row">
    <div class="col-md-3">
      <ul class="list-group">
        <a href="{{ url_for('logs', repo, file='backup.log', limit=limit) }}"
           class="list-group-item{% if file=='backup.log' %} active{% endif %}">Backup Log</a>
        <a href="{{ url_for('logs', repo, file='restore.log', limit=limit) }}"
           class="list-group-item{% if file=='restore.log' %} active{% endif %}">Restore Log</a>
        {% for e in error_logs %}
          <a href="{{ url_for('logs', repo, date=e.date, limit=limit) }}"
             class="list-group-item{% if e.date==date %} active{% endif %}">
            Error log <time class="js-datetime" datetime="{{ e.date }}">{{ e.date | lastupdated }}</time>
            {% if not e.is_empty %}
              <span class="badge badge-warning">not empty</span>
            {% else %}
              <span class="badge badge-info">empty</span>
            {% endif %}
          </a>
        {% endfor %}
        {% if limit == error_logs|count %}
          <a href="{{ url_for('logs', repo, limit=limit * 2) }}"
             class="list-group-item">{% trans %}Show more...{% endtrans %}</a>
        {% endif %}
      </ul>
    </div>
    <div class="col-md-9">
      {% if data %}
        <div class="alert alert-info">
          {% trans %}Notice: To prevent performance issues, only the last 2000 lines of each log files are displayed.{% endtrans %}
          <a href="{{ url_for('logs', repo, file=file, date=date, raw=1)}}"><b><i class="icon icon-download"></i>{% trans %}Show all logs{% endtrans %}</b></a>
        </div>
        {{ pre_code(data)}}
      {% elif file or date %}
        {% call empty('icon-file', _('Log file empty')) %}
          <p>{% trans %}This log file is empty. Select another log file to show it's contents.{% endtrans %}</p>
        {% endcall %}
      {% else %}
        {% call empty('icon-file', _('No log file selected')) %}
          <p>{% trans %}Select a log file to show it's contents.{% endtrans %}</p>
        {% endcall %}
      {% endif %}
    </div>
  </div>
  <!-- /.row -->
{% endblock %}
