mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
test_nav
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
(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);
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
from flask import abort, render_template, request, session, url_for
|
from flask import abort, render_template, request, url_for
|
||||||
from flask_login import current_user
|
|
||||||
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 convert_time_unixtimestamp, get_time_left
|
from app.formatters import convert_time_unixtimestamp, get_time_left
|
||||||
@@ -17,12 +15,6 @@ from app.utils.user import user_has_permissions
|
|||||||
@main.route("/activity/services/<uuid:service_id>")
|
@main.route("/activity/services/<uuid:service_id>")
|
||||||
@user_has_permissions()
|
@user_has_permissions()
|
||||||
def all_jobs_activity(service_id):
|
def all_jobs_activity(service_id):
|
||||||
if session.get("invited_user_id"):
|
|
||||||
session.pop("invited_user_id", None)
|
|
||||||
session["service_id"] = service_id
|
|
||||||
|
|
||||||
if not current_user.has_permissions("view_activity"):
|
|
||||||
return redirect(url_for("main.choose_template", service_id=service_id))
|
|
||||||
service_data_retention_days = 7
|
service_data_retention_days = 7
|
||||||
page = get_page_from_request()
|
page = get_page_from_request()
|
||||||
jobs = job_api_client.get_page_of_jobs(service_id, page=page)
|
jobs = job_api_client.get_page_of_jobs(service_id, page=page)
|
||||||
@@ -36,16 +28,25 @@ def all_jobs_activity(service_id):
|
|||||||
next_page=next_page,
|
next_page=next_page,
|
||||||
prev_page=prev_page,
|
prev_page=prev_page,
|
||||||
pagination=pagination,
|
pagination=pagination,
|
||||||
jobs=jobs
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle_pagination(jobs, service_id, page):
|
def handle_pagination(jobs, service_id, page):
|
||||||
if page is None:
|
if page is None:
|
||||||
abort(404, "Invalid page argument ({}).".format(request.args.get("page")))
|
abort(404, "Invalid page argument ({}).".format(request.args.get("page")))
|
||||||
prev_page = generate_previous_dict("main.all_jobs_activity", service_id, page) if page > 1 else None
|
prev_page = (
|
||||||
next_page = generate_next_dict("main.all_jobs_activity", service_id, page) if jobs["links"].get("next") else None
|
generate_previous_dict("main.all_jobs_activity", service_id, page)
|
||||||
pagination = generate_pagination_pages(jobs["total"], jobs['page_size'], page)
|
if page > 1
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
next_page = (
|
||||||
|
generate_next_dict("main.all_jobs_activity", service_id, page)
|
||||||
|
if jobs.get("links", {}).get("next")
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
pagination = generate_pagination_pages(
|
||||||
|
jobs.get("total", {}), jobs.get("page_size", {}), page
|
||||||
|
)
|
||||||
return prev_page, next_page, pagination
|
return prev_page, next_page, pagination
|
||||||
|
|
||||||
|
|
||||||
@@ -54,18 +55,26 @@ def generate_job_dict(jobs):
|
|||||||
{
|
{
|
||||||
"job_id": job["id"],
|
"job_id": job["id"],
|
||||||
"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_link": url_for(".view_job", service_id=current_service.id, job_id=job["id"]),
|
".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"]
|
||||||
|
),
|
||||||
"created_at": job["created_at"],
|
"created_at": job["created_at"],
|
||||||
"time_sent_data_value": convert_time_unixtimestamp(
|
"time_sent_data_value": convert_time_unixtimestamp(
|
||||||
job["processing_finished"] if job["processing_finished"]
|
job["processing_finished"]
|
||||||
else job["processing_started"] if job["processing_started"]
|
if job["processing_finished"]
|
||||||
else job["created_at"]
|
else (
|
||||||
|
job["processing_started"]
|
||||||
|
if job["processing_started"]
|
||||||
|
else job["created_at"]
|
||||||
|
)
|
||||||
),
|
),
|
||||||
"processing_finished": job["processing_finished"],
|
"processing_finished": job["processing_finished"],
|
||||||
"processing_started": job["processing_started"],
|
"processing_started": job["processing_started"],
|
||||||
"created_by": job["created_by"],
|
"created_by": job["created_by"],
|
||||||
"template_name": job["template_name"]
|
"template_name": job["template_name"],
|
||||||
}
|
}
|
||||||
for job in jobs["data"]
|
for job in jobs["data"]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,16 +33,18 @@ def generate_previous_next_dict(view, service_id, page, title, url_args):
|
|||||||
|
|
||||||
def generate_pagination_pages(total_items, page_size, current_page):
|
def generate_pagination_pages(total_items, page_size, current_page):
|
||||||
total_pages = (total_items + page_size - 1) // page_size
|
total_pages = (total_items + page_size - 1) // page_size
|
||||||
pagination = {
|
pagination = {"current": current_page, "pages": [], "last": total_pages}
|
||||||
'current': current_page,
|
|
||||||
'pages': [],
|
|
||||||
'last': total_pages
|
|
||||||
}
|
|
||||||
if total_pages <= 4:
|
if total_pages <= 4:
|
||||||
pagination['pages'] = list(range(1, total_pages + 1))
|
pagination["pages"] = list(range(1, total_pages + 1))
|
||||||
else:
|
else:
|
||||||
if current_page <= 3:
|
if current_page <= 3:
|
||||||
pagination['pages'] = [1, 2, 3, total_pages]
|
pagination["pages"] = [1, 2, 3, total_pages]
|
||||||
else:
|
else:
|
||||||
pagination['pages'] = [1, current_page - 1, current_page, current_page + 1, total_pages]
|
pagination["pages"] = [
|
||||||
|
1,
|
||||||
|
current_page - 1,
|
||||||
|
current_page,
|
||||||
|
current_page + 1,
|
||||||
|
total_pages,
|
||||||
|
]
|
||||||
return pagination
|
return pagination
|
||||||
|
|||||||
@@ -126,8 +126,6 @@ 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({
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ EXCLUDED_ENDPOINTS = tuple(
|
|||||||
"add_organization",
|
"add_organization",
|
||||||
"add_service",
|
"add_service",
|
||||||
"add_service_template",
|
"add_service_template",
|
||||||
|
"all_jobs_activity",
|
||||||
"api_callbacks",
|
"api_callbacks",
|
||||||
"api_documentation",
|
"api_documentation",
|
||||||
"api_integration",
|
"api_integration",
|
||||||
@@ -400,6 +401,7 @@ def test_navigation_urls(
|
|||||||
assert [a["href"] for a in page.select(".nav a")] == [
|
assert [a["href"] for a in page.select(".nav a")] == [
|
||||||
"/services/{}/templates".format(SERVICE_ONE_ID),
|
"/services/{}/templates".format(SERVICE_ONE_ID),
|
||||||
"/services/{}".format(SERVICE_ONE_ID),
|
"/services/{}".format(SERVICE_ONE_ID),
|
||||||
|
"/activity/services/{}".format(SERVICE_ONE_ID),
|
||||||
# "/services/{}/usage".format(SERVICE_ONE_ID),
|
# "/services/{}/usage".format(SERVICE_ONE_ID),
|
||||||
# "/services/{}/users".format(SERVICE_ONE_ID),
|
# "/services/{}/users".format(SERVICE_ONE_ID),
|
||||||
# "/services/{}/service-settings".format(SERVICE_ONE_ID),
|
# "/services/{}/service-settings".format(SERVICE_ONE_ID),
|
||||||
|
|||||||
Reference in New Issue
Block a user