diff --git a/app/assets/javascripts/activityChart.js b/app/assets/javascripts/activityChart.js index 8bece8276..5d2f89b39 100644 --- a/app/assets/javascripts/activityChart.js +++ b/app/assets/javascripts/activityChart.js @@ -238,17 +238,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 902e90ee5..61cd543ef 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 114667f2d..94fd08faa 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -54,75 +54,88 @@ {% if current_user.has_permissions('manage_service') %}{% endif %} - {{ ajax_block(partials, updates_url, 'template-statistics') }} -

Recent Batches

-
- - - - - - - - - - - - - {% if jobs %} - {% for job in jobs[:5] %} +
+
- 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 %} + +
Job ID#TemplateJob status# of Recipients
+ + {{ job.job_id[:8] if job.job_id else 'Manually entered number' }} + + {{ 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 }}
No batched job messages found  (messages are kept for {{ service_data_retention_days }} days).
+
+ +
+

All Activity

+ + + + + + + + + + + + {% if jobs %} + {% for job in jobs[:5] %} {% set notification = job.notifications[0] %} - - - + - - - + + - {% endfor %} - {% else %} - - - - {% endif %} - -
Job ID#TemplateJob statusSender# of Recipients
- {{ 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 }} - + {{ 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 %} - {{ job.created_by.name }}{{ job.notification_count }}
No batched job messages found  (messages are kept for {{ service_data_retention_days }} days).
+ {% endfor %} + {% else %} + + No batched job messages found  (messages are kept for {{ service_data_retention_days }} days). + + {% endif %} + + +

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

+
- -

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..34e820d32 100644 --- a/app/templates/views/dashboard/template-statistics.html +++ b/app/templates/views/dashboard/template-statistics.html @@ -1,7 +1,8 @@ {% 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( template_statistics, diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index b5a58f550..37dbdf831 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( @@ -1936,6 +1928,6 @@ 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) == 0 - assert len(rows) == 1 + assert job_table_body is not None