From 2378bfd5b00ddf9856385576be0b414f98615d5d Mon Sep 17 00:00:00 2001 From: Duncan Ragsdale <88173870+Thistleman@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:13:26 -0700 Subject: [PATCH 1/2] added functional private report status bars, reoriented status and error bars and fixed buggy case logic Signed-off-by: Duncan Ragsdale <88173870+Thistleman@users.noreply.github.com> --- .../mysubmissions/private_report/page.tsx | 177 ++++++++++++++++-- 1 file changed, 159 insertions(+), 18 deletions(-) diff --git a/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx b/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx index 4092d35..17340fc 100644 --- a/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx +++ b/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx @@ -27,9 +27,15 @@ type ErrorData = { error_message?: string; } -// eslint-disable-next-line type SubmissionData = { - submitted_at: string; + submittedAt: string; + altName: string; + dataRequirements: string[]; + mrt: number; + pythonVersion: string; + results: any; + workerVersion: number; + status: string; } const PrivateReportPage: React.FC = () => { @@ -37,18 +43,51 @@ const PrivateReportPage: React.FC = () => { const selectedSubmission = searchParams.get('sid') || 'development'; const [marimoUrl, setMarimoUrl] = useState(''); const [errorData, setErrorData] = useState({ - error_rate: '0%', + error_rate: '0', error_code: '', error_type: '', error_message: '', }); const [displayErrorDetails, setDisplayErrorDetails] = useState(false); + const [submissionData, setSubmissionData] = useState({ + submittedAt: '', + altName: '', + dataRequirements: [], + mrt: 0, + pythonVersion: '', + results: {}, + workerVersion: 0, + status: '', + }); + + const getIcon = (status: string) => { + switch (status) { + case 'submitted': + return ( + Status: Queued + ); + case 'running': + return ( + Status: In Progress + ); + case 'failed': + return ( + Status: Failed + ); + case 'finished': + return ( + Status: Success + ); + default: + return null; + } + }; useEffect(() => { const fetchSubmissionErrors = async () => { if (selectedSubmission === 'development') { setErrorData({ - error_rate: '0%', + error_rate: '0', error_code: 'OP Development', error_type: 'Example Error Type', error_message: 'This is a message. I like messages.', @@ -82,6 +121,29 @@ const PrivateReportPage: React.FC = () => { } }; + /* + result.submission_details + { + alt_name: "abcd" + +archived: false + +created_by: Object { uuid: 9, username: "MikeSloth" } + +data_requirements: Array(4) [ "time_series", "latitude", "longitude", … ] + +mrt: 16.30142615099976 + +python_version: "3.11" + +result: Object { mean_run_time: 16.30142615099976, mean_mean_absolute_error: 46.332131163990425, median_mean_absolute_error: 0.20766129032258066 } + +submission_id: 41 + +submitted_at: "2024-08-07T18:22:32.251191Z" + +worker_version: 1} + */ const fetchSubmissionResults = async () => { const num = parseInt(selectedSubmission); if (typeof(num) !== 'number') { @@ -95,6 +157,16 @@ const PrivateReportPage: React.FC = () => { console.error('Invalid submission ID'); } else { setMarimoUrl(result.marimo_url[0]); + setSubmissionData({ + submittedAt: result.submission_details.submitted_at, + altName: result.submission_details.alt_name, + dataRequirements: result.submission_details.data_requirements, + mrt: result.submission_details.mrt, + pythonVersion: result.submission_details.python_version, + results: result.submission_details.result, + workerVersion: result.submission_details.worker_version, + status: result.submission_details.status, + }); } }) .catch((error) => { @@ -107,13 +179,94 @@ const PrivateReportPage: React.FC = () => { fetchSubmissionErrors(); }, [selectedSubmission]); + const formatDate = (dateString: string) => { + const date = new Date(dateString); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + const year = date.getFullYear(); + return `${month}/${day}/${year}`; + }; + return (
-
+
+ + {submissionData && ( + +
+ {submissionData.status === 'finished' ? + `Success Rate: ${100 - parseInt( + errorData.error_rate || '0')}%` : + getIcon(submissionData.status)} +
+
+ Date: {formatDate(submissionData.submittedAt)} +
+
+ MRT: {submissionData.mrt} +
+
+ Results: {submissionData.results && + Object.keys(submissionData.results).length > 0 ? + Object.entries(submissionData.results) + .map(([key, value]) => `${key}: ${value}`) + .join(', ') : + 'No results available'} +
+
+ Data Requirements:{' '} + {submissionData.dataRequirements.join(', ')} +
+
+ )} +
- - Error Rate: - {' '} - {errorData.error_rate} - {displayErrorDetails && ( <> @@ -146,17 +294,10 @@ const PrivateReportPage: React.FC = () => { )} - -
{ - (errorData.error_code && errorData.error_code.length > 0) ? + (submissionData.status !== 'finished') ?
: }> From adbd5225148b0514ebde8d9190571136a99beac3 Mon Sep 17 00:00:00 2001 From: Duncan Ragsdale <88173870+Thistleman@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:45:25 -0700 Subject: [PATCH 2/2] finished report page Signed-off-by: Duncan Ragsdale <88173870+Thistleman@users.noreply.github.com> --- .../mysubmissions/private_report/page.tsx | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx b/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx index 17340fc..82367b9 100644 --- a/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx +++ b/src/app/(mysubmissions)/mysubmissions/private_report/page.tsx @@ -15,6 +15,9 @@ import Footer from '@/app/modules/footer/footer'; import SubmissionService from '@/services/submission_service'; // eslint-disable-next-line max-len import MarimoProcessor from '@/app/modules/mysubmissions/marimo/marimoprocessor'; +import {EditableInput} from '@/app/modules/global/editableComponents'; +import UserService from '@/services/user_service'; +import CookieService from '@/services/cookie_service'; // *********** REDUX IMPORTS *********** @@ -28,6 +31,7 @@ type ErrorData = { } type SubmissionData = { + submissionId: number; submittedAt: string; altName: string; dataRequirements: string[]; @@ -50,6 +54,7 @@ const PrivateReportPage: React.FC = () => { }); const [displayErrorDetails, setDisplayErrorDetails] = useState(false); const [submissionData, setSubmissionData] = useState({ + submissionId: 0, submittedAt: '', altName: '', dataRequirements: [], @@ -59,6 +64,51 @@ const PrivateReportPage: React.FC = () => { workerVersion: 0, status: '', }); + const [isEditing, setIsEditing] = useState<{ [key: string]: boolean }>({}); + + const handleNameChange = (newValue: string) => { + setSubmissionData((prevSubmissionData) => ({ + ...prevSubmissionData, + altName: newValue, + })); + }; + + const handleSetName = async (newValue: string) => { + const user = CookieService.getUserCookie(); + const userId = await UserService.getUserId(user.token); + await SubmissionService.updateName( + user.token, + userId, + submissionData.submissionId, + newValue); + }; + + const onChange = (newValue: string) => { + setIsEditing((prev) => ({...prev, [submissionData.submissionId]: true})); + handleNameChange(newValue); + }; + + const onClick = () => { + setIsEditing((prev) => ({...prev, [submissionData.submissionId]: false})); + handleSetName(submissionData.altName); + }; + + const getDisplayName = () => { + const {altName, submissionId, submittedAt} = submissionData; + + if (altName !== null && + altName !== undefined && + altName !== 'N/A' && + (altName.length > 0 || isEditing[submissionId])) { + return altName; + } else if (submissionId !== null && + submissionId !== undefined && + submittedAt !== null && submittedAt !== undefined) { + return `Submission_${submissionId}_${submittedAt}`; + } else { + return 'N/A'; + } + }; const getIcon = (status: string) => { switch (status) { @@ -158,6 +208,7 @@ worker_version: 1} } else { setMarimoUrl(result.marimo_url[0]); setSubmissionData({ + submissionId: result.submission_details.submission_id, submittedAt: result.submission_details.submitted_at, altName: result.submission_details.alt_name, dataRequirements: result.submission_details.data_requirements, @@ -202,6 +253,43 @@ worker_version: 1} flex-col "> + +
+ onChange(e.target.value)} + onClick={onClick} + /> +
+
+ +
+