diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index c6b65d4e6..addf9cc7a 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -381,28 +381,29 @@ td.table-empty-message { } .job-table { - .usa-table { - 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; - } + width: 100%; + border-collapse: collapse; + td.file-name { + width: 25%; + overflow-wrap: anywhere; + } + td.template { + width: 20%; + } + td.time-sent { + width: 20%; + } + td.sender { + width: 15%; + } + td.count-of-recipients { + width: 5%; + } + td.report { + width: 5%; + } + th { + padding: 0.5rem 0.5rem; } } diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index a88203ae7..c2a11eccf 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -1,4 +1,5 @@ import calendar +from collections import defaultdict from datetime import datetime from functools import partial from itertools import groupby @@ -47,31 +48,38 @@ def service_dashboard(service_id): if not current_user.has_permissions("view_activity"): return redirect(url_for("main.choose_template", service_id=service_id)) - notifications = notification_api_client.get_notifications_for_service( - service_id=service_id, - )["notifications"] - - job_response = job_api_client.get_jobs(service_id) - + job_response = job_api_client.get_jobs(service_id)["data"] + notifications_response = notification_api_client.get_notifications_for_service(service_id)["notifications"] service_data_retention_days = 7 - jobs = [ + + aggregate_notifications_by_job = defaultdict(list) + for notification in notifications_response: + job_id = notification.get("job", {}).get("id", None) + if job_id: + aggregate_notifications_by_job[job_id].append(notification) + + job_and_notifications = [ { "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"] ), + "view_job_link": url_for( + ".view_job", service_id=current_service.id, job_id=job["id"] + ), + "created_at": job["created_at"], "notification_count": job["notification_count"], "created_by": job["created_by"], + "notifications": aggregate_notifications_by_job.get(job["id"], []), } - for job in job_response["data"] + for job in job_response ] return render_template( "views/dashboard/dashboard.html", updates_url=url_for(".service_dashboard_updates", service_id=service_id), partials=get_dashboard_partials(service_id), - notifications=notifications, - jobs=jobs, + job_and_notifications=job_and_notifications, service_data_retention_days=service_data_retention_days, ) diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 9c51ea47c..3ea62a273 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -28,66 +28,70 @@ {{ ajax_block(partials, updates_url, 'totals') }} {{ ajax_block(partials, updates_url, 'template-statistics') }} -
| + | File name | -+ | Template | -+ | Time sent | -+ | Sender | -+ | # of Recipients | -+ | Report |
|---|---|---|---|---|---|---|---|---|---|---|---|
|
- {{ notification.job.original_file_name if notification.job.original_file_name else 'Manually entered number'}}
- - View Batch - |
- - {{ notification.template.name }} - | -- {{ notification.created_at | format_datetime_short_america }} - | -- {{ notification.created_by.name }} - | - {% set job_available = jobs|selectattr('job_id', 'equalto', notification.job.id)|first %} -- {{ 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 %} - | -||||||
|
+ {{ notification.job.original_file_name if notification.job.original_file_name else 'Manually entered number'}}
+ + View Batch + |
+ + {{ notification.template.name }} + | ++ {{ job.created_at | format_datetime_short_america }} + | ++ {{ notification.created_by.name }} + | ++ {{ job.notification_count}} + | ++ {% if notification and job.time_left != "Data no longer available" %} + Download + {{ job.time_left }} + {% elif job %} + {{ job.time_left }} + {% endif %} + | +||||||