Only show the filters if they will have an effect

If you never create any API keys we shouldn’t give you the option to see
API-related events – it will only confuse things.

And since there’s (currently) only one type of event left once you take
API key events out of the picture it doesn’t make sense to show the
filters at all.
This commit is contained in:
Chris Hill-Scott
2019-10-21 13:42:28 +01:00
parent 63f6a3ab12
commit 9055a33dca
2 changed files with 20 additions and 12 deletions

View File

@@ -4,17 +4,21 @@ from flask import render_template, request
from app import current_service, format_date_numeric
from app.main import main
from app.models.event import APIKeyEvents, ServiceEvents
from app.models.event import APIKeyEvent, APIKeyEvents, ServiceEvents
from app.utils import user_has_permissions
@main.route("/services/<service_id>/history")
@user_has_permissions('manage_service')
def history(service_id):
events = _get_events(current_service.id, request.args.get('selected'))
return render_template(
'views/temp-history.html',
days=_chunk_events_by_day(
_get_events(current_service.id, request.args.get('selected'))
days=_chunk_events_by_day(events),
show_navigation=request.args.get('selected') or any(
isinstance(event, APIKeyEvent) for event in events
)
)

View File

@@ -11,15 +11,19 @@
{{ page_header("Audit events") }}
{{ pill(
[
('All', None, url_for('main.history', service_id=current_service.id), None),
('Service', '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
) }}
{% 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">