{% extends "withnav_template.html" %}
{% from "components/page-header.html" import page_header %}
{% from "components/table.html" import list_table, field %}
{% from "components/pill.html" import pill %}

{% block service_page_title %}
  Audit events
{% endblock %}

{% block maincolumn_content %}

  {{ page_header("Audit events") }}

  {% if show_navigation %}
    <div class="bottom-gutter">
      {{ pill(
        [
          ('All', None, url_for('main.history', service_id=current_service.id), None),
          ('Service settings', 'service', url_for('main.history', service_id=current_service.id, selected='service'), None),
          ('API keys', 'api', url_for('main.history', service_id=current_service.id, selected='api'), None),
        ],
        request.args.get('selected'),
        show_count=False
      ) }}
    </div>
  {% endif %}

  {% for day, events in days %}
    <h2 class="heading-small top-gutter">
      {{ events[0].time|format_date_human|title }}
    </h2>
    <ul class="bottom-gutter">
      {% for event in events %}
        <li class="history-list-item">
          <div class="grid-row">
            <div class="grid-col-4">
              <div class="history-list-user">
                {{ user_getter(event.user_id) }}
              </div>
              <div class="history-list-time">
                {{ event.time | format_time_24h }}
              </div>
            </div>
            <div class="grid-col-8">
              {{ event }}
            </div>
        </li>
      {% endfor%}
    </ul>
  {% endfor %}

{% endblock %}
