From 524a1e4687e5fece63f3c05fc87f3726c3e8706c Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Thu, 25 Jan 2024 15:32:44 -0800 Subject: [PATCH] updated download links and table html --- .../uswds/_uswds-theme-custom-styles.scss | 23 +++- app/formatters.py | 16 ++- app/main/views/dashboard.py | 7 +- app/templates/components/table.html | 2 +- app/templates/views/dashboard/dashboard.html | 110 ++++++++++-------- 5 files changed, 100 insertions(+), 58 deletions(-) diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index 533b54a2e..b5f2147cd 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -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; } } } diff --git a/app/formatters.py b/app/formatters.py index eefd20666..971beb03e 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -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() diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 3ccc39403..cb73175c5 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -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//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, ) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 803030e54..2e59e4a33 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -6,7 +6,7 @@ {% for field_heading in field_headings %} - + {% if field_headings_visible %} {{ field_heading }} {% else %} diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 2bf5cae0e..4892f1588 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -31,57 +31,71 @@

Recent Batches

- {% 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() %} - {{ item.job.original_file_name if item.job.id else '' }} - {% 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}} + + + + + + + + + + + + + {% for notification in notifications %} + {% if notification %} + + + + + + {% set job_available = jobs|selectattr('job_id', 'equalto', notification.job.id)|first %} + + + {% endif %} - {% endcall %} - {% call row_heading() %} - {% if availability and availability.time_left != "Data no longer available" %} - {{ "Download" if item.job.original_file_name else '' }} - {{ availability.time_left }} - {% elif availability %} - {{ availability.time_left }} - {% endif %} - {% endcall %} - {% endif %} - {% endcall %} + {% endfor %} + +
+ File name + + Template + + Time sent + + Sender + + # of Recipients + + Report +
+ {% if notification.job.original_file_name %} + {{ notification.job.original_file_name }} + {% else %} + {{ 'Manually entered number' }} + {% endif %} +
+ View Batch +
+ {{ notification.template.name }} + + {{ (notification.updated_at or notification.created_at)| format_datetime_short_america }} + + {{ notification.created_by.name }} + + {{ job_available.notification_count if job_available else ''}} + + {% if job_available and job_available.time_left != "Data no longer available" %} + + {{ "Download" if job_available.job_id else '' }} + {{ job_available.time_left }} + {% elif job_available %} + {{ job_available.time_left }} + {% endif %} +
- - {% if show_pagination %} - {{ previous_next_navigation(prev_page, next_page) }} - {% elif next_page %} - - {% endif %} - -

Usage

Daily

Across all services