mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Merge pull request #1520 from gov-cjwaszczuk/master
Added letters info to service / admin dashboard & activity page
This commit is contained in:
@@ -42,7 +42,8 @@
|
||||
position: relative;
|
||||
margin-bottom: $gutter-two-thirds;
|
||||
|
||||
.big-number {
|
||||
.big-number,
|
||||
.big-number-smaller {
|
||||
padding: $gutter-half;
|
||||
position: relative;
|
||||
background: $black;
|
||||
|
||||
@@ -215,6 +215,7 @@ def get_dashboard_partials(service_id):
|
||||
for job in job_api_client.get_jobs(service_id, limit_days=7, statuses=statuses_to_display)['data']
|
||||
]
|
||||
service = service_api_client.get_detailed_service(service_id)
|
||||
column_width = 'column-third' if 'letter' in current_service['permissions'] else 'column-half'
|
||||
|
||||
return {
|
||||
'upcoming': render_template(
|
||||
@@ -231,7 +232,8 @@ def get_dashboard_partials(service_id):
|
||||
'totals': render_template(
|
||||
'views/dashboard/_totals.html',
|
||||
service_id=service_id,
|
||||
statistics=get_dashboard_totals(service['data']['statistics'])
|
||||
statistics=get_dashboard_totals(service['data']['statistics']),
|
||||
column_width=column_width
|
||||
),
|
||||
'template-statistics': render_template(
|
||||
'views/dashboard/template-statistics.html',
|
||||
|
||||
@@ -225,7 +225,7 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
page = get_page_from_request()
|
||||
if page is None:
|
||||
abort(404, "Invalid page argument ({}) reverting to page 1.".format(request.args['page'], None))
|
||||
if message_type not in ['email', 'sms']:
|
||||
if message_type not in ['email', 'sms', 'letter']:
|
||||
abort(404)
|
||||
filter_args = _parse_filter_args(request.args)
|
||||
filter_args['status'] = _set_status_filters(filter_args)
|
||||
@@ -243,7 +243,6 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
headers={
|
||||
'Content-Disposition': 'inline; filename="notifications.csv"'}
|
||||
)
|
||||
|
||||
notifications = notification_api_client.get_notifications_for_service(
|
||||
service_id=service_id,
|
||||
page=page,
|
||||
|
||||
@@ -103,11 +103,16 @@ def create_global_stats(services):
|
||||
'delivered': 0,
|
||||
'failed': 0,
|
||||
'requested': 0
|
||||
},
|
||||
'letter': {
|
||||
'delivered': 0,
|
||||
'failed': 0,
|
||||
'requested': 0
|
||||
}
|
||||
}
|
||||
|
||||
for service in services:
|
||||
for msg_type, status in itertools.product(('sms', 'email'), ('delivered', 'failed', 'requested')):
|
||||
for msg_type, status in itertools.product(('sms', 'email', 'letter'), ('delivered', 'failed', 'requested')):
|
||||
stats[msg_type][status] += service['statistics'][msg_type][status]
|
||||
|
||||
for stat in stats.values():
|
||||
|
||||
@@ -49,7 +49,6 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
else:
|
||||
if limit_days is not None:
|
||||
params['limit_days'] = limit_days
|
||||
|
||||
return self.get(
|
||||
url='/service/{}/notifications'.format(service_id),
|
||||
params=params
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
danger_zone=False,
|
||||
failure_link=None,
|
||||
link=None,
|
||||
show_failures=True
|
||||
show_failures=True,
|
||||
smaller=False,
|
||||
smallest=False
|
||||
) %}
|
||||
<div class="big-number-with-status">
|
||||
{{ big_number(number, label, link=link) }}
|
||||
{{ big_number(number, label, link=link, smaller=smaller, smallest=smallest) }}
|
||||
{% if show_failures %}
|
||||
<div class="big-number-status{% if danger_zone %}-failing{% endif %}">
|
||||
{% if failures %}
|
||||
|
||||
@@ -126,17 +126,23 @@
|
||||
{% if notification.status|format_notification_status_as_url %}
|
||||
<a href="{{ notification.status|format_notification_status_as_url }}">
|
||||
{% endif %}
|
||||
{{ notification.status|format_notification_status(
|
||||
notification.template.template_type
|
||||
) }}
|
||||
{% if notification['notification_type'] != "letter" %}
|
||||
{{ notification.status|format_notification_status(
|
||||
notification.template.template_type
|
||||
) }}
|
||||
{% endif %}
|
||||
{% if notification.status|format_notification_status_as_url %}
|
||||
</a>
|
||||
{% endif %}
|
||||
<span class="status-hint">
|
||||
{{ notification.status|format_notification_status_as_time(
|
||||
notification.created_at|format_datetime_short,
|
||||
(notification.updated_at or notification.created_at)|format_datetime_short
|
||||
) }}
|
||||
{% if notification['notification_type'] == "letter" %}
|
||||
{{ notification.created_at|format_datetime_short }}
|
||||
{% else %}
|
||||
{{ notification.status|format_notification_status_as_time(
|
||||
notification.created_at|format_datetime_short,
|
||||
(notification.updated_at or notification.created_at)|format_datetime_short
|
||||
) }}
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if notification.status in ['created', 'sending', 'delivered'] %}</span>{% endif %}
|
||||
{% endcall %}
|
||||
|
||||
@@ -55,9 +55,7 @@
|
||||
{{ item.preview_of_content }}
|
||||
</p>
|
||||
{% endcall %}
|
||||
{{ notification_status_field(
|
||||
'' if template.template_type == 'letter' else item
|
||||
) }}
|
||||
{{ notification_status_field(item) }}
|
||||
{% endcall %}
|
||||
|
||||
{% if more_than_one_page %}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
field_headings=['Recipient', 'Status'],
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
|
||||
{% call row_heading() %}
|
||||
<a class="file-list-filename" href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=item.id) }}">{{ item.to }}</a>
|
||||
<p class="file-list-hint">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<div class="ajax-block-container">
|
||||
<div class="grid-row">
|
||||
<div id="total-email" class="column-half">
|
||||
<div id="total-email" class="{{column_width}}">
|
||||
{{ big_number_with_status(
|
||||
statistics['email']['requested'],
|
||||
message_count_label(statistics['email']['requested'], 'email', suffix='sent'),
|
||||
@@ -14,7 +14,7 @@
|
||||
link=url_for(".view_notifications", service_id=service_id, message_type='email', status='sending,delivered,failed')
|
||||
) }}
|
||||
</div>
|
||||
<div id="total-sms" class="column-half">
|
||||
<div id="total-sms" class="{{column_width}}">
|
||||
{{ big_number_with_status(
|
||||
statistics['sms']['requested'],
|
||||
message_count_label(statistics['sms']['requested'], 'sms', suffix='sent'),
|
||||
@@ -25,5 +25,18 @@
|
||||
link=url_for(".view_notifications", service_id=service_id, message_type='sms', status='sending,delivered,failed')
|
||||
) }}
|
||||
</div>
|
||||
{% if 'letter' in current_service['permissions'] %}
|
||||
<div id="total-letters" class="{{column_width}}">
|
||||
{{ big_number_with_status(
|
||||
statistics['letter']['requested'],
|
||||
message_count_label(statistics['letter']['requested'], 'letter', suffix='sent'),
|
||||
statistics['letter']['failed'],
|
||||
statistics['letter']['failed_percentage'],
|
||||
statistics['letter']['show_warning'],
|
||||
failure_link=url_for(".view_notifications", service_id=service_id, message_type='letter', status='failed'),
|
||||
link=url_for(".view_notifications", service_id=service_id, message_type='letter', status='')
|
||||
) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,35 +13,36 @@
|
||||
<h1 class="heading-large">
|
||||
{{ message_count_label(99, message_type, suffix='') | capitalize }}
|
||||
</h1>
|
||||
{% if not message_type == "letter" %}
|
||||
{{ ajax_block(
|
||||
partials,
|
||||
url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status),
|
||||
'counts'
|
||||
) }}
|
||||
|
||||
{{ ajax_block(
|
||||
partials,
|
||||
url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status),
|
||||
'counts'
|
||||
) }}
|
||||
<form
|
||||
method="post"
|
||||
action="{{ url_for('.view_notifications', service_id=current_service.id, message_type=message_type) }}"
|
||||
class="grid-row"
|
||||
>
|
||||
<div class="column-three-quarters">
|
||||
{{ textbox(
|
||||
search_form.to,
|
||||
width='1-1',
|
||||
label='Search by {}'.format('email address' if message_type == 'email' else 'phone number')
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-one-quarter align-button-with-textbox">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="submit" class="button" value="Search">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form
|
||||
method="post"
|
||||
action="{{ url_for('.view_notifications', service_id=current_service.id, message_type=message_type) }}"
|
||||
class="grid-row"
|
||||
>
|
||||
<div class="column-three-quarters">
|
||||
{{ textbox(
|
||||
search_form.to,
|
||||
width='1-1',
|
||||
label='Search by {}'.format('email address' if message_type == 'email' else 'phone number')
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-one-quarter align-button-with-textbox">
|
||||
<form id="search-form" method="post">
|
||||
<input type="hidden" name="to" value="{{ search_form.to.data }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="submit" class="button" value="Search">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form id="search-form" method="post">
|
||||
<input type="hidden" name="to" value="{{ search_form.to.data }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
</form>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{{ ajax_block(
|
||||
partials,
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
{% from "components/big-number.html" import big_number_with_status %}
|
||||
{% from "components/message-count-label.html" import message_count_label %}
|
||||
<div class="grid-row bottom-gutter">
|
||||
<div class="column-half">
|
||||
<div class="column-third">
|
||||
{{ big_number_with_status(
|
||||
global_stats.email.delivered + global_stats.email.failed,
|
||||
message_count_label(global_stats.email.delivered, 'email'),
|
||||
global_stats.email.failed,
|
||||
global_stats.email.failure_rate,
|
||||
global_stats.email.failure_rate|float > 3,
|
||||
smaller=True
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-half">
|
||||
<div class="column-third">
|
||||
{{ big_number_with_status(
|
||||
global_stats.sms.delivered + global_stats.sms.failed,
|
||||
message_count_label(global_stats.sms.delivered, 'sms'),
|
||||
global_stats.sms.failed,
|
||||
global_stats.sms.failure_rate,
|
||||
global_stats.sms.failure_rate|float > 3,
|
||||
smaller=True
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-third">
|
||||
{{ big_number_with_status(
|
||||
global_stats.letter.delivered + global_stats.letter.failed,
|
||||
message_count_label(global_stats.letter.delivered, 'letter'),
|
||||
global_stats.letter.failed,
|
||||
global_stats.letter.failure_rate,
|
||||
global_stats.letter.failure_rate|float > 3,
|
||||
smaller=True
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user