Skip to content

Commit

Permalink
bugfix mysubmission rename, bugfix leaderboard display, implement res…
Browse files Browse the repository at this point in the history
…ource page

Signed-off-by: Duncan Ragsdale <[email protected]>
  • Loading branch information
Thistleman committed Jul 30, 2024
1 parent 48375cb commit dda80fe
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 58 deletions.
Binary file added public/static/assets/resources/1/cardCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/static/assets/resources/1/shortdesc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Links to a docs page. We would like a docs page.


Binary file added public/static/assets/resources/2/cardCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/static/assets/resources/2/shortdesc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Come and check out our github! You can file issues, offer contributions, and more!


Binary file added public/static/assets/resources/3/cardCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/static/assets/resources/3/shortdesc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Learn more about the research behind the PV-Insight project.


Binary file added public/static/assets/resources/4/cardCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/static/assets/resources/4/shortdesc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Have any questions about your submissions or administrative issues with the validation hub, you can reach out to our team here.


5 changes: 0 additions & 5 deletions src/app/(analyses)/analyses/analysis/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const AnalysisPage: React.FC = () => {
)) {
console.log('Development analysis');
} else {
console.log('NO!', selectedAnalysis);
navigate.push('/analyses');
}

Expand Down Expand Up @@ -127,7 +126,6 @@ const AnalysisPage: React.FC = () => {
AnalysisService.getCardDetails(selectedAnalysis)
.then((response: any) => {
setIsLoading(false);
console.log('resp:', response.data);
setAnalysisDetailsCard(response.data);
setAnalysisId(response.data.analysis_id);
})
Expand All @@ -144,15 +142,13 @@ const AnalysisPage: React.FC = () => {
}, [selectedAnalysis, error, navigate]);

