mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 02:13:12 -04:00
Make a macro for the AJAX update module
This is less repetitive than typing out the HTML with all its attributes every time. It also lets us wrap up the idea of ‘finished’ as a parameter, so the AJAX code will only be initiated when it’s needed, eg if a job is still processing.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
{% from "components/show-more.html" import show_more %}
|
||||
{% from "components/message-count-label.html" import message_count_label %}
|
||||
{% from "components/table.html" import list_table, field, right_aligned_field_heading, hidden_field_heading %}
|
||||
{% from "components/ajax-block.html" import ajax_block %}
|
||||
|
||||
{% block page_title %}
|
||||
{{ current_service.name }} – GOV.UK Notify
|
||||
@@ -29,30 +30,18 @@
|
||||
In the last 7 days
|
||||
</h2>
|
||||
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".service_dashboard_updates", service_id=current_service.id)}}"
|
||||
data-key="totals"
|
||||
data-interval-seconds="2"
|
||||
aria-live="polite"
|
||||
>
|
||||
{% call ajax_block(updates_url, 'totals') %}
|
||||
{% include 'views/dashboard/_totals.html' %}
|
||||
</div>
|
||||
{% endcall %}
|
||||
{{ show_more(
|
||||
url_for('.weekly', service_id=current_service.id),
|
||||
'Compare to previous weeks'
|
||||
) }}
|
||||
|
||||
{% if template_statistics|length %}
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".service_dashboard_updates", service_id=current_service.id)}}"
|
||||
data-key="template-statistics"
|
||||
data-interval-seconds="2"
|
||||
aria-live="polite"
|
||||
>
|
||||
{% call ajax_block(updates_url, 'template-statistics') %}
|
||||
{% include 'views/dashboard/template-statistics.html' %}
|
||||
</div>
|
||||
{% endcall %}
|
||||
{{ show_more(
|
||||
url_for('.template_history', service_id=current_service.id),
|
||||
'See all templates used this year'
|
||||
@@ -60,14 +49,9 @@
|
||||
{% endif %}
|
||||
|
||||
{% if jobs %}
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".service_dashboard_updates", service_id=current_service.id)}}"
|
||||
data-key="jobs"
|
||||
data-interval-seconds="2"
|
||||
aria-live="polite"
|
||||
>
|
||||
{% include 'views/dashboard/_jobs.html' %}
|
||||
{% call ajax_block(updates_url, 'jobs') %}
|
||||
{% include 'views/dashboard/_jobs.html' %}
|
||||
{% endcall %}
|
||||
{{ show_more(
|
||||
url_for('.view_jobs', service_id=current_service.id),
|
||||
'See all uploaded files'
|
||||
@@ -76,15 +60,9 @@
|
||||
|
||||
{% if current_user.has_permissions(['manage_settings'], admin_override=True) %}
|
||||
<h2 class='heading-medium'>This year</h2>
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".service_dashboard_updates", service_id=current_service.id)}}"
|
||||
data-key="usage"
|
||||
data-interval-seconds="2"
|
||||
aria-live="polite"
|
||||
>
|
||||
{% call ajax_block(updates_url, 'usage') %}
|
||||
{% include 'views/dashboard/_usage.html' %}
|
||||
</div>
|
||||
{% endcall %}
|
||||
{{ show_more(
|
||||
url_for(".usage", service_id=current_service['id']),
|
||||
'See usage breakdown'
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{% from "components/banner.html" import banner %}
|
||||
{% from "components/sms-message.html" import sms_message %}
|
||||
{% from "components/email-message.html" import email_message %}
|
||||
{% from "components/ajax-block.html" import ajax_block %}
|
||||
|
||||
{% block page_title %}
|
||||
{{ uploaded_file_name }} – GOV.UK Notify
|
||||
@@ -28,40 +29,16 @@
|
||||
)}}
|
||||
{% endif %}
|
||||
|
||||
<div
|
||||
{% if not finished %}
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job.id, status=status, help=request.args.get('help', 0))}}"
|
||||
data-key="status"
|
||||
aria-live="polite"
|
||||
{% endif %}
|
||||
>
|
||||
{% call ajax_block(updates_url, 'status', finished=finished) %}
|
||||
{% include 'partials/jobs/status.html' %}
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<div
|
||||
{% if not finished %}
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job.id, status=status, help=request.args.get('help', 0))}}"
|
||||
data-key="counts"
|
||||
aria-live="polite"
|
||||
{% endif %}
|
||||
>
|
||||
{% call ajax_block(updates_url, 'counts', finished=finished) %}
|
||||
{% include 'partials/jobs/count.html' %}
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<div
|
||||
{% if notifications %}
|
||||
class='dashboard-table'
|
||||
{% endif %}
|
||||
{% if not finished %}
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job.id, status=request.args.get('status'), help=request.args.get('help'))}}"
|
||||
data-key="notifications"
|
||||
aria-live="polite"
|
||||
{% endif %}
|
||||
>
|
||||
{% call ajax_block(updates_url, 'notifications', finished=finished) %}
|
||||
{% include 'partials/jobs/notifications.html' %}
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user