mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-06 00:48:46 -04:00
convert time to sort
This commit is contained in:
@@ -33,6 +33,7 @@ from app.asset_fingerprinter import asset_fingerprinter
|
|||||||
from app.config import configs
|
from app.config import configs
|
||||||
from app.extensions import redis_client
|
from app.extensions import redis_client
|
||||||
from app.formatters import (
|
from app.formatters import (
|
||||||
|
convert_time_unixtimestamp,
|
||||||
convert_markdown_template,
|
convert_markdown_template,
|
||||||
convert_to_boolean,
|
convert_to_boolean,
|
||||||
format_auth_type,
|
format_auth_type,
|
||||||
|
|||||||
14
app/assets/javascripts/sortAlphanumeric.js
Normal file
14
app/assets/javascripts/sortAlphanumeric.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
(function (window) {
|
||||||
|
// document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
// const rows = document.querySelectorAll('td.table-field.file-name');
|
||||||
|
|
||||||
|
// rows.forEach(row => {
|
||||||
|
// let sortValue = row.getAttribute('data-sort-value');
|
||||||
|
// if (sortValue) {
|
||||||
|
// // Remove non-numeric characters to ensure numerical comparison
|
||||||
|
// sortValue = sortValue.replace(/\D/g, '');
|
||||||
|
// row.setAttribute('data-sort-value', sortValue);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
})(window);
|
||||||
@@ -231,6 +231,11 @@ def naturaltime_without_indefinite_article(date):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def convert_time_unixtimestamp(date_string):
|
||||||
|
dt = datetime.fromisoformat(date_string)
|
||||||
|
return int(dt.timestamp())
|
||||||
|
|
||||||
|
|
||||||
def format_delta(date):
|
def format_delta(date):
|
||||||
# This method assumes that date is in UTC
|
# This method assumes that date is in UTC
|
||||||
date = parse_naive_dt(date)
|
date = parse_naive_dt(date)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from flask_login import current_user
|
|||||||
from werkzeug.utils import redirect
|
from werkzeug.utils import redirect
|
||||||
|
|
||||||
from app import current_service, job_api_client
|
from app import current_service, job_api_client
|
||||||
from app.formatters import get_time_left
|
from app.formatters import get_time_left, convert_time_unixtimestamp
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.utils.pagination import (
|
from app.utils.pagination import (
|
||||||
generate_next_dict,
|
generate_next_dict,
|
||||||
@@ -35,7 +35,8 @@ def all_jobs_activity(service_id):
|
|||||||
service_data_retention_days=service_data_retention_days,
|
service_data_retention_days=service_data_retention_days,
|
||||||
next_page=next_page,
|
next_page=next_page,
|
||||||
prev_page=prev_page,
|
prev_page=prev_page,
|
||||||
pagination=pagination
|
pagination=pagination,
|
||||||
|
jobs=jobs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -56,10 +57,16 @@ def generate_job_dict(jobs):
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"job_id": job["id"],
|
"job_id": job["id"],
|
||||||
|
"sort_value": hashlib.sha1(job["id"].encode("utf-8")).hexdigest(),
|
||||||
|
"job_sort_value": job["id"].replace("-", ""),
|
||||||
"time_left": get_time_left(job["created_at"]),
|
"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_link": url_for(".view_job_csv", service_id=current_service.id, job_id=job["id"]),
|
||||||
"view_job_link": url_for(".view_job", service_id=current_service.id, job_id=job["id"]),
|
"view_job_link": url_for(".view_job", service_id=current_service.id, job_id=job["id"]),
|
||||||
"created_at": job["created_at"],
|
"created_at": job["created_at"],
|
||||||
|
"time_sent_data_value": convert_time_unixtimestamp(job["processing_finished"] if job["processing_finished"] else job["processing_started"]
|
||||||
|
if job["processing_started"] else job["created_at"]),
|
||||||
|
"processing_finished": job["processing_finished"],
|
||||||
|
"processing_started": job["processing_started"],
|
||||||
"notification_count": job["notification_count"],
|
"notification_count": job["notification_count"],
|
||||||
"created_by": job["created_by"],
|
"created_by": job["created_by"],
|
||||||
"template_name": job["template_name"]
|
"template_name": job["template_name"]
|
||||||
|
|||||||
@@ -65,45 +65,36 @@
|
|||||||
|
|
||||||
|
|
||||||
{% block maincolumn_content %}
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
<div class="dashboard margin-bottom-8">
|
<div class="dashboard margin-bottom-8">
|
||||||
<h1 class="usa-sr-only">All activity</h1>
|
<h1 class="usa-sr-only">All activity</h1>
|
||||||
{% if current_user.has_permissions('manage_templates') and not current_service.all_templates %}
|
{% if current_user.has_permissions('manage_templates') and not current_service.all_templates %}
|
||||||
<!-- {% include 'views/dashboard/write-first-messages.html' %} -->
|
<!-- {% include 'views/dashboard/write-first-messages.html' %} -->
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ ajax_block(partials, updates_url, 'upcoming') }}
|
<!-- {{ ajax_block(partials, updates_url, 'upcoming') }} -->
|
||||||
|
|
||||||
<h2 class="font-body-2xl line-height-sans-2 margin-0">All activity</h2>
|
<h2 class="font-body-2xl line-height-sans-2 margin-0">All activity</h2>
|
||||||
|
|
||||||
<h2 class="margin-top-4 margin-bottom-1">Sent jobs</h2>
|
<h2 class="margin-top-4 margin-bottom-1">Sent jobs</h2>
|
||||||
<div class="usa-table-container--scrollable" tabindex="0">
|
<div class="table-wrapper" tabindex="0">
|
||||||
<table class="usa-table usa-table--borderless job-table">
|
<table class="usa-table usa-table--borderless job-table" id="jobIdHeader">
|
||||||
|
<caption></caption>
|
||||||
<thead class="table-field-headings">
|
<thead class="table-field-headings">
|
||||||
<tr>
|
<tr>
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading-first">
|
<th data-sortable aria-sort="none" scope="col" role="columnheader" class="table-field-heading-first" aria-sort="none" id="jobId">
|
||||||
<span>Job ID#</span>
|
<span>Job ID#</span>
|
||||||
</th>
|
</th>
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
||||||
<span>Template</span>
|
<span>Template</span>
|
||||||
</th>
|
</th>
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
||||||
<span>Status</span>
|
<span>Time sent</span>
|
||||||
</th>
|
</th>
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
||||||
<span>Sender</span>
|
<span>Sender</span>
|
||||||
</th>
|
</th>
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
||||||
<span>Reports</span>
|
<span>Report</span>
|
||||||
</th>
|
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
|
||||||
<span># of Recipients</span>
|
|
||||||
</th>
|
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
|
||||||
<span>Message parts used</span>
|
|
||||||
</th>
|
|
||||||
<th data-sortable scope="col" role="columnheader" class="table-field-heading">
|
|
||||||
<span>Delivery rate</span>
|
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -111,17 +102,24 @@
|
|||||||
{% if all_jobs_dict %}
|
{% if all_jobs_dict %}
|
||||||
{% for job in all_jobs_dict %}
|
{% for job in all_jobs_dict %}
|
||||||
{% if job.job_id %}
|
{% if job.job_id %}
|
||||||
<tr class="table-row" id="{{ job.job_id }}">
|
<tr class="table-row" id="{{ job.job_id|replace('-', '') }}">
|
||||||
<td class="table-field file-name" data-sort-value="{{ job.job_id[-12:].rjust(12, '0') }}">
|
<!-- <th class="table-field file-name" scope="row" role="rowheader" data-sort-value="{{ job.job_id }}" id="jobId">
|
||||||
<a class="usa-link file-list-filename" href="{{ job.view_job_link }}">
|
<a class="usa-link file-list-filename" href="{{ job.view_job_link }}">
|
||||||
{{ job.job_id[-12:] if job and job.job_id else 'Manually entered number' }}
|
{{ job.job_id if job.job_id else 'Manually entered number' }}
|
||||||
</a>
|
</a>
|
||||||
|
</th> -->
|
||||||
|
<td class="table-field file-name" scope="row" role="rowheader" data-sort-value="{{ job.job_id | replace('-', '') }}">
|
||||||
|
<a class="usa-link file-list-filename" href="{{ job.view_job_link }}">
|
||||||
|
{{ job.job_id if job.job_id else 'Manually entered number' }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="table-field template">
|
<td class="table-field template">
|
||||||
{{ job.template_name }}
|
{{ job.template_name }}
|
||||||
</td>
|
</td>
|
||||||
<td class="table-field time-sent">
|
<td data-sort-value="{{job.time_sent_data_value}}" class="table-field time-sent">
|
||||||
{{ job.created_at | format_datetime_table }}
|
{{ (job.processing_finished if job.processing_finished else job.processing_started
|
||||||
|
if job.processing_started else job.created_at)|format_datetime_table }}
|
||||||
</td>
|
</td>
|
||||||
<td class="table-field sender">
|
<td class="table-field sender">
|
||||||
{{ job.created_by.name }}
|
{{ job.created_by.name }}
|
||||||
@@ -130,25 +128,19 @@
|
|||||||
{% if job.time_left != "Data no longer available" %}
|
{% if job.time_left != "Data no longer available" %}
|
||||||
<a class="usa-link file-list-filename" href="{{ job.download_link }}"><img src="{{ url_for('static', filename='img/material-icons/file_download.svg') }}" alt="File Download Icon"></a>
|
<a class="usa-link file-list-filename" href="{{ job.download_link }}"><img src="{{ url_for('static', filename='img/material-icons/file_download.svg') }}" alt="File Download Icon"></a>
|
||||||
{% elif job %}
|
{% elif job %}
|
||||||
<span>{{ job.time_left }} n/a</span>
|
<span>N/A</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="table-field count-of-recipients">
|
|
||||||
{{ job.notification_count}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr class="table-row">
|
|
||||||
<td class="table-empty-message" colspan="10">No batched job messages found  (messages are kept for {{ service_data_retention_days }} days).</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>
|
<div class="usa-sr-only usa-table__announcement-region" aria-live="polite"></div>
|
||||||
<b>Note:</b> Report data is only available for 7 days after your message has been sent
|
<p><b>Note:</b> Report data is only available for 7 days after your message has been sent</p>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
{{show_pagination}}
|
{{show_pagination}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ const javascripts = () => {
|
|||||||
paths.src + 'javascripts/loginAlert.js',
|
paths.src + 'javascripts/loginAlert.js',
|
||||||
paths.src + 'javascripts/main.js',
|
paths.src + 'javascripts/main.js',
|
||||||
paths.src + 'javascripts/sampleChartDashboard.js',
|
paths.src + 'javascripts/sampleChartDashboard.js',
|
||||||
|
paths.src + 'javascripts/sortAlphanumeric.js',
|
||||||
|
|
||||||
])
|
])
|
||||||
.pipe(plugins.prettyerror())
|
.pipe(plugins.prettyerror())
|
||||||
.pipe(plugins.babel({
|
.pipe(plugins.babel({
|
||||||
|
|||||||
Reference in New Issue
Block a user