useEffect(() => {
console.log('analysis', selectedAnalysis, typeof selectedAnalysis);
if (selectedAnalysis !== undefined && selectedAnalysis !== null &&
((typeof(selectedAnalysis) === 'number' && selectedAnalysis > 0) ||
(
typeof(selectedAnalysis) === 'string' &&
selectedAnalysis === 'development'
))) {
setCoverImageDir(`/static/assets/${selectedAnalysis}/banner.png`);
console.log('cid', coverImageDir);

MS.fetchMarkdown(`/static/assets/${selectedAnalysis}/description.md`)
.then((text) => replaceImagePaths(text, selectedAnalysis))
Expand All @@ -179,7 +175,6 @@ const AnalysisPage: React.FC = () => {


const handleChange = (event: any, newValue: number) => {
console.log('new value:', newValue);
setValue(newValue);
};

Expand Down
8 changes: 6 additions & 2 deletions src/app/(mysubmissions)/mysubmissions/private_report/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const PrivateReportPage: React.FC = () => {
try {
const errors = await
SubmissionService.getSubmissionErrors(parseInt(selectedSubmission));
console.log('Error data:', errors);
if (errors === 'Invalid submission ID') {
console.error('Invalid submission ID');
} else if (errors.length === 0) {
Expand Down Expand Up @@ -91,6 +90,7 @@ const PrivateReportPage: React.FC = () => {
SubmissionService.getSubmissionResults(num)
.then((response) => response.data)
.then((result) => {
console.log('result:', result);
if (result === 'Invalid submission ID') {
console.error('Invalid submission ID');
} else {
Expand Down Expand Up @@ -155,9 +155,13 @@ const PrivateReportPage: React.FC = () => {
</AppBar>
</Box>

<Suspense fallback={<CircularProgress />}>
{
(errorData.error_code && errorData.error_code.length > 0) ?
<div>
</div> : <Suspense fallback={<CircularProgress />}>
<MarimoProcessor htmlFile={marimoUrl} />
</Suspense>
}

</div>
</main>
Expand Down
56 changes: 51 additions & 5 deletions src/app/(resources)/resources/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,71 @@
// *********** START OF IMPORTS ***********

import React from 'react';
import {Grid} from '@mui/material';

// *********** MODULE IMPORTS ***********

import Header from '@/app/modules/header/header';
import Footer from '@/app/modules/footer/footer';
import Elink from '@/app/modules/elink/elink';
import ResourceCard from '@/app/modules/resources/resourcecard';

// *********** REDUX IMPORTS ***********

// *********** END OF IMPORTS ***********

const ResourcesPage: React.FC = () => {
// Array of resource objects
const resources = [
{
cardName: 'Developer Tools',
cardId: 1,
testId: 'resource-1',
url: 'https://example.com/resource1',
},
{
cardName: 'Github',
cardId: 2,
testId: 'resource-2',
url: 'https://github.com/slacgismo/pv-validation-hub',
},
{
cardName: 'PVInsight',
cardId: 3,
testId: 'resource-2',
url: 'https://gismo.slac.stanford.edu/research/pvinsight-phase-2',
},
{
cardName: 'Contact Us',
cardId: 4,
testId: 'resource-2',
url: 'https://example.com/resource2',
},
];

return (
<div className="flex flex-col min-h-screen">
<Header />
<main className="flex min-h-screen flex-col
items-center justify-between p-24">
<h1>Welcome to the resources page!</h1>
<Elink url='https://slac.stanford.edu' />
<main className="
flex
min-h-screen
flex-col
items-center
justify-between
p-24">
<h1>Resources</h1>
<p> Something inspirational here.</p>
<Grid container spacing={2}>
{resources.map((resource) => (
<ResourceCard
key={resource.cardId}
cardName={resource.cardName}
cardId={resource.cardId}
testId={resource.testId}
url={resource.url}
linkText={resource.linkText}
/>
))}
</Grid>
</main>
<Footer />
</div>
Expand Down
30 changes: 13 additions & 17 deletions src/app/modules/analyses/leaderboard/leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default function Leaderboard() {
)) {
console.log('Development analysis');
} else {
console.log('NO!', analysisId);
navigate.push('/analyses');
}
const [leaderboardDetails, setLeaderboardDetails] = useState<{
Expand All @@ -69,7 +68,7 @@ export default function Leaderboard() {
created_by: string;
execution_time: number;
status: string;
metrics: Array<string>;
dataRequirements: Array<string>;
error: number;
}[]>([]);
const [isLeaderboardLoading, setLeaderboardIsLoading] = useState(true);
Expand Down Expand Up @@ -162,8 +161,8 @@ export default function Leaderboard() {
},
},
{
field: 'metrics',
headerName: 'Metrics',
field: 'dataRequirements',
headerName: 'Data Requirements',
headerAlign: 'center',
align: 'center',
filterable: false,
Expand All @@ -173,28 +172,29 @@ export default function Leaderboard() {
flex: 1.5,
renderCell: (params) => {
// params.value needs to be an array of strings.
let metrics;
let dataRequirements;
let id;
if (Array.isArray(params.value)) {
try {
// Attempt to parse the JSON string
metrics = params.value;
dataRequirements = params.value;
id = params.id;
} catch (error) {
console.error('Failed to retrieve a metrics array:', error);
metrics = [];
console.error('Failed to retrieve a dataRequirements array:',
error);
dataRequirements = [];
id = 0;
}
} else {
console.error('Failed to retrieve a metrics array.',
console.error('Failed to retrieve a dataRequirements array.',
' Instead received: ', params.value
);
metrics = [];
dataRequirements = [];
id = 0;
}
return (
<Box>
{metrics.map((name: string, index: number) => {
{dataRequirements.map((name: string, index: number) => {
const key=`${index}-${name}-${id}`;
const hex=ColorPalette[index];
return (
Expand Down Expand Up @@ -252,15 +252,13 @@ export default function Leaderboard() {
);
if (typeof analysisId === 'number') {
const url = `/analysis/${analysisId}/leaderboard`;
console.log('Leaderboard URL:', url);
DashboardService.getLeaderBoard(url)
.then((leaderboardResponse) => {
setLeaderboardIsLoading(false);
const resp = leaderboardResponse.data;
return DashboardService.formatResponse(resp.submissions);
})
.then((formattedResponse) => {
console.log('Formatted response:', formattedResponse);
if (formattedResponse.length > 0) {
setLeaderboardDetails(formattedResponse);
} else {
Expand All @@ -270,7 +268,7 @@ export default function Leaderboard() {
created_by: 'N/A',
execution_time: 0,
status: 'N/A',
metrics: ['N/A'],
dataRequirements: ['N/A'],
error: 0,
}]);
}
Expand All @@ -283,7 +281,6 @@ export default function Leaderboard() {
});
DashboardService.getAnalysisDetails(analysisId)
.then((response) => {
console.log('Analysis details:', response.data.display_errors);
setAnalysisErrorTypes(response.data.display_errors);
})
.catch((error) => {
Expand All @@ -297,7 +294,7 @@ export default function Leaderboard() {
created_by: 'Development',
execution_time: 0,
status: 'Development',
metrics: ['Development'],
dataRequirements: ['Development'],
error: 0,
}]);
resetDefaultColumns(columnArray);
Expand All @@ -313,7 +310,6 @@ export default function Leaderboard() {
}, [analysisId]);

useEffect(() => {
console.log('Leaderboard details:', leaderboardDetails);
}, [leaderboardDetails]);

useEffect(() => {
Expand Down
4 changes: 0 additions & 4 deletions src/app/modules/analyses/upload/uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default function SubmissionUploader(
useEffect(() => {
AnalysisService.getPythonVersions()
.then((response) => {
console.log('versions:', response);
if (response.status === 200) {
setPythonVersions(response.data);
}
Expand All @@ -63,7 +62,6 @@ export default function SubmissionUploader(
}, []);

const handleNameChange = (e: any) => {
console.log('event: ', e);
let val = e.target.value;
if (typeof(val) !== 'string' || val === undefined || val === null) {
console.error('Name submission must be a string.');
Expand All @@ -73,7 +71,6 @@ export default function SubmissionUploader(
};

const handleSelectChange = (e: any) => {
console.log('event: ', e);
let val = e.target.value;
if (typeof(val) !== 'string' || val === undefined || val === null) {
console.error('Name submission must be a string.');
Expand Down Expand Up @@ -106,7 +103,6 @@ export default function SubmissionUploader(

responsePromise
.then((response) => {
console.log('response:', response);
clearName();
if (response.status === 200) {
setUploadSuccess({
Expand Down
12 changes: 8 additions & 4 deletions src/app/modules/elink/elink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import Link from 'next/link';

/**
*
* @param {string} url a url to insert into the link
* @param {string} props.url a url to insert into the link
* @param {string} props.linkText optional text to display in the link
* @return {JSX.Element} prefilled Link Component
*/
export default function Elink(url: {url: string}) {
export default function Elink(
{url, linkText}: {url: string, linkText?: string}) {
console.log(url, linkText);
const text = linkText || url;
return (
<Link
href={`/external?exturl=${url.url}`}
href={`/external?exturl=${url}`}
className='
standardLink
whitespace-nowrap
'>
{url.url}
{text}
</Link>
);
}
1 change: 0 additions & 1 deletion src/app/modules/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ const NavMenu: React.FC<NavMenuProps> = ({pages, isLoggedIn}) => {
<Box sx={{flexGrow: 1, display: {xs: 'none', md: 'flex'}}}>
{pages.map((page, index) => {
if (page.requireLogin && !isLoggedIn) {
console.log('disabled link');
return (
<Link className={`
${styles.menuDisabled}
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/homepage/demoTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function DemoBoard() {
},
{
field: 'metrics',
headerName: 'Metrics',
headerName: 'Data Requirements',
headerAlign: 'center',
align: 'center',
filterable: false,
Expand Down
1 change: 0 additions & 1 deletion src/app/modules/mysubmissions/marimo/marimoprocessor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import React from 'react';


const MarimoProcessor = ({htmlFile}: {htmlFile: string}) => {
console.log('htmlFile: ', htmlFile);
return (
<div className="iframeContainer">
<iframe
Expand Down
Loading

0 comments on commit dda80fe

Please sign in to comment.