mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 22:48:24 -04:00
Merge pull request #2311 from GSA/2171-clean-up-titles
Pluralization around text, fixing conditionals, making bar chart more visible
This commit is contained in:
@@ -130,11 +130,12 @@
|
|||||||
.append('g')
|
.append('g')
|
||||||
.attr('class', 'bar-group')
|
.attr('class', 'bar-group')
|
||||||
.attr('fill', d => color(d.key));
|
.attr('fill', d => color(d.key));
|
||||||
|
const minBarHeight = 5;
|
||||||
barGroups.selectAll('rect')
|
barGroups.selectAll('rect')
|
||||||
.data(d => d)
|
.data(d => d)
|
||||||
.enter()
|
.enter()
|
||||||
.append('rect')
|
.append('rect')
|
||||||
|
.filter(d => d[1] - d[0] > 0)
|
||||||
.attr('x', d => x(d.data.label))
|
.attr('x', d => x(d.data.label))
|
||||||
.attr('y', height)
|
.attr('y', height)
|
||||||
.attr('height', 0)
|
.attr('height', 0)
|
||||||
@@ -155,8 +156,10 @@
|
|||||||
.transition()
|
.transition()
|
||||||
.duration(1000)
|
.duration(1000)
|
||||||
.attr('y', d => y(d[1]))
|
.attr('y', d => y(d[1]))
|
||||||
.attr('height', d => y(d[0]) - y(d[1]));
|
.attr('height', d => {
|
||||||
};
|
const calculatedHeight = y(d[0]) - y(d[1]);
|
||||||
|
return calculatedHeight < minBarHeight ? minBarHeight : calculatedHeight;
|
||||||
|
}); };
|
||||||
|
|
||||||
// Function to create an accessible table
|
// Function to create an accessible table
|
||||||
const createTable = function(tableId, chartType, labels, deliveredData, failedData, pendingData) {
|
const createTable = function(tableId, chartType, labels, deliveredData, failedData, pendingData) {
|
||||||
@@ -238,9 +241,6 @@
|
|||||||
failedData.push(data[dateString].sms.failure);
|
failedData.push(data[dateString].sms.failure);
|
||||||
pendingData.push(data[dateString].sms.pending || 0);
|
pendingData.push(data[dateString].sms.pending || 0);
|
||||||
totalMessages += data[dateString].sms.delivered + data[dateString].sms.failure + data[dateString].sms.pending;
|
totalMessages += data[dateString].sms.delivered + data[dateString].sms.failure + data[dateString].sms.pending;
|
||||||
|
|
||||||
// Calculate the total number of messages
|
|
||||||
totalMessages += data[dateString].sms.delivered + data[dateString].sms.failure;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,20 +62,46 @@ def service_dashboard(service_id):
|
|||||||
job_response = job_api_client.get_jobs(service_id)["data"]
|
job_response = job_api_client.get_jobs(service_id)["data"]
|
||||||
service_data_retention_days = 7
|
service_data_retention_days = 7
|
||||||
|
|
||||||
filtered_jobs = [job for job in job_response if job["job_status"] != "cancelled"]
|
active_jobs = [job for job in job_response if job["job_status"] != "cancelled"]
|
||||||
sorted_jobs = sorted(filtered_jobs, key=lambda job: job["created_at"], reverse=True)
|
sorted_jobs = sorted(active_jobs, key=lambda job: job["created_at"], reverse=True)
|
||||||
|
job_lists = [
|
||||||
|
{
|
||||||
|
**job_dict,
|
||||||
|
"finished_processing": job_is_finished(job_dict)
|
||||||
|
}
|
||||||
|
for job_dict in sorted_jobs
|
||||||
|
]
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"views/dashboard/dashboard.html",
|
"views/dashboard/dashboard.html",
|
||||||
updates_url=url_for(".service_dashboard_updates", service_id=service_id),
|
updates_url=url_for(".service_dashboard_updates", service_id=service_id),
|
||||||
partials=get_dashboard_partials(service_id),
|
partials=get_dashboard_partials(service_id),
|
||||||
jobs=sorted_jobs,
|
jobs=job_lists,
|
||||||
service_data_retention_days=service_data_retention_days,
|
service_data_retention_days=service_data_retention_days,
|
||||||
sms_sent=sms_sent,
|
sms_sent=sms_sent,
|
||||||
sms_allowance_remaining=sms_allowance_remaining,
|
sms_allowance_remaining=sms_allowance_remaining,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def job_is_finished(job_dict):
|
||||||
|
done_statuses = [
|
||||||
|
"delivered",
|
||||||
|
"sent",
|
||||||
|
"failed",
|
||||||
|
"technical-failure",
|
||||||
|
"temporary-failure",
|
||||||
|
"permanent-failure",
|
||||||
|
"cancelled"
|
||||||
|
]
|
||||||
|
|
||||||
|
processed_count = sum(
|
||||||
|
stat["count"]
|
||||||
|
for stat in job_dict["statistics"]
|
||||||
|
if stat["status"] in done_statuses
|
||||||
|
)
|
||||||
|
return job_dict["notification_count"] == processed_count
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services/<uuid:service_id>/daily-stats.json")
|
@main.route("/services/<uuid:service_id>/daily-stats.json")
|
||||||
@user_has_permissions()
|
@user_has_permissions()
|
||||||
def get_daily_stats(service_id):
|
def get_daily_stats(service_id):
|
||||||
@@ -89,7 +115,6 @@ def get_daily_stats(service_id):
|
|||||||
@main.route("/services/<uuid:service_id>/daily-stats-by-user.json")
|
@main.route("/services/<uuid:service_id>/daily-stats-by-user.json")
|
||||||
@user_has_permissions()
|
@user_has_permissions()
|
||||||
def get_daily_stats_by_user(service_id):
|
def get_daily_stats_by_user(service_id):
|
||||||
service_id = session.get("service_id")
|
|
||||||
date_range = get_stats_date_range()
|
date_range = get_stats_date_range()
|
||||||
stats = service_api_client.get_user_service_notification_statistics_by_day(
|
stats = service_api_client.get_user_service_notification_statistics_by_day(
|
||||||
service_id,
|
service_id,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
{% if job.scheduled_for %}
|
{% if job.scheduled_for %}
|
||||||
<div class="usa-alert usa-alert--info">
|
<div class="usa-alert usa-alert--info">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
<h2 class="usa-alert__heading">Your message has been scheduled</h2>
|
<h2 class="usa-alert__heading">Your {{ 'message has' if job.notification_count == 1 else 'messages have' }} been scheduled</h2>
|
||||||
<p class="usa-alert__text">
|
<p class="usa-alert__text">
|
||||||
{{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_normal }} by {{ job.created_by.name }}
|
{{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_normal }} by {{ job.created_by.name }}
|
||||||
</p>
|
</p>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="usa-alert usa-alert--success">
|
<div class="usa-alert usa-alert--success">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
<h2 class="usa-alert__heading">
|
<h2 class="usa-alert__heading">
|
||||||
Your message is sending
|
Your {{ 'message is' if job.notification_count == 1 else 'messages are' }} sending
|
||||||
</h2>
|
</h2>
|
||||||
<p class="usa-alert__text">
|
<p class="usa-alert__text">
|
||||||
{{ job.template_name }} - {{ current_service.name }}
|
{{ job.template_name }} - {{ current_service.name }}
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
<div class="usa-alert usa-alert--info">
|
<div class="usa-alert usa-alert--info">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
<h2 class="usa-alert__heading">
|
<h2 class="usa-alert__heading">
|
||||||
Your message is pending
|
Your {{ 'message is' if job.notification_count == 1 else 'messages are' }} pending
|
||||||
</h2>
|
</h2>
|
||||||
<p class="usa-alert__text">
|
<p class="usa-alert__text">
|
||||||
{{ job.template_name }} - {{ current_service.name }}
|
{{ job.template_name }} - {{ current_service.name }}
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<div class="usa-alert usa-alert--success">
|
<div class="usa-alert usa-alert--success">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
<h2 class="usa-alert__heading">
|
<h2 class="usa-alert__heading">
|
||||||
Your message has been sent
|
Your {{ 'message has' if job.notification_count == 1 else 'messages have' }} been sent
|
||||||
</h2>
|
</h2>
|
||||||
<p class="usa-alert__text">
|
<p class="usa-alert__text">
|
||||||
{{ job.template_name }} - {{ current_service.name }}
|
{{ job.template_name }} - {{ current_service.name }}
|
||||||
|
|||||||
@@ -46,14 +46,16 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="table-field template">{{ job.template_name }}</td>
|
<td class="table-field template">{{ job.template_name }}</td>
|
||||||
<td class="table-field time-sent">
|
<td class="table-field time-sent">
|
||||||
{% if job.scheduled_for and not job.processing_finished %}
|
{% if not job.finished_processing %}
|
||||||
Scheduled for {{ job.scheduled_for|format_datetime_table }}
|
{% if job.scheduled_for%}
|
||||||
{% elif job.processing_finished and not job.statistics|selectattr('status', 'equalto', 'sending')|list %}
|
Scheduled for {{ job.scheduled_for|format_datetime_table }}
|
||||||
Sent on {{ job.processing_finished|format_datetime_table }}
|
{% elif job.processing_started %}
|
||||||
{% elif job.processing_started %}
|
Sending since {{ job.processing_started|format_datetime_table }}
|
||||||
Sending since {{ job.processing_started|format_datetime_table }}
|
{% else %}
|
||||||
|
Pending since {{ job.created_at|format_datetime_table }}
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
Pending since {{ job.created_at|format_datetime_table }}
|
Sent on {{ job.processing_started|format_datetime_table }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="table-field sender sender-column">{{ job.created_by.name }}</td>
|
<td class="table-field sender sender-column">{{ job.created_by.name }}</td>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
{% block maincolumn_content %}
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
{{ page_header("Message status") }}
|
{{ page_header("Message status") }}
|
||||||
{% if not job.processing_finished %}
|
{% if not job.finished_processing %}
|
||||||
<div
|
<div
|
||||||
data-module="update-content"
|
data-module="update-content"
|
||||||
data-resource="{{ updates_url }}"
|
data-resource="{{ updates_url }}"
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
>
|
>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ partials['status']|safe }}
|
{{ partials['status']|safe }}
|
||||||
{% if not job.processing_finished %}
|
{% if not job.finished_processing %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not finished %}
|
{% if not finished %}
|
||||||
|
|||||||
Reference in New Issue
Block a user