updated download links and table html

This commit is contained in:
Beverly Nguyen
2024-01-25 15:32:44 -08:00
parent c9ed1ab59d
commit 524a1e4687
5 changed files with 100 additions and 58 deletions

View File

@@ -379,9 +379,26 @@ td.table-empty-message {
.job-table { .job-table {
.usa-table { .usa-table {
thead th { thead th.file-name {
background-color: #d9e8f6; width: 25%;
color: #1b1b1b; }
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;
} }
} }
} }

View File

@@ -97,14 +97,21 @@ def format_datetime_short(date):
format_date_short(date), format_time_24h(date), get_user_preferred_timezone() format_date_short(date), format_time_24h(date), get_user_preferred_timezone()
) )
def format_datetime_short_america(date): def format_datetime_short_america(date):
return "{} at {} {}".format( return "{} at {}".format(
format_date_normal_america(date), format_time_12h(date),get_user_preferred_timezone() 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) 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): def format_time_12h(date):
date = parse_naive_dt(date) date = parse_naive_dt(date)
@@ -112,6 +119,7 @@ def format_time_12h(date):
preferred_tz = pytz.timezone(get_user_preferred_timezone()) preferred_tz = pytz.timezone(get_user_preferred_timezone())
return date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%I:%M %p") return date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%I:%M %p")
def format_datetime_relative(date): def format_datetime_relative(date):
return "{} at {} {}".format( return "{} at {} {}".format(
get_human_day(date), format_time_24h(date), get_user_preferred_timezone() get_human_day(date), format_time_24h(date), get_user_preferred_timezone()

View File

@@ -29,7 +29,7 @@ from app.utils.csv import Spreadsheet
from app.utils.pagination import generate_next_dict, generate_previous_dict from app.utils.pagination import generate_next_dict, generate_previous_dict
from app.utils.time import get_current_financial_year from app.utils.time import get_current_financial_year
from app.utils.user import user_has_permissions from app.utils.user import user_has_permissions
from pprint import pprint
@main.route("/services/<uuid:service_id>/dashboard") @main.route("/services/<uuid:service_id>/dashboard")
@user_has_permissions("view_activity", "send_messages") @user_has_permissions("view_activity", "send_messages")
@@ -58,8 +58,10 @@ def service_dashboard(service_id):
{ {
"job_id": job["id"], "job_id": job["id"],
"time_left": get_time_left(job["created_at"]), "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"], "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', []) for job in job_response.get('data', [])
] ]
@@ -69,6 +71,7 @@ def service_dashboard(service_id):
partials=get_dashboard_partials(service_id), partials=get_dashboard_partials(service_id),
notifications=notifications, notifications=notifications,
jobs=jobs, jobs=jobs,
job_response=job_response['data'],
service_data_retention_days=service_data_retention_days, service_data_retention_days=service_data_retention_days,
) )

View File

@@ -6,7 +6,7 @@
<thead class="table-field-headings{% if field_headings_visible %}-visible{% endif %}"> <thead class="table-field-headings{% if field_headings_visible %}-visible{% endif %}">
<tr> <tr>
{% for field_heading in field_headings %} {% 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 %} {% if field_headings_visible %}
{{ field_heading }} {{ field_heading }}
{% else %} {% else %}

View File

@@ -31,57 +31,71 @@
<h2 class="margin-top-4 margin-bottom-1">Recent Batches</h2> <h2 class="margin-top-4 margin-bottom-1">Recent Batches</h2>
<div class='job-table'> <div class='job-table'>
{% call(item, row_number) list_table( <table class="usa-table usa-table--borderless width-full">
notifications, <thead class="table-field-headings">
caption="Batched Jobs", <tr>
caption_visible=False, <th scope="col" class="table-field-heading-first file-name">
border_visible=True, <span>File name</span>
empty_message='No batched job messages found &thinsp;(messages are kept for {} days)'.format(service_data_retention_days)|safe, </th>
field_headings=['File Name','Template','Time Sent', 'Sender', '# of Recipients', "Report"], <th scope="col" class="table-field-heading template">
field_headings_visible=False <span>Template</span>
) %} </th>
{% if item.job.original_file_name and item.job.id and item.template %} <th scope="col" class="table-field-heading time-sent">
{% call row_heading() %} <span>Time sent</span>
<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> </th>
{% endcall %} <th scope="col" class="table-field-heading sender">
{% call row_heading() %} <span>Sender</span>
{{ item.template.name }} </th>
{% endcall %} <th scope="col" class="table-field-heading #-of-recipients">
{% call row_heading() %} <span># of Recipients</span>
{{ (item.updated_at or item.created_at)| format_datetime_short_america </th>
}} <th scope="col" class="table-field-heading report">
{% endcall %} <span>Report</span>
{% call row_heading() %} </th>
{{ item.created_by.name }} </tr>
{% endcall %} </thead>
{% set availability = jobs|selectattr('job_id', 'equalto', item.job.id)|first %} <tbody>
{% call row_heading() %} {% for notification in notifications %}
{% if availability %} {% if notification %}
{{ availability.notification_count}} <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 %} {% endif %}
{% endcall %} {% endfor %}
{% call row_heading() %} </tbody>
{% if availability and availability.time_left != "Data no longer available" %} </table>
<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 %}
</div> </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> <h2 class="margin-top-4 margin-bottom-1">Usage</h2>
<h3 class="margin-bottom-0">Daily</h3> <h3 class="margin-bottom-0">Daily</h3>
<p class="margin-0">Across all services</p> <p class="margin-0">Across all services</p>