mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 03:14:58 -04:00
moved table to parent dashboard
This commit is contained in:
@@ -16,7 +16,7 @@ from app import (
|
||||
format_datetime_short,
|
||||
notification_api_client,
|
||||
)
|
||||
from app.formatters import format_date_numeric, format_datetime_numeric
|
||||
from app.formatters import format_date_numeric, format_datetime_numeric, get_time_left
|
||||
from app.main import main
|
||||
from app.statistics_utils import get_formatted_percentage
|
||||
from app.utils import (
|
||||
@@ -42,6 +42,7 @@ def old_service_dashboard(service_id):
|
||||
@main.route("/services/<uuid:service_id>")
|
||||
@user_has_permissions()
|
||||
def service_dashboard(service_id):
|
||||
download_availability = []
|
||||
if session.get("invited_user_id"):
|
||||
session.pop("invited_user_id", None)
|
||||
session["service_id"] = service_id
|
||||
@@ -49,11 +50,25 @@ 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=get_notifications(service_id, message_type=None)['batched_data']
|
||||
|
||||
for notification in notifications:
|
||||
message_type = notification.get('template_type')
|
||||
job_id = notification.get('job', {}).get('id')
|
||||
original_file_name = notification.get('job', {}).get('original_file_name')
|
||||
service_data_retention_days = current_service.get_days_of_retention(
|
||||
message_type
|
||||
)
|
||||
created_at = notification.get('created_at')
|
||||
if job_id and original_file_name:
|
||||
time_left_value = get_time_left(created_at, service_data_retention_days=service_data_retention_days)
|
||||
download_availability.append({'job_id': job_id, 'time_left': time_left_value})
|
||||
return render_template(
|
||||
"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),
|
||||
notifications=notifications,
|
||||
download_availability=download_availability,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,48 +3,7 @@
|
||||
{% 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 %}
|
||||
|
||||
<div class="ajax-block-container" id='pill-selected-item'>
|
||||
<!-- Batched Job Table -->
|
||||
{% if notifications %}
|
||||
<div class='job-table'>
|
||||
{% endif %}
|
||||
{% call(item, row_number) list_table(
|
||||
notifications,
|
||||
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() %}
|
||||
<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(
|
||||
item.created_at|format_datetime_short,
|
||||
(item.updated_at or item.created_at)|format_datetime_short
|
||||
) }}
|
||||
{% 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>
|
||||
<span>- available for {{ limit_days }} days</span>
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% if notifications %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_pagination %}
|
||||
{{ previous_next_navigation(prev_page, next_page) }}
|
||||
{% elif next_page %}
|
||||
<p class="table-show-more-link">
|
||||
Only showing the first 50 messages
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- Dashboard Table -->
|
||||
{% if notifications %}
|
||||
<div class='dashboard-table'>
|
||||
{% endif %}
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
{{ ajax_block(partials, updates_url, 'template-statistics') }}
|
||||
|
||||
<h2 class="margin-top-4 margin-bottom-1">Batched Jobs</h2>
|
||||
{% if batched %}
|
||||
{% if notifications %}
|
||||
<div class='job-table'>
|
||||
{% endif %}
|
||||
{% call(item, row_number) list_table(
|
||||
batched['batched_data'],
|
||||
notifications,
|
||||
caption="Batched Jobs",
|
||||
caption_visible=False,
|
||||
border_visible=True,
|
||||
@@ -42,7 +42,7 @@
|
||||
field_headings=['Template Name','Date/Time', 'Download (CSV) Report'],
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
{% if item.job.original_file_name %}
|
||||
{% 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>
|
||||
{% endcall %}
|
||||
@@ -54,7 +54,10 @@
|
||||
{% 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>
|
||||
<span>- available for {{ service_data_retention_days }} days</span>
|
||||
{% set availability = download_availability|selectattr('job_id', 'equalto', item.job.id)|first %}
|
||||
{% if availability %}
|
||||
<span>- {{ availability.time_left }}</span>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
|
||||
Reference in New Issue
Block a user