Skip to content

Commit

Permalink
WP-201: add entity organization to user file submissions (#368)
Browse files Browse the repository at this point in the history
* WP-201: add entity organization to user file submissions

* Unifying submission modal and css.
  • Loading branch information
chandra-tacc authored Nov 20, 2024
1 parent d044bd4 commit 0dd8a1d
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<link rel="stylesheet" href="{% static 'apcd-cms/css/table.css' %}">
<link rel="stylesheet" href="{% static 'apcd-cms/css/modal.css' %}">
<link rel="stylesheet" href="{% static 'submissions/css/table.css' %}">
<link rel="stylesheet" href="{% static 'submissions/css/modal.css' %}">
<div class="container">
{% include "nav_cms_breadcrumbs.html" %}
<div id="list-admin-submissions"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
@media (max-width: 767px) {
/* To label the cells */
/* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */
.submission-table td:nth-of-type(1):before { content: "Submission ID"; }
.submission-table td:nth-of-type(2):before { content: "File Name"; }
.submission-table td:nth-of-type(3):before { content: "Status"; }
.submission-table td:nth-of-type(1):before { content: "Received"; }
.submission-table td:nth-of-type(2):before { content: "Organization"; }
.submission-table td:nth-of-type(3):before { content: "File Name"; }
.submission-table td:nth-of-type(4):before { content: "Outcome"; }
.submission-table td:nth-of-type(5):before { content: "Created"; }
.submission-table td:nth-of-type(5):before { content: "Status"; }
.submission-table td:nth-of-type(6):before { content: "Last Updated"; }
.submission-table td:nth-of-type(7):before { content: "Actions"; }
}
7 changes: 4 additions & 3 deletions apcd-cms/src/apps/submissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth.decorators import login_required
from apps.utils.apcd_database import get_user_submissions_and_logs
from apps.utils.apcd_groups import has_apcd_group
from apps.utils.utils import title_case, table_filter
from apps.utils.utils import title_case
from django.core.paginator import Paginator
import logging
from dateutil import parser
Expand Down Expand Up @@ -34,7 +34,7 @@ def get(self, request, *args, **kwargs):

paginator = Paginator(filtered_submissions, items_per_page)
page_info = paginator.get_page(page_number)
context= self.get_view_submissions_json(list(page_info), selected_status=status, selected_sort=sort)
context = self.get_view_submissions_json(list(page_info), selected_status=status, selected_sort=sort)
context['page_num'] = page_info.number
context['total_pages'] = paginator.num_pages
return JsonResponse({'response': context})
Expand Down Expand Up @@ -70,7 +70,7 @@ def getDate(submission):
submission_content = [submission for submission in submission_content
if submission['status'].lower() == status.lower()]

submission_content= sorted(
submission_content = sorted(
submission_content,
key=lambda row: getDate(row),
reverse=(sort == 'Newest Received')
Expand All @@ -89,6 +89,7 @@ def _set_submissions(submission):
return {
'submission_id': submission['submission_id'],
'submitter_id': submission['submitter_id'],
'entity_name': submission['entity_name'],
'file_name': submission['file_name'],
'status': submission['status'],
'outcome': title_case(submission['outcome']) if submission['outcome'] else None,
Expand Down
7 changes: 6 additions & 1 deletion apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ def get_user_submissions_and_logs(user):
SELECT json_build_object(
'submission_id', submissions.submission_id,
'submitter_id', submissions.submitter_id,
'entity_name', submitters.entity_name,
'file_name', submissions.zip_file_name,
'status', submissions.status,
'outcome', submissions.outcome,
Expand All @@ -855,6 +856,7 @@ def get_user_submissions_and_logs(user):
SELECT COALESCE(json_agg(json_build_object(
'log_id', submission_logs.log_id,
'submission_id', submission_logs.submission_id,
'entity_name', submitters.entity_name,
'file_type', submission_logs.file_type,
'validation_suite', submission_logs.validation_suite,
'outcome', submission_logs.outcome,
Expand All @@ -869,11 +871,13 @@ def get_user_submissions_and_logs(user):
FROM submissions
LEFT JOIN submission_logs
ON submissions.submission_id = submission_logs.submission_id
LEFT JOIN submitters
ON submitters.submitter_id = submissions.submitter_id
WHERE submissions.submitter_id
IN (
SELECT submitter_users.submitter_id FROM submitter_users
WHERE submitter_users.user_id = %s )
GROUP BY (submissions.submission_id)
GROUP BY (submissions.submission_id, submitters.entity_name)
ORDER BY submissions.received_timestamp DESC
"""
cur = conn.cursor()
Expand Down Expand Up @@ -914,6 +918,7 @@ def get_all_submissions_and_logs():
ELSE json_agg(json_build_object(
'log_id', submission_logs.log_id,
'submission_id', submission_logs.submission_id,
'entity_name', submitters.entity_name,
'file_type', submission_logs.file_type,
'validation_suite', submission_logs.validation_suite,
'outcome', submission_logs.outcome,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
height: 100%; /* Adjust as needed */
padding-top: 20px;
}
.submissionTable td {
word-wrap: break-word;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useEffect, useState } from 'react';
import { useSubmissions, useSubmissionFilters } from 'hooks/admin';
import {
useSubmissions,
SubmissionRow,
useSubmissionFilters,
SubmissionLogsModalContent,
} from 'hooks/admin';
import { ViewSubmissionLogsModal } from './ViewSubmissionLogsModal';
FileSubmissionRow,
FileSubmissionLogsModalContent,
} from 'hooks/submissions';
import { ViewSubmissionLogsModal } from 'apcd-components/Submissions/ViewFileSubmissions';
import LoadingSpinner from 'core-components/LoadingSpinner';
import SectionMessage from 'core-components/SectionMessage';
import Button from 'core-components/Button';
Expand Down Expand Up @@ -36,10 +35,10 @@ export const AdminSubmissions: React.FC = () => {
const [page, setPage] = useState<number>(1);
const [viewModalOpen, setViewModalOpen] = useState(false);
const [selectedSubmission, setSelectedSubmission] =
useState<SubmissionRow | null>(null);
useState<FileSubmissionRow | null>(null);

const [selectedSubmissionLog, setSelectedSubmissionLog] = useState<
SubmissionLogsModalContent[]
FileSubmissionLogsModalContent[]
>([]);

const closeModal = () => {
Expand Down Expand Up @@ -124,7 +123,7 @@ export const AdminSubmissions: React.FC = () => {
) : null}
</div>
</div>
<table id="submissionTable" className={styles.submissionTable}>
<table id="submissionTable" className="submission-table">
<thead>
<tr>
{header.map((columnName: string, index: number) => (
Expand All @@ -133,28 +132,30 @@ export const AdminSubmissions: React.FC = () => {
</tr>
</thead>
<tbody>
{submissionData?.page.map((row: SubmissionRow, rowIndex: number) => (
<tr key={rowIndex}>
<td>{formatDate(row.received_timestamp)}</td>
<td>{titleCase(row.entity_name)}</td>
<td>{row.file_name}</td>
<td>{titleCase(row.outcome)}</td>
<td>{titleCase(row.status)}</td>
<td>{formatDate(row.updated_at)}</td>
<td>
<Button
type="link"
onClick={() => {
setSelectedSubmission(row);
setSelectedSubmissionLog(row?.view_modal_content);
setViewModalOpen(true);
}}
>
View Logs
</Button>
</td>
</tr>
))}
{submissionData?.page.map(
(row: FileSubmissionRow, rowIndex: number) => (
<tr key={rowIndex}>
<td>{formatDate(row.received_timestamp)}</td>
<td>{titleCase(row.entity_name)}</td>
<td>{row.file_name}</td>
<td>{titleCase(row.outcome)}</td>
<td>{titleCase(row.status)}</td>
<td>{formatDate(row.updated_at)}</td>
<td>
<Button
type="link"
onClick={() => {
setSelectedSubmission(row);
setSelectedSubmissionLog(row?.view_modal_content);
setViewModalOpen(true);
}}
>
View Logs
</Button>
</td>
</tr>
)
)}
</tbody>
</table>
<div className={styles.paginatorContainer}>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
height: 100%; /* Adjust as needed */
padding-top: 20px;
}
.submissionTable td {
word-wrap: break-word;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import SectionMessage from 'core-components/SectionMessage';
import Paginator from 'core-components/Paginator';
import styles from './ViewSubmissions.module.css';
import { Link } from 'react-router-dom';
import { FileSubmissionLogsModal } from './ViewSubmissionsModal';
import { ViewSubmissionLogsModal } from './ViewSubmissionsModal';
import { formatDate } from 'utils/dateUtil';
import { titleCase } from 'utils/stringUtil';

export const ViewFileSubmissions: React.FC = () => {
const header = [
'Received',
'Entity Organization',
'File Name',
'Outcome',
'Status',
Expand Down Expand Up @@ -117,7 +118,7 @@ export const ViewFileSubmissions: React.FC = () => {
) : null}
</div>
</div>
<table id="submissionTable" className={styles.submissionTable}>
<table id="submissionTable" className="submission-table">
<thead>
<tr>
{header.map((columnName: string, index: number) => (
Expand All @@ -130,6 +131,7 @@ export const ViewFileSubmissions: React.FC = () => {
(row: FileSubmissionRow, rowIndex: number) => (
<tr key={rowIndex}>
<td>{formatDate(row.received_timestamp)}</td>
<td>{titleCase(row.entity_name)}</td>
<td>{titleCase(row.file_name)}</td>
<td>{titleCase(row.outcome)}</td>
<td>{titleCase(row.status)}</td>
Expand Down Expand Up @@ -159,7 +161,7 @@ export const ViewFileSubmissions: React.FC = () => {
/>
</div>
{selectedSubmission && viewModalOpen && (
<FileSubmissionLogsModal
<ViewSubmissionLogsModal
isOpen={viewModalOpen}
parentToggle={closeModal}
submission_logs={selectedSubmissionLog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ViewSubmissionLogsModalProps {
parentToggle: () => void;
}

export const FileSubmissionLogsModal: React.FC<
export const ViewSubmissionLogsModal: React.FC<
ViewSubmissionLogsModalProps
> = ({ submission_logs, isOpen, parentToggle }) => {
const closeBtn = (
Expand All @@ -33,17 +33,19 @@ export const FileSubmissionLogsModal: React.FC<
<div>
<dl>
{submission_logs.length > 0 ? (
submission_logs.map((log, index) => (
submission_logs.map((log: any, index: number) => (
<div className="modal-section" key={index}>
<dl className="c-data-list--is-vert c-data-list--is-wide">
<dt className="c-data-list__key">Log ID</dt>
<dd className="c-data-list__value">{log.log_id}</dd>
<dt className="c-data-list__key">Submission ID</dt>
<dt className="c-data-list__key">Entity Organization</dt>
<dd className="c-data-list__value">
{log.submission_id}
{titleCase(log.entity_name)}
</dd>
<dt className="c-data-list__key">File Type</dt>
<dd className="c-data-list__value">{log.file_type}</dd>
<dd className="c-data-list__value">
{titleCase(log.file_type)}
</dd>
<dt className="c-data-list__key">Validation Suite</dt>
<dd className="c-data-list__value">
{titleCase(log.validation_suite)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ViewFileSubmissions } from './ViewSubmissions';
import { ViewSubmissionLogsModal } from './ViewSubmissionsModal';

export { ViewFileSubmissions };
export { ViewFileSubmissions, ViewSubmissionLogsModal };
31 changes: 0 additions & 31 deletions apcd-cms/src/client/src/hooks/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,6 @@ export type UserResult = {
total_pages: number;
};

export type SubmissionRow = {
submission_id: string;
submitter_id: string;
entity_name: string;
file_name: string;
status: string;
outcome: string;
received_timestamp: string;
updated_at: string;
view_modal_content: SubmissionLogsModalContent[];
};

export type SubmissionResult = {
header: string[];
selected_status: string;
selected_sort: string;
query_str: string;
pagination_url_namespaces: string;
page: SubmissionRow[];
page_num: number;
total_pages: number;
};

export type SubmissionLogsModalContent = {
log_id: string;
entity_name: string;
file_type: string;
validation_suite: string;
outcome: string;
};

export type ExtensionRow = {
created: string;
org_name: string;
Expand Down
Loading

0 comments on commit 0dd8a1d

Please sign in to comment.