From a920528902aa019527cadbd1064b5dd4a3fe4082 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Wed, 3 Jan 2024 00:26:49 -0800 Subject: [PATCH] moved table to dashboard --- app/main/views/dashboard.py | 5 +++ app/main/views/jobs.py | 1 + .../views/activity/notifications.html | 16 ++++--- app/templates/views/dashboard/dashboard.html | 44 ++++++++++++++++++- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 161b00eda..10ca0e534 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -13,6 +13,8 @@ from app import ( current_service, service_api_client, template_statistics_client, + format_datetime_short, + notification_api_client, ) from app.formatters import format_date_numeric, format_datetime_numeric from app.main import main @@ -27,6 +29,8 @@ 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 app.main.views.jobs import get_notifications +from pprint import pprint @main.route("/services//dashboard") @@ -49,6 +53,7 @@ def service_dashboard(service_id): "views/dashboard/dashboard.html", updates_url=url_for(".service_dashboard_updates", service_id=service_id), partials=get_dashboard_partials(service_id), + batched=get_notifications(service_id, message_type=None), ) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index ed8f051a3..bb1ac6f6f 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -235,6 +235,7 @@ def get_notifications(service_id, message_type, status_override=None): # noqa return { "service_data_retention_days": service_data_retention_days, + 'batched_data': notifications['notifications'], "counts": render_template( "views/activity/counts.html", status=request.args.get("status"), diff --git a/app/templates/views/activity/notifications.html b/app/templates/views/activity/notifications.html index 5909474a7..eba0be348 100644 --- a/app/templates/views/activity/notifications.html +++ b/app/templates/views/activity/notifications.html @@ -5,7 +5,7 @@
{% if notifications %} -
+
{% endif %} {% call(item, row_number) list_table( notifications, @@ -13,15 +13,21 @@ caption_visible=False, border_visible=True, empty_message='No batched job messages found  (messages are kept for {} days)'.format(limit_days)|safe, - field_headings=['Batched Job', 'Download (CSV) Report'], + field_headings=['Template Name','Date/Time', 'Download (CSV) Report'], field_headings_visible=False ) %} {% if item.job.original_file_name %} {% call row_heading() %} - {{ item.job.original_file_name|replace('.csv', '') if item.job.id else '' }} + {{ item.job.original_file_name|replace('.csv', '') if item.job.id else '' }} {% endcall %} - {% call row_heading() %} - {{ "Download Report" if item.job.original_file_name else '' }} + {% call row_heading() %} + {{ item.status|format_notification_status_as_time( + item.created_at|format_datetime_short, + (item.updated_at or item.created_at)|format_datetime_short + ) }} + {% endcall %} + {% call row_heading() %} + {{ "Download" if item.job.original_file_name else '' }} - available for {{ limit_days }} days {% endcall %} {% endif %} diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 52a7694ac..603037e83 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -1,6 +1,6 @@ {% extends "withnav_template.html" %} -{% from "components/table.html" import list_table, field, right_aligned_field_heading, hidden_field_heading %} +{% from "components/table.html" import list_table, field, text_field, link_field, right_aligned_field_heading, hidden_field_heading, row_heading, notification_status_field, notification_carrier_field, notification_carrier_message_field %} {% from "components/ajax-block.html" import ajax_block %} {% block service_page_title %} @@ -29,6 +29,48 @@ {{ ajax_block(partials, updates_url, 'template-statistics') }} +

Batched Jobs

+ {% if batched %} +
+ {% endif %} + {% call(item, row_number) list_table( + batched['batched_data'], + caption="Batched Jobs", + caption_visible=False, + border_visible=True, + empty_message='No batched job messages found  (messages are kept for {} days)'.format(limit_days)|safe, + field_headings=['Template Name','Date/Time', 'Download (CSV) Report'], + field_headings_visible=False + ) %} + {% if item.job.original_file_name %} + {% call row_heading() %} + {{ item.job.original_file_name|replace('.csv', '') if item.job.id else '' }} + {% endcall %} + {% call row_heading() %} + {{ item.status|format_notification_status_as_time( + item.created_at|format_datetime_short, + (item.updated_at or item.created_at)|format_datetime_short + ) }} + {% endcall %} + {% call row_heading() %} + {{ "Download" if item.job.original_file_name else '' }} + - available for {{ service_data_retention_days }} days + {% endcall %} + {% endif %} + {% endcall %} + {% if batched %} +
+ {% endif %} + + {% if show_pagination %} + {{ previous_next_navigation(prev_page, next_page) }} + {% elif next_page %} + + {% endif %} + +

Usage

Daily

Across all services