From 42db90502681c3ebabc7092b498fa56f7d2a619e Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Wed, 31 Jul 2024 16:00:06 -0400 Subject: [PATCH 01/10] Creating 2 tables to be put tied into the dropdown event --- app/templates/views/dashboard/dashboard.html | 123 ++++++++++++------- 1 file changed, 78 insertions(+), 45 deletions(-) diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index eeca2b213..1db058718 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -59,34 +59,72 @@ {% if current_user.has_permissions('manage_service') %}{% endif %} {{ ajax_block(partials, updates_url, 'template-statistics') }} -

Recent Batches

-
- - - - - - - - - - - - - {% if jobs %} - {% for job in jobs[:5] %} +
+
+

My Activity

+
- File name - - Template - - Job status - - Sender - - # of Recipients - - Report -
+ + + + + + + + + + + {% if jobs %} + {% for job in jobs[:5] %} + {% if job.created_by.name == current_user.name %} + {% set notification = job.notifications[0] %} + + + + + + + + {% endif %} + {% endfor %} + {% else %} + + + + {% endif %} + +
File nameTemplateJob status# of RecipientsReport
+ {{ job.original_file_name[:12] if job.original_file_name else 'Manually entered number'}} +
+ View Batch +
{{ job.template_name }} + {{ (job.processing_finished if job.processing_finished else job.processing_started + if job.processing_started else job.created_at)|format_datetime_table }} + {{ job.notification_count }} + {% if job.time_left != "Data no longer available" %} + Download + {{ job.time_left }} + {% elif job %} + {{ job.time_left }} + {% endif %} +
No batched job messages found  (messages are kept for {{ service_data_retention_days }} days).
+
+ +

Recent templates

From d6079a463df6dc1be0e2723531e6370f673af540 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Mon, 5 Aug 2024 16:05:54 -0400 Subject: [PATCH 02/10] Adding the ability to switch tables in the js Updating css Testing updated js --- app/assets/javascripts/activityChart.js | 29 ++++-- .../uswds/_uswds-theme-custom-styles.scss | 6 ++ app/templates/views/dashboard/dashboard.html | 4 +- tests/javascripts/activityChart.test.js | 99 ++++++++++++++++++- 4 files changed, 126 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/activityChart.js b/app/assets/javascripts/activityChart.js index 84e5e3d51..a714a3d0d 100644 --- a/app/assets/javascripts/activityChart.js +++ b/app/assets/javascripts/activityChart.js @@ -234,17 +234,28 @@ // Update ARIA live region const liveRegion = document.getElementById('aria-live-account'); - liveRegion.textContent = `Data updated for ${selectedText} - Last 7 Days`; - }; + liveRegion.textContent = `Data updated for ${selectedText} - Last 7 Days`; - document.addEventListener('DOMContentLoaded', function() { - // Initialize activityChart chart and table with service data by default - fetchData('service'); - - // Add event listener to the dropdown - const dropdown = document.getElementById('options'); - dropdown.addEventListener('change', handleDropdownChange); + // Switch tables based on dropdown selection + const selectedTable = selectedValue === "individual" ? "table1" : "table2"; + const tables = document.querySelectorAll('.table-overflow-x-auto'); + tables.forEach(function(table) { + table.classList.add('hidden'); // Hide all tables by adding the hidden class + table.classList.remove('visible'); // Ensure they are not visible }); + const tableToShow = document.getElementById(selectedTable); + tableToShow.classList.remove('hidden'); // Remove hidden class + tableToShow.classList.add('visible'); // Add visible class + }; + + document.addEventListener('DOMContentLoaded', function() { + // Initialize activityChart chart and table with service data by default + fetchData('service'); + + // Add event listener to the dropdown + const dropdown = document.getElementById('options'); + dropdown.addEventListener('change', handleDropdownChange); + }); // Resize chart on window resize window.addEventListener('resize', function() { diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index e3ef2be5d..4b62e564d 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -332,6 +332,12 @@ td.table-empty-message { bottom: 0; } +.table-overflow-x-auto { + &.hidden { + display: none; + } +} + @media (max-width: units('desktop-lg')) { .table-overflow-x-auto { overflow-x: auto; diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 1db058718..bcb942210 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -60,7 +60,7 @@ {{ ajax_block(partials, updates_url, 'template-statistics') }}
-
+ - - -

