mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Show upcoming jobs on the dashboard
On the dashboard: - adds a new ‘in the next 24 hours’ section to the dashboard which lists upcoming jobs - tweaks some spacing on the dashboard so that it doesn’t look like too much of a mess - don’t show scheduled jobs in the table of normal jobs On the jobs page: - don’t show scheduled jobs
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
|
||||
@extend %big-number;
|
||||
position: relative;
|
||||
margin-bottom: $gutter-half;
|
||||
margin-bottom: $gutter-two-thirds;
|
||||
|
||||
.big-number {
|
||||
padding: $gutter-half;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
%show-more,
|
||||
.show-more {
|
||||
|
||||
@include core-16;
|
||||
@@ -8,7 +9,7 @@
|
||||
border-top: 1px solid $border-colour;
|
||||
|
||||
&:focus {
|
||||
|
||||
|
||||
outline: none;
|
||||
color: $text-colour;
|
||||
box-shadow: 0 -10px 0 0 $yellow;
|
||||
@@ -32,3 +33,8 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.show-more-empty {
|
||||
@extend %show-more;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,20 @@
|
||||
|
||||
.dashboard-table {
|
||||
|
||||
.heading-medium {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.table-field-headings,
|
||||
.table-field-headings {
|
||||
th {
|
||||
font-size: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.table-field-headings-visible {
|
||||
th {
|
||||
padding-bottom: 5px;
|
||||
|
||||
@@ -116,9 +116,21 @@ def get_dashboard_partials(service_id):
|
||||
lambda job: job['original_file_name'] != current_app.config['TEST_MESSAGE_FILENAME'],
|
||||
job_api_client.get_job(service_id, limit_days=7)['data']
|
||||
))
|
||||
scheduled_jobs = filter(
|
||||
lambda job: job['job_status'] == 'scheduled',
|
||||
jobs
|
||||
)
|
||||
immediate_jobs = filter(
|
||||
lambda job: job['job_status'] != 'scheduled',
|
||||
jobs
|
||||
)
|
||||
service = service_api_client.get_detailed_service(service_id)
|
||||
|
||||
return {
|
||||
'upcoming': render_template(
|
||||
'views/dashboard/_upcoming.html',
|
||||
scheduled_jobs=scheduled_jobs
|
||||
),
|
||||
'totals': render_template(
|
||||
'views/dashboard/_totals.html',
|
||||
service_id=service_id,
|
||||
@@ -134,7 +146,7 @@ def get_dashboard_partials(service_id):
|
||||
'has_template_statistics': bool(template_statistics),
|
||||
'jobs': render_template(
|
||||
'views/dashboard/_jobs.html',
|
||||
jobs=jobs
|
||||
jobs=immediate_jobs
|
||||
),
|
||||
'has_jobs': bool(jobs),
|
||||
'usage': render_template(
|
||||
|
||||
@@ -65,7 +65,10 @@ def _set_status_filters(filter_args):
|
||||
def view_jobs(service_id):
|
||||
return render_template(
|
||||
'views/jobs/jobs.html',
|
||||
jobs=add_rate_to_jobs(job_api_client.get_job(service_id)['data'])
|
||||
jobs=filter(
|
||||
lambda job: job['job_status'] != 'scheduled',
|
||||
add_rate_to_jobs(job_api_client.get_job(service_id)['data'])
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -274,6 +277,11 @@ def get_status_filters(service, message_type, statistics):
|
||||
|
||||
|
||||
def _get_job_counts(job, help_argument):
|
||||
sending = 0 if job['job_status'] == 'pending' else (
|
||||
job.get('notification_count', 0) -
|
||||
job.get('notifications_delivered', 0) -
|
||||
job.get('notifications_failed', 0)
|
||||
)
|
||||
return [
|
||||
(
|
||||
label,
|
||||
@@ -293,9 +301,7 @@ def _get_job_counts(job, help_argument):
|
||||
],
|
||||
[
|
||||
'sending', 'sending',
|
||||
job.get('notification_count', 0) -
|
||||
job.get('notifications_delivered', 0) -
|
||||
job.get('notifications_failed', 0)
|
||||
sending
|
||||
],
|
||||
[
|
||||
'delivered', 'delivered',
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
{% macro show_more(url, label) %}
|
||||
<a href="{{ url }}" class="show-more"><span>{{ label }}</span></a>
|
||||
{% macro show_more(url=None, label=None) %}
|
||||
{% if url and label %}
|
||||
<a href="{{ url }}" class="show-more"><span>{{ label }}</span></a>
|
||||
{% else %}
|
||||
<span class="show-more-empty"></span>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
Report is {{ "{:.0f}%".format(percentage_complete) }} complete…
|
||||
</p>
|
||||
{% elif notifications %}
|
||||
<p class="bottom-gutter-1-2">
|
||||
<p class="bottom-gutter">
|
||||
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
|
||||
 
|
||||
<span id="time-left">{{ time_left }}</span>
|
||||
|
||||
@@ -18,7 +18,11 @@
|
||||
{% call row_heading() %}
|
||||
<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>
|
||||
<span class="file-list-hint">
|
||||
Sent {{
|
||||
item.scheduled_for|format_datetime_short if item.scheduled_for else item.created_at|format_datetime_short
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
{% endcall %}
|
||||
{% call field() %}
|
||||
|
||||
38
app/templates/views/dashboard/_upcoming.html
Normal file
38
app/templates/views/dashboard/_upcoming.html
Normal file
@@ -0,0 +1,38 @@
|
||||
{% from "components/table.html" import list_table, field, right_aligned_field_heading, row_heading %}
|
||||
{% from "components/big-number.html" import big_number %}
|
||||
{% from "components/show-more.html" import show_more %}
|
||||
|
||||
{% if scheduled_jobs %}
|
||||
<div class='dashboard-table'>
|
||||
<h2 class="heading-medium">
|
||||
In the next 24 hours
|
||||
</h2>
|
||||
{% call(item, row_number) list_table(
|
||||
scheduled_jobs,
|
||||
caption="In the next 24 hours",
|
||||
caption_visible=False,
|
||||
empty_message='Nothing to see here',
|
||||
field_headings=[
|
||||
'File',
|
||||
'Messages to be sent'
|
||||
],
|
||||
field_headings_visible=True
|
||||
) %}
|
||||
{% call row_heading() %}
|
||||
<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">
|
||||
Sending at {{ item.scheduled_for|format_time }}
|
||||
</span>
|
||||
</div>
|
||||
{% endcall %}
|
||||
{% call field() %}
|
||||
{{ big_number(
|
||||
item.notification_count,
|
||||
smallest=True
|
||||
) }}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
{{ show_more() }}
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -23,6 +23,8 @@
|
||||
{% include 'views/dashboard/no-permissions-banner.html' %}
|
||||
{% endif %}
|
||||
|
||||
{{ ajax_block(partials, updates_url, 'upcoming') }}
|
||||
|
||||
<h2 class="heading-medium">
|
||||
In the last 7 days
|
||||
</h2>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
|
||||
{% if notifications %}
|
||||
<p class="bottom-gutter-1-2">
|
||||
<p class="bottom-gutter">
|
||||
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
|
||||
 
|
||||
Data available for 7 days
|
||||
|
||||
Reference in New Issue
Block a user