Files
atst/templates/audit_log.html
2018-11-13 17:06:29 -05:00

90 lines
2.8 KiB
HTML

{% extends "base.html" %}
{% block content %}
<section class="block-list">
<header class="block-list__header">
<h1 class="block-list__title">Activity History</h1>
</header>
<ul>
{% for event in audit_events %}
<li class="block-list__item">
<article class='audit-log__item'>
<div class='audit-log__item__timestamp'>
<local-datetime timestamp='{{ event.time_created }}'></local-datetime>
</div>
<div>
<h2 class='h4 audit-log__item__name'>
{{ event.user.full_name if event.user else "ATAT System" }}
</h2>
{{ event.action }} {{ event.resource_type }} <code>{{ event.resource_id }}</code>
{% if event.display_name %}
({{ event.display_name }})
{% endif %}
<br>
{% if event.workspace %}
in Workspace <code>{{ event.workspace_id }}</code> ({{ event.workspace.name }})
{% elif event.request %}
on Request <code>{{ event.request_id }}</code> ({{ event.request.displayname }})
{% endif %}
</div>
</article>
</li>
{% endfor %}
</ul>
</section>
{% macro Page(pagination, route, i, label=None) -%}
{% set label = label or i %}
{% if i == pagination.page %}
<button class="usa-button usa-button-primary">{{ label }}</button>
{% else %}
<a class="usa-button usa-button-secondary page" href="{{ url_for(route, page=i, perPage=pagination.per_page) }}">{{ label }}</a>
{% endif%}
{%- endmacro %}
{% macro Pagination(pagination, route) -%}
{% set first %}
{{ Page(pagination, route, 1, label="first") }}
{{ Page(pagination, route, pagination.page - 1, label="prev") }}
{% endset %}
{% set last %}
{{ Page(pagination, route, pagination.page + 1, label="next") }}
{{ Page(pagination, route, pagination.pages, label="last") }}
{% endset %}
<div class="pagination">
{% if pagination.page == 1 %}
{% set max_page = [pagination.pages, 5] | min %}
{% for i in range(1, max_page + 1) %}
{{ Page(pagination, route, i) }}
{% endfor %}
{{ last }}
{% elif pagination.page == pagination.pages %}
{{ first }}
{% for i in range(pagination.pages - 4, pagination.pages + 1) %}
{{ Page(pagination, route, i) }}
{% endfor %}
{% else %}
{% set window = pagination | pageWindow %}
{{ first }}
{% for i in range(window.0, window.1 + 1) %}
{{ Page(pagination, route, i) }}
{% endfor %}
{{ last }}
{% endif %}
</div>
{%- endmacro %}
{{ Pagination(audit_events, 'atst.activity_history') }}
{% endblock %}