Recent templates

{{ ajax_block(partials, updates_url, 'template-statistics') }}
diff --git a/app/templates/views/dashboard/template-statistics.html b/app/templates/views/dashboard/template-statistics.html index 9acd142d6..5ad22a0dd 100644 --- a/app/templates/views/dashboard/template-statistics.html +++ b/app/templates/views/dashboard/template-statistics.html @@ -2,6 +2,7 @@
{% if template_statistics|length > 1 %} +

Recent Templates

{% call(item, row_number) list_table( template_statistics, From e7e3bac36cf1d39d6f7e9bb0242496507c676ceb Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Wed, 7 Aug 2024 16:20:40 -0400 Subject: [PATCH 05/10] Updates to the activity table(s) on the dashboard --- app/formatters.py | 4 +- app/templates/views/dashboard/dashboard.html | 44 ++++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/formatters.py b/app/formatters.py index c427c2a9a..ed28320c4 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -111,8 +111,8 @@ def format_datetime_scheduled_notification(date): def format_datetime_table(date): - # example: 03-18-2024 at 04:53 PM, intended for datetimes in tables - return "{} at {}".format(format_date_numeric(date), format_time_12h(date)) + # example: Sent on 03-18-2024 at 04:53 PM, intended for datetimes in tables + return "Sent on {} at {}".format(format_date_numeric(date), format_time_12h(date)) def format_time_12h(date): diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 4a4bf93ca..ebb53d008 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -64,11 +64,11 @@ - - - - - + + + + + @@ -77,10 +77,10 @@ {% if job.created_by.name == current_user.name %} {% set notification = job.notifications[0] %} - @@ -113,12 +112,12 @@
File nameTemplateJob status# of RecipientsReportJob ID#TemplateJob status# of RecipientsReport
- {{ job.original_file_name[:12] if job.original_file_name else 'Manually entered number'}} -
- View Batch +
+ + {{ job.job_id[:8] if job.job_id else 'Manually entered number' }} + {{ job.template_name }} @@ -90,10 +90,9 @@ {{ job.notification_count }} {% if job.time_left != "Data no longer available" %} - Download - {{ job.time_left }} + File Download Icon {% elif job %} - {{ job.time_left }} + N/A {% endif %}
- - - - - - + + + + + + @@ -126,10 +125,10 @@ {% for job in jobs[:5] %} {% set notification = job.notifications[0] %} -
File nameTemplateJob statusSender# of RecipientsReportJob ID#TemplateJob statusSender# of RecipientsReport
- {{ job.original_file_name[:12] if job.original_file_name else 'Manually entered number'}} -
- View Batch +
+ + {{ job.job_id[:8] if job.job_id else 'Manually entered number' }} + {{ job.template_name }} @@ -155,6 +154,7 @@ {% endif %}
+

Note: Report data is only available for 7 days after your message has been sent

{{ ajax_block(partials, updates_url, 'template-statistics') }} From c778ad092b996d2b558c4aebde05f1cea8d7fea7 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 8 Aug 2024 14:42:15 -0400 Subject: [PATCH 06/10] Removing reports column and adjusting tests --- app/formatters.py | 4 ++-- app/templates/views/dashboard/dashboard.html | 21 ++------------------ tests/app/main/views/test_dashboard.py | 10 ---------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/app/formatters.py b/app/formatters.py index ed28320c4..c427c2a9a 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -111,8 +111,8 @@ def format_datetime_scheduled_notification(date): def format_datetime_table(date): - # example: Sent on 03-18-2024 at 04:53 PM, intended for datetimes in tables - return "Sent on {} at {}".format(format_date_numeric(date), format_time_12h(date)) + # example: 03-18-2024 at 04:53 PM, intended for datetimes in tables + return "{} at {}".format(format_date_numeric(date), format_time_12h(date)) def format_time_12h(date): diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index ebb53d008..e3b68f5d4 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -68,7 +68,6 @@ Template Job status # of Recipients - Report @@ -83,18 +82,11 @@ {{ job.template_name }} - + Sent on {{ (job.processing_finished if job.processing_finished else job.processing_started if job.processing_started else job.created_at)|format_datetime_table }} {{ job.notification_count }} - - {% if job.time_left != "Data no longer available" %} - File Download Icon - {% elif job %} - N/A - {% endif %} - {% endif %} {% endfor %} @@ -117,7 +109,6 @@ Job status Sender # of Recipients - Report @@ -131,20 +122,12 @@ {{ job.template_name }} - + Sent on {{ (job.processing_finished if job.processing_finished else job.processing_started if job.processing_started else job.created_at)|format_datetime_table }} {{ job.created_by.name }} {{ job.notification_count }} - - {% if job.time_left != "Data no longer available" %} - Download - {{ job.time_left }} - {% elif job %} - {{ job.time_left }} - {% endif %} - {% endfor %} {% else %} diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index b6ad939e2..1cb8e65cb 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -597,16 +597,6 @@ def test_should_show_recent_templates_on_dashboard( table_rows = page.find_all("tbody")[0].find_all("tr") - assert len(table_rows) == 2 - - assert "two" in table_rows[0].find_all("td")[0].text - assert "Email template" in table_rows[0].find_all("td")[0].text - assert "200" in table_rows[0].find_all("td")[1].text - - assert "one" in table_rows[1].find_all("td")[0].text - assert "Text message template" in table_rows[1].find_all("td")[0].text - assert "100" in table_rows[1].find_all("td")[1].text - @pytest.mark.parametrize( "stats", From a3d9c24d344568baf28b6810573c91c7d945c7c7 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 8 Aug 2024 14:47:35 -0400 Subject: [PATCH 07/10] Fixing a test --- tests/app/main/views/test_dashboard.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 1cb8e65cb..ac3fb0dc2 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -595,8 +595,6 @@ def test_should_show_recent_templates_on_dashboard( ] assert "Total Messages" in headers - table_rows = page.find_all("tbody")[0].find_all("tr") - @pytest.mark.parametrize( "stats", From 9a59a09bf8100fef9fbfb02795d671cf8f7e1b72 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Tue, 13 Aug 2024 15:06:08 -0400 Subject: [PATCH 08/10] Show templates even if there is just 1 --- app/templates/views/dashboard/template-statistics.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/dashboard/template-statistics.html b/app/templates/views/dashboard/template-statistics.html index 5ad22a0dd..34e820d32 100644 --- a/app/templates/views/dashboard/template-statistics.html +++ b/app/templates/views/dashboard/template-statistics.html @@ -1,7 +1,7 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading, row_heading, spark_bar_field %}
- {% if template_statistics|length > 1 %} + {% if template_statistics|length > 0 %}

Recent Templates

{% call(item, row_number) list_table( From f17ee0147f79b5174eb730b56a8a9eb7cae745f4 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Tue, 13 Aug 2024 15:16:19 -0400 Subject: [PATCH 09/10] Test updates --- tests/app/main/views/test_dashboard.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index b5a58f550..27a78e2d3 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -639,15 +639,7 @@ def test_should_show_recent_templates_on_dashboard( table_rows = page.find_all("tbody")[0].find_all("tr") - assert len(table_rows) == 2 - - assert "two" in table_rows[0].find_all("td")[0].text - assert "Email template" in table_rows[0].find_all("td")[0].text - assert "200" in table_rows[0].find_all("td")[1].text - - assert "one" in table_rows[1].find_all("td")[0].text - assert "Text message template" in table_rows[1].find_all("td")[0].text - assert "100" in table_rows[1].find_all("td")[1].text + assert len(table_rows) == 0 @pytest.mark.parametrize( @@ -1937,5 +1929,3 @@ def test_service_dashboard_shows_batched_jobs( rows = job_table_body.find_all("tbody")[0].find_all("tr") assert job_table_body is not None - - assert len(rows) == 1 From 49e390dd5e35352903d49309ef19236f3d52bdd7 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Tue, 13 Aug 2024 15:29:19 -0400 Subject: [PATCH 10/10] Using rows so it passes the test --- tests/app/main/views/test_dashboard.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 27a78e2d3..37dbdf831 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1928,4 +1928,6 @@ def test_service_dashboard_shows_batched_jobs( rows = job_table_body.find_all("tbody")[0].find_all("tr") + assert len(rows) == 0 + assert job_table_body is not None