mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
This is a first go at having the job page update without refreshing. The approach I’ve taken is to do all the rendering of HTML on the server side, rather than use a Javascipt templating engine like mustache. This ensures that we don’t have to maintain two sets of templates. So the approach is to split the job page into partials. These partials can then: - be included in the job page to render the whole page - be rendered indivudually and then returned as a blob of HTML inside a JSON response Then I’ve added a Javascript module which looks for areas of the page that should be reloaded. For each area of the page it will poll a URL and re-render that section of the page when it gets new HTML. It implements some throttling so that API calls will never happen more frequently than 0.67 times/second.
70 lines
1.9 KiB
HTML
70 lines
1.9 KiB
HTML
{% extends "withnav_template.html" %}
|
||
{% from "components/banner.html" import banner %}
|
||
{% from "components/sms-message.html" import sms_message %}
|
||
{% from "components/email-message.html" import email_message %}
|
||
|
||
{% block page_title %}
|
||
{{ uploaded_file_name }} – GOV.UK Notify
|
||
{% endblock %}
|
||
|
||
{% block maincolumn_content %}
|
||
|
||
<h1 class="heading-large">
|
||
{{ uploaded_file_name }}
|
||
</h1>
|
||
|
||
{% if 'sms' == template.template_type %}
|
||
<div class="grid-row">
|
||
<div class="column-two-thirds">
|
||
{{ sms_message(
|
||
template.formatted_as_markup,
|
||
)}}
|
||
</div>
|
||
</div>
|
||
{% elif 'email' == template.template_type %}
|
||
{{ email_message(
|
||
template.subject,
|
||
template,
|
||
from_address='{}@notifications.service.gov.uk'.format(service.email_from),
|
||
from_name=from_name
|
||
)}}
|
||
{% endif %}
|
||
|
||
{% if not finished_at %}
|
||
<div
|
||
data-module="update-content"
|
||
data-resource="{{url_for(".view_job_updates", service_id=service_id, job_id=job_id)}}"
|
||
data-key="status"
|
||
>
|
||
{% endif %}
|
||
{% include 'partials/jobs/status.html' %}
|
||
{% if not finished_at %}
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% if not finished_at %}
|
||
<div
|
||
data-module="update-content"
|
||
data-resource="{{url_for(".view_job_updates", service_id=service_id, job_id=job_id)}}"
|
||
data-key="counts"
|
||
>
|
||
{% endif %}
|
||
{% include 'partials/jobs/count.html' %}
|
||
{% if not finished_at %}
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% if not finished_at %}
|
||
<div
|
||
data-module="update-content"
|
||
data-resource="{{url_for(".view_job_updates", service_id=service_id, job_id=job_id)}}"
|
||
data-key="notifications"
|
||
>
|
||
{% endif %}
|
||
{% include 'partials/jobs/notifications.html' %}
|
||
{% if not finished_at %}
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% endblock %}
|