Put uploaded files on the dashboard

This commit depends on and uses the data returned by:
- [x] https://github.com/alphagov/notifications-api/pull/345
- [x] https://github.com/alphagov/notifications-api/pull/347
- [x] https://github.com/alphagov/notifications-admin/pull/612

It puts the last 5 jobs on the dashboard. This should be changed to all the jobs
from the last 7 days when that parameter is available.

It also:
- links to the jobs page
- makes the numbers on the jobs page consistent with the dashboard
- makes the numbers on an individual job consistent with the appearance of the
  dashboard
This commit is contained in:
Chris Hill-Scott
2016-05-25 13:36:35 +01:00
parent fe38a46798
commit 16d83faa72
14 changed files with 130 additions and 107 deletions

View File

@@ -14,7 +14,7 @@
{% if label_link %}
<a class="big-number-label" href="{{ label_link }}">{{ label }}</a>
<a class="big-number-overlay-link" href="{{ label_link }}" aria-hidden="true"></a>
{% else %}
{% elif label %}
<span class="big-number-label">{{ label }}</span>
{% endif %}
</div>

View File

@@ -1,9 +1,9 @@
{% from "components/big-number.html" import big_number %}
<div
{% if not finished_at %}
{% if not finished %}
data-module="update-content"
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job_id)}}"
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job.id)}}"
data-key="counts"
aria-live="polite"
{% endif %}
@@ -12,12 +12,17 @@
<ul class="grid-row job-totals">
<li class="column-one-quarter">
{{ big_number(
counts.queued, 'queued'
job.get('notifications_sent', 0) - job.get('notifications_delivered', 0) - job.get('notifications_failed', 0), 'sending'
)}}
</li>
<li class="column-one-quarter">
{{ big_number(
counts.sent, 'processed'
job.get('notifications_delivered', 0), 'delivered'
)}}
</li>
<li class="column-one-quarter">
{{ big_number(
job.notifications_failed, 'failed'
)}}
</li>
</ul>

View File

@@ -1,9 +1,9 @@
{% from "components/table.html" import list_table, field, right_aligned_field_heading %}
<div
{% if not finished_at %}
{% if not finished %}
data-module="update-content"
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job_id)}}"
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job.id)}}"
data-key="notifications"
aria-live="polite"
{% endif %}

View File

@@ -1,12 +1,12 @@
<div
{% if not finished_at %}
{% if not finished %}
data-module="update-content"
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job_id)}}"
data-resource="{{url_for(".view_job_updates", service_id=current_service.id, job_id=job.id)}}"
data-key="status"
aria-live="polite"
{% endif %}
>
<p class='heading-small'>
Sent by {{ created_by }} on {{ uploaded_at|format_datetime_short }}
Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }}
</p>
</div>

View File

@@ -0,0 +1,35 @@
{% from "components/table.html" import list_table, field, right_aligned_field_heading %}
{% from "components/big-number.html" import big_number %}
{% call(item, row_number) list_table(
jobs,
caption="Recent batch jobs",
caption_visible=False,
empty_message='You havent sent any batch messages yet',
field_headings=[
'File',
right_aligned_field_heading('Sending'),
right_aligned_field_heading('Delivered'),
right_aligned_field_heading('Failed')
],
field_headings_visible=True
) %}
{% call field() %}
<div class="file-list">
<a class="file-list-filename" href="{{ url_for('.view_job', service_id=current_service.id, job_id=item.id) }}">{{ item.original_file_name }}</a>
<span class="file-list-hint">Uploaded {{ item.created_at|format_datetime_short }}</span>
</div
{% endcall %}
{% call field(align='right') %}
{{ big_number(
item.get('notifications_sent', 0) - item.get('notifications_delivered', 0) - item.get('notifications_failed', 0),
smaller=True
) }}
{% endcall %}
{% call field(align='right') %}
{{ big_number(item.get('notifications_delivered', 0), smaller=True) }}
{% endcall %}
{% call field(align='right', status='error' if 0 else '') %}
{{ big_number(item.get('notifications_failed', 0), smaller=True) }}
{% endcall %}
{% endcall %}

View File

@@ -8,9 +8,10 @@
) %}
{% call field() %}
<a href="{{ url_for('.view_job', service_id=current_service.id, job_id=item.id) }}">{{ item.original_file_name }}</a>
{{ item.created_at|format_datetime }}
{% endcall %}
{% call field() %}
{{ item.created_at|format_datetime }}
{% endcall %}
{% call field(align='right') %}
{{ item.notification_count }}

View File

@@ -1,6 +1,7 @@
{% from "components/big-number.html" import big_number, big_number_with_status %}
{% 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 %}
<div
data-module="update-content"
@@ -39,7 +40,7 @@
) }}
</div>
</div>
{% if template_statistics|length %}
{% include 'views/dashboard/template-statistics.html' %}
{{ show_more(
@@ -48,8 +49,16 @@
) }}
{% endif %}
{% if jobs %}
{% include 'views/dashboard/_jobs.html' %}
{{ show_more(
url_for('.view_jobs', service_id=current_service.id),
'See all uploaded files'
) }}
{% endif %}
{% if current_user.has_permissions(['manage_settings'], admin_override=True) %}
<h2 class='heading-medium'>This year</h2>
<h2 class='heading-medium'>This year</h2>
<div class='grid-row'>
<div class='column-half'>

View File

@@ -1,44 +1,12 @@
{% extends "withnav_template.html" %}
{% from "components/table.html" import list_table, field, right_aligned_field_heading %}
{% block page_title %}
Notifications activity GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Notifications activity</h1>
<p>
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, page=1) }}">All messages</a>
</p>
<p>
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, type="sms", page=1) }}">Text messages</a>&emsp;
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, type="email", page=1) }}">Email messages</a>
</p>
<p>
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, status=['sent', 'delivered'], page=1) }}">Successful messages</a>&emsp;
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, status=['failed', 'complaint', 'bounce'], page=1) }}">Failed messages</a>
</p>
{% call(item, row_number) list_table(
jobs,
caption="Recent activity",
caption_visible=False,
empty_message='You havent sent any notifications yet',
field_headings=['Job', 'Time', 'Uploaded by', right_aligned_field_heading('Status')]
) %}
{% call field() %}
<a href="{{ url_for('.view_job', service_id=current_service.id, job_id=item.id) }}">{{ item.original_file_name }}</a>
{% endcall %}
{% call field() %}
{{ item.created_at | format_datetime}}
{% endcall %}
{% call field() %}
{{ item.created_by.name }}
{% endcall %}
{% call field(align='right') %}
{{ item.status }}
{% endcall %}
{% endcall %}
<h1 class="heading-large">Uploaded files</h1>
<div class="dashboard">
{% include 'views/dashboard/_jobs.html' %}
</div>
{% endblock %}