mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
updated dashboard
This commit is contained in:
@@ -50,34 +50,52 @@ def service_dashboard(service_id):
|
||||
|
||||
notifications = notification_api_client.get_notifications_for_service(
|
||||
service_id=service_id,
|
||||
)['notifications']
|
||||
)["notifications"]
|
||||
|
||||
notificaton_job_ids = [notification['job']['id'] for notification in notifications if 'job' in notification]
|
||||
notificaton_job_ids = [
|
||||
notification["job"]["id"]
|
||||
for notification in notifications
|
||||
if "job" in notification
|
||||
]
|
||||
|
||||
jobs = []
|
||||
|
||||
for notificaton_job_id in notificaton_job_ids:
|
||||
job_data = job_api_client.get_job(service_id, notificaton_job_id)["data"]
|
||||
jobs.append(job_data)
|
||||
if job_data:
|
||||
jobs.append(job_data)
|
||||
|
||||
service_data_retention_days = None
|
||||
|
||||
download_availability = []
|
||||
for job in jobs:
|
||||
message_type = job.get('template_type')
|
||||
message_type = job.get("template_type")
|
||||
if message_type is not None:
|
||||
service_data_retention_days = current_service.get_days_of_retention(message_type)
|
||||
time_left = get_time_left(job['created_at'], service_data_retention_days=service_data_retention_days)
|
||||
download_availability.append({"job_id": job['id'], "time_left": time_left})
|
||||
|
||||
service_data_retention_days = current_service.get_days_of_retention(
|
||||
message_type
|
||||
)
|
||||
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_availability.append(
|
||||
{
|
||||
"job_id": job["id"],
|
||||
"time_left": time_left,
|
||||
"download_link": download_link,
|
||||
}
|
||||
)
|
||||
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,
|
||||
download_availability=download_availability,
|
||||
service_data_retention_days=service_data_retention_days
|
||||
)
|
||||
service_data_retention_days=service_data_retention_days,
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/dashboard.json")
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
) %}
|
||||
{% if item.job.original_file_name and item.job.id %}
|
||||
{% call row_heading() %}
|
||||
<a class="usa-link file-list-filename" href="/services/{{ item.service }}/jobs/{{ item.job.id }}">{{ item.job.original_file_name|replace('.csv', '') if item.job.id else '' }}</a>
|
||||
<a class="usa-link file-list-filename" href="/services/{{ item.service }}/jobs/{{ item.job.id }}">{{ item.job.original_file_name|replace('.csv', '') if item.job.id else '' }}</a>
|
||||
{% endcall %}
|
||||
{% call row_heading() %}
|
||||
{{ item.status|format_notification_status_as_time(
|
||||
@@ -53,11 +53,13 @@
|
||||
}}
|
||||
{% endcall %}
|
||||
{% call row_heading() %}
|
||||
<a class="usa-link file-list-filename" href="/services/{{ item.service }}/jobs/{{ item.job.id }}.csv">{{ "Download" if item.job.original_file_name else '' }}</a>
|
||||
{% set availability = download_availability|selectattr('job_id', 'equalto', item.job.id)|first %}
|
||||
{% if availability %}
|
||||
{% if availability and availability.time_left != "Data no longer available" %}
|
||||
<a class="usa-link file-list-filename" href="{{ availability.download_link[0] }}">{{ "Download" if item.job.original_file_name else '' }}</a>
|
||||
<span>- {{ availability.time_left }}</span>
|
||||
{% endif %}
|
||||
{% elif availability %}
|
||||
<span>{{ availability.time_left }}</span>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
@@ -77,7 +79,7 @@
|
||||
<h2 class="margin-top-4 margin-bottom-1">Usage</h2>
|
||||
<h3 class="margin-bottom-0">Daily</h3>
|
||||
<p class="margin-0">Across all services</p>
|
||||
<table class="usa-table usa-table--borderless margin-top-1 margin-bottom-5">
|
||||
<table class="usage-table usa-table usa-table--borderless margin-top-1 margin-bottom-5">
|
||||
<caption class="usa-sr-only">
|
||||
Daily
|
||||
</caption>
|
||||
|
||||
Reference in New Issue
Block a user