mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
updated download links and table html
This commit is contained in:
@@ -379,9 +379,26 @@ td.table-empty-message {
|
||||
|
||||
.job-table {
|
||||
.usa-table {
|
||||
thead th {
|
||||
background-color: #d9e8f6;
|
||||
color: #1b1b1b;
|
||||
thead th.file-name {
|
||||
width: 25%;
|
||||
}
|
||||
thead th.template {
|
||||
width: 20%;
|
||||
}
|
||||
thead th.time-sent {
|
||||
width: 30%;
|
||||
}
|
||||
thead th.sender {
|
||||
width: 15%;
|
||||
}
|
||||
thead th.\#-of-recipients {
|
||||
width: 5%;
|
||||
}
|
||||
thead th.report {
|
||||
width: 5%;
|
||||
}
|
||||
th {
|
||||
padding: 0.5rem 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,14 +97,21 @@ def format_datetime_short(date):
|
||||
format_date_short(date), format_time_24h(date), get_user_preferred_timezone()
|
||||
)
|
||||
|
||||
|
||||
def format_datetime_short_america(date):
|
||||
return "{} at {} {}".format(
|
||||
format_date_normal_america(date), format_time_12h(date),get_user_preferred_timezone()
|
||||
return "{} at {}".format(
|
||||
format_date_numeric_america(date), format_time_12h(date)
|
||||
)
|
||||
|
||||
def format_date_normal_america(date):
|
||||
|
||||
def format_date_numeric_america(date):
|
||||
date = parse_naive_dt(date)
|
||||
return date.strftime("%B %d, %Y").lstrip("0")
|
||||
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
return (
|
||||
date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%m-%d-%Y")
|
||||
)
|
||||
|
||||
|
||||
def format_time_12h(date):
|
||||
date = parse_naive_dt(date)
|
||||
@@ -112,6 +119,7 @@ def format_time_12h(date):
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
return date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%I:%M %p")
|
||||
|
||||
|
||||
def format_datetime_relative(date):
|
||||
return "{} at {} {}".format(
|
||||
get_human_day(date), format_time_24h(date), get_user_preferred_timezone()
|
||||
|
||||
@@ -29,7 +29,7 @@ from app.utils.csv import Spreadsheet
|
||||
from app.utils.pagination import generate_next_dict, generate_previous_dict
|
||||
from app.utils.time import get_current_financial_year
|
||||
from app.utils.user import user_has_permissions
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/dashboard")
|
||||
@user_has_permissions("view_activity", "send_messages")
|
||||
@@ -58,8 +58,10 @@ def service_dashboard(service_id):
|
||||
{
|
||||
"job_id": job["id"],
|
||||
"time_left": get_time_left(job["created_at"]),
|
||||
"download_link": url_for(".view_job_csv", service_id=current_service.id, job_id=job["id"]),
|
||||
# "download_link": url_for(".view_job_csv", service_id=current_service.id, job_id=job["id"]),
|
||||
"notification_count": job["notification_count"],
|
||||
"created_by": job["created_by"],
|
||||
"download_link": url_for(".view_job_csv", service_id=current_service.id, job_id=job["id"])
|
||||
}
|
||||
for job in job_response.get('data', [])
|
||||
]
|
||||
@@ -69,6 +71,7 @@ def service_dashboard(service_id):
|
||||
partials=get_dashboard_partials(service_id),
|
||||
notifications=notifications,
|
||||
jobs=jobs,
|
||||
job_response=job_response['data'],
|
||||
service_data_retention_days=service_data_retention_days,
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<thead class="table-field-headings{% if field_headings_visible %}-visible{% endif %}">
|
||||
<tr>
|
||||
{% for field_heading in field_headings %}
|
||||
<th scope="col" class="table-field-heading{% if loop.first %}-first{% endif %}" width="{% if equal_length %}{{ (100 / field_headings|length)|int }}%{% endif %}">
|
||||
<th scope="col" class="table-field-heading{% if loop.first %}-first{% endif %} {{ field_heading|lower|replace(' ', '-') }}" width="{% if equal_length %}{{ (100 / field_headings|length)|int }}%{% endif %}">
|
||||
{% if field_headings_visible %}
|
||||
{{ field_heading }}
|
||||
{% else %}
|
||||
|
||||
@@ -31,57 +31,71 @@
|
||||
|
||||
<h2 class="margin-top-4 margin-bottom-1">Recent Batches</h2>
|
||||
<div class='job-table'>
|
||||
{% call(item, row_number) list_table(
|
||||
notifications,
|
||||
caption="Batched Jobs",
|
||||
caption_visible=False,
|
||||
border_visible=True,
|
||||
empty_message='No batched job messages found  (messages are kept for {} days)'.format(service_data_retention_days)|safe,
|
||||
field_headings=['File Name','Template','Time Sent', 'Sender', '# of Recipients', "Report"],
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
{% if item.job.original_file_name and item.job.id and item.template %}
|
||||
{% call row_heading() %}
|
||||
<a class="usa-link file-list-filename" href="/services/{{ item.service }}/jobs/{{ item.job.id }}">{{ item.job.original_file_name if item.job.id else '' }}</a>
|
||||
{% endcall %}
|
||||
{% call row_heading() %}
|
||||
{{ item.template.name }}
|
||||
{% endcall %}
|
||||
{% call row_heading() %}
|
||||
{{ (item.updated_at or item.created_at)| format_datetime_short_america
|
||||
}}
|
||||
{% endcall %}
|
||||
{% call row_heading() %}
|
||||
{{ item.created_by.name }}
|
||||
{% endcall %}
|
||||
{% set availability = jobs|selectattr('job_id', 'equalto', item.job.id)|first %}
|
||||
{% call row_heading() %}
|
||||
{% if availability %}
|
||||
{{ availability.notification_count}}
|
||||
<table class="usa-table usa-table--borderless width-full">
|
||||
<thead class="table-field-headings">
|
||||
<tr>
|
||||
<th scope="col" class="table-field-heading-first file-name">
|
||||
<span>File name</span>
|
||||
</th>
|
||||
<th scope="col" class="table-field-heading template">
|
||||
<span>Template</span>
|
||||
</th>
|
||||
<th scope="col" class="table-field-heading time-sent">
|
||||
<span>Time sent</span>
|
||||
</th>
|
||||
<th scope="col" class="table-field-heading sender">
|
||||
<span>Sender</span>
|
||||
</th>
|
||||
<th scope="col" class="table-field-heading #-of-recipients">
|
||||
<span># of Recipients</span>
|
||||
</th>
|
||||
<th scope="col" class="table-field-heading report">
|
||||
<span>Report</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for notification in notifications %}
|
||||
{% if notification %}
|
||||
<tr class="table-row" id="f4b38296-06a3-4963-a66b-fb44fd6fa55c">
|
||||
<th class="table-field">
|
||||
{% if notification.job.original_file_name %}
|
||||
{{ notification.job.original_file_name }}
|
||||
{% else %}
|
||||
{{ 'Manually entered number' }}
|
||||
{% endif %}
|
||||
<br>
|
||||
<a class="usa-link file-list-filename" href="/services/{{ notification.service }}/jobs/{{ notification.job.id }}">View Batch</a>
|
||||
</th>
|
||||
<th class="table-field">
|
||||
{{ notification.template.name }}
|
||||
</th>
|
||||
<th class="table-field">
|
||||
{{ (notification.updated_at or notification.created_at)| format_datetime_short_america }}
|
||||
</th>
|
||||
<th class="table-field">
|
||||
{{ notification.created_by.name }}
|
||||
</th>
|
||||
{% set job_available = jobs|selectattr('job_id', 'equalto', notification.job.id)|first %}
|
||||
<th class="table-field">
|
||||
{{ job_available.notification_count if job_available else ''}}
|
||||
</th>
|
||||
<th class="table-field">
|
||||
{% if job_available and job_available.time_left != "Data no longer available" %}
|
||||
<a class="usa-link file-list-filename" href="{{ job_available.download_link }}">
|
||||
{{ "Download" if job_available.job_id else '' }}</a>
|
||||
<span class="usa-hint">{{ job_available.time_left }}</span>
|
||||
{% elif job_available %}
|
||||
<span>{{ job_available.time_left }}</span>
|
||||
{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% call row_heading() %}
|
||||
{% if availability and availability.time_left != "Data no longer available" %}
|
||||
<a class="usa-link file-list-filename" href="{{ availability.download_link[0] }}">{{ "Download" if item.job.original_file_name else '' }}</a>
|
||||
<span class="usa-hint">{{ availability.time_left }}</span>
|
||||
{% elif availability %}
|
||||
<span>{{ availability.time_left }}</span>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
{% if show_pagination %}
|
||||
{{ previous_next_navigation(prev_page, next_page) }}
|
||||
{% elif next_page %}
|
||||
<p class="table-show-more-link">
|
||||
Only showing the first 50 messages
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h2 class="margin-top-4 margin-bottom-1">Usage</h2>
|
||||
<h3 class="margin-bottom-0">Daily</h3>
|
||||
<p class="margin-0">Across all services</p>
|
||||
|
||||
Reference in New Issue
Block a user