Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 265 use common data header #266

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 4 additions & 33 deletions src/components/trays/model-selection/catalogItems.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Fragment, useState } from "react";
import { AccordionGroup, Accordion, AccordionSummary, AccordionDetails, Stack, Checkbox, Typography } from '@mui/joy';
import PropTypes from 'prop-types';
import { getHeaderSummary } from "@utils/map-utils";
import { useLayers } from "@context/map-context";

// set component prop types
Expand All @@ -24,11 +25,6 @@ export default function CatalogItems(data) {
// create some state for what catalog accordian is expanded/not expanded
const [accordianDateIndex, setAccordianDateIndex] = useState(-1);

// variables for the display of checkbox labels
let stormOrModelEle = null;
let numberName = null;
let numberEle = null;

/**
* handles the model checkbox click
*
Expand Down Expand Up @@ -140,29 +136,16 @@ export default function CatalogItems(data) {
</div>
);
}
// if there were no catalog data returned
else if(data.data['catalog'] === undefined || data.data['catalog'] === null) {
return (
<div>
Error: { 'No catalog data retrieved.' }
</div>
);
}

// return all the data cards
else {
// save the name of the element for tropical storms and advisory numbers
if (data.isTropical) {
stormOrModelEle = 'storm_name';
numberName = ' Adv: ';
numberEle = 'advisory_number';
}
// save the name of the synoptic ADCIRC models and cycle numbers
else if (!data.isTropical) {
stormOrModelEle = 'model';
numberName = ' Cycle: ';
numberEle = 'cycle';
}

// render the results of the data query
return (
<Fragment>
Expand All @@ -189,7 +172,7 @@ export default function CatalogItems(data) {
// filter by the group name, get the top 1
.filter((val, idx, self) =>
( idx === self.findIndex((t)=> ( t['group'] === val['group']) )))
.sort((a, b) => a['properties'][numberEle] < b['properties'][numberEle] ? 1 : -1)
.sort((a, b) => a.properties['product_name'] < b.properties['product_name'] ? -1 : 1)
// output summarized details of each group member
.map((mbr, mbrIdx) => (
// create the checkbox
Expand All @@ -198,19 +181,7 @@ export default function CatalogItems(data) {
sx={{ m: .5 }}
key={ mbrIdx }
checked={ getCheckedState(mbr.group) }
label={
<Typography sx={{ fontSize: "xs" }}>
{
// create the label
((mbr['properties'][stormOrModelEle] === undefined) ? 'Data error' : mbr['properties'][stormOrModelEle].toUpperCase()) + ', ' +
numberName + mbr['properties'][numberEle] +
', Type: ' + mbr['properties']['event_type'] +
', Grid: ' + mbr['properties']['grid_type'] +
', Instance: ' + mbr['properties']['instance_name'] +
((mbr['properties']['meteorological_model'] === 'None') ? '' : ', ' + mbr['properties']['meteorological_model'])
}
</Typography>
}
label={ <Typography sx={{ fontSize: "xs" }}>{ getHeaderSummary(mbr['properties']) } </Typography> }
onChange={ (event) => handleCBClick( catalog['members'], mbr['group'],
event.target.checked) }
/>
Expand Down