diff --git a/app/main/views/history.py b/app/main/views/history.py index 08f696494..2512cfe72 100644 --- a/app/main/views/history.py +++ b/app/main/views/history.py @@ -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//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 ) ) diff --git a/app/templates/views/temp-history.html b/app/templates/views/temp-history.html index 47c3e24f3..2047e6236 100644 --- a/app/templates/views/temp-history.html +++ b/app/templates/views/temp-history.html @@ -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 %} +
+ {{ 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 + ) }} +
+ {% endif %} {% for day, events in days %}