diff --git a/apps/frontend/package-lock.json b/apps/frontend/package-lock.json index 8c79a12..ed01d54 100644 --- a/apps/frontend/package-lock.json +++ b/apps/frontend/package-lock.json @@ -15,7 +15,7 @@ "@fontsource/public-sans": "^5.0.18", "@mui/icons-material": "^5.15.11", "@mui/material": "^5.15.11", - "@nasapds/wds-react": "^0.0.3", + "@nasapds/wds-react": "^0.0.4", "@reduxjs/toolkit": "^2.2.1", "axios": "^1.6.7", "classnames": "^2.5.1", @@ -893,21 +893,21 @@ "integrity": "sha512-J4yDIIthosAsRZ5CPYP/jQvUAQtlZTTD/4suA08/FEnlxqW3sKS9iAhgsa9VYLZ6vDHn/ixJgIqRQPotoBjxIw==" }, "node_modules/@fontsource-variable/inter": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.1.0.tgz", - "integrity": "sha512-Wj2dUGP0vUpxRGQTXQTCNJO+aLcFcQm+gUPXfj/aS877bQkEPBPv9JvZJpwdm2vzelt8NTZ+ausKlBCJjh2XIg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.1.1.tgz", + "integrity": "sha512-OpXFTmiH6tHkYijMvQTycFKBLK4X+SRV6tet1m4YOUH7SzIIlMqDja+ocDtiCA72UthBH/vF+3ZtlMr2rN/wIw==", "license": "OFL-1.1" }, "node_modules/@fontsource-variable/public-sans": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@fontsource-variable/public-sans/-/public-sans-5.1.1.tgz", - "integrity": "sha512-tqIED9ZiEyX8AQp/4AoVVWy7O05IxVqEWdk8Epw3Cp1np/mmwMGp1JWyzLeJq8ZE4HqdF9e5FSuB3rnyDLpTiA==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@fontsource-variable/public-sans/-/public-sans-5.1.2.tgz", + "integrity": "sha512-D4BaUhRY52xoVJw24gOVJymDBHoezdv3X2Rot9iYsHieEuvu8mwBNTSqBJvS6wlMZo2i834azXKllxRYE0C6fg==", "license": "OFL-1.1" }, "node_modules/@fontsource/dm-mono": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@fontsource/dm-mono/-/dm-mono-5.1.0.tgz", - "integrity": "sha512-cfowZUJJDHjgVFOEQmIn2KHtQ8LDXnTGgTTunUImzzg3Xf6V92MlYR/pmkqIt7lXq7lfP/pQZ9ph/9JeLDRsCQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@fontsource/dm-mono/-/dm-mono-5.1.1.tgz", + "integrity": "sha512-blj8dgPQ63UqOdt0beSL1oV5r0/AASsQTGBOI5lTryb6XBzWUsOiIZCfHENtbCuGXjCblxVc+1/zkb13lwYF+g==", "license": "OFL-1.1" }, "node_modules/@fontsource/inter": { @@ -1221,23 +1221,23 @@ } }, "node_modules/@nasapds/wds": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@nasapds/wds/-/wds-0.0.2.tgz", - "integrity": "sha512-qBojc0gSbARfQh3+CJLcwnR1zzLW5muzZaWHbObpno04vP8NtrjZ5cbgPRu2dhZ8ymiYTHNVtkbO3HX4v3djJg==", + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@nasapds/wds/-/wds-0.0.3.tgz", + "integrity": "sha512-hjWtK6tgo+NrmNfslmoW52/xpb+gjzVZD0KEsrVkRKm/JW84BaK19Rqrf8oyzoe9EC9Xzab///Fuuwtv4xI7Mw==", "license": "Apache-2.0", "dependencies": { - "@fontsource-variable/inter": "^5.1.0", - "@fontsource-variable/public-sans": "^5.1.1", - "@fontsource/dm-mono": "^5.1.0" + "@fontsource-variable/inter": "^5.1.1", + "@fontsource-variable/public-sans": "^5.1.2", + "@fontsource/dm-mono": "^5.1.1" } }, "node_modules/@nasapds/wds-react": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@nasapds/wds-react/-/wds-react-0.0.3.tgz", - "integrity": "sha512-sEZxtgYJdKmJVrkH6hSl4x8PhcmYHbEHHHX60CJhLEr8ccNTVVtYbsNWhPu7mnmqzNXK3NQ8TWKjh2kg2s7l+g==", + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@nasapds/wds-react/-/wds-react-0.0.4.tgz", + "integrity": "sha512-fQkCzijivgrdvxTG82Ntgrp/u873MIa9uHhiySd2oW5Y/U7HD+lItMw+zFMrBVGHQY3CN7LSUWOh0HEm/Jdj/A==", "license": "Apache-2.0", "dependencies": { - "@nasapds/wds": "^0.0.2" + "@nasapds/wds": "^0.0.3" }, "peerDependencies": { "@emotion/react": "^11.11.1", diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 6286615..88d0bf2 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -1,7 +1,7 @@ { "name": "pds-portal-frontend", "private": true, - "version": "0.0.2", + "version": "0.0.4", "type": "module", "scripts": { "dev": "vite", @@ -18,7 +18,7 @@ "@fontsource/public-sans": "^5.0.18", "@mui/icons-material": "^5.15.11", "@mui/material": "^5.15.11", - "@nasapds/wds-react": "^0.0.3", + "@nasapds/wds-react": "^0.0.4", "@reduxjs/toolkit": "^2.2.1", "axios": "^1.6.7", "classnames": "^2.5.1", diff --git a/apps/frontend/src/components/Filters/Filter.tsx b/apps/frontend/src/components/Filters/Filter.tsx index 4939daf..c55a002 100644 --- a/apps/frontend/src/components/Filters/Filter.tsx +++ b/apps/frontend/src/components/Filters/Filter.tsx @@ -30,7 +30,7 @@ export type FilterProps = { title: string; options: FilterOptionProps[]; onChecked: (event: ChangeEvent) => void; - onCheckedRadio: (event: ChangeEvent) => void; + onCheckedRadio: (name: string, checked: boolean, value: string) => void; collapseAll?: boolean; variant: FilterVariant; }; @@ -72,102 +72,154 @@ const Filter = ({ return isIncluded; }; + const isASingleSelected = ( + possibleOptions: FilterOptionProps[], + filterVariant: FilterVariant + ) => { + let isSingleAndSelected = false; + if (filterVariant === "single") { + possibleOptions.forEach((option) => { + if (option.value !== "all" && option.isChecked === true) { + isSingleAndSelected = true; + } + }); + } + + return isSingleAndSelected; + }; + useEffect(() => { setIsCollapsed(collapseAll); }, [collapseAll]); return ( -
- - - - - {displayTitle.toUpperCase()} - - - - - {isCollapsed ? : } - - - - - - {!isCollapsed ? ( - - - - - - ), - }} - /> - - - ) : ( - <> - )} - - {!isCollapsed ? ( - - {options.map((option) => - titleIncludesSubFilter(option.title, subFilter) ? ( - + {!isASingleSelected(options, variant) ? ( +
+ + + + + {displayTitle.toUpperCase()} + + + - + {isCollapsed ? ( + + ) : ( + + )} + + + + + {!isCollapsed ? ( + + + + + + ), + }} /> - - {option.title.toUpperCase()} - - - {option.title === "all" - ? "" - : " (" + option.resultsFound + ")"} - - - - ) : ( - <> - ) + + + ) : ( + <> )} - + {!isCollapsed ? ( + + {options.map((option) => + titleIncludesSubFilter(option.title, subFilter) ? ( + + {variant !== "single" ? ( + <> + + + {option.title.toUpperCase()} + + + {option.title === "all" + ? "" + : " (" + option.resultsFound + ")"} + + + + ) : ( +
+ + onCheckedRadio( + option.value, + !option.isChecked, + value + ) + } + > + {option.title.toUpperCase()} + + + {option.title === "all" + ? "" + : " (" + option.resultsFound + ")"} + + +
+ )} +
+ ) : ( + <> + ) + )} +
+ ) : ( + "" + )} + +
) : ( - "" + <> )} - -
+ ); }; diff --git a/apps/frontend/src/components/Filters/Filters.tsx b/apps/frontend/src/components/Filters/Filters.tsx index 89c3731..a72b728 100644 --- a/apps/frontend/src/components/Filters/Filters.tsx +++ b/apps/frontend/src/components/Filters/Filters.tsx @@ -7,7 +7,7 @@ import { Chip, Typography } from "@nasapds/wds-react"; export type FiltersProps = { filters: FilterProps[]; onChecked: (event: ChangeEvent) => void; - onCheckedRadio: (event: ChangeEvent) => void; + onCheckedRadio: (name: string, checked: boolean, value: string) => void; onFilterChipDelete: (value: string, parentValue: string) => void; onFilterClear: () => void; collapseAll?: boolean; @@ -41,7 +41,7 @@ const Filters = ({ filter.options.forEach((option) => { if (option.value !== "all" && option.isChecked) { const optionProps = { - title: option.title, + title: filter.displayTitle + " : " + option.title, value: option.value, resultsFound: option.resultsFound, isChecked: option.isChecked, diff --git a/apps/frontend/src/components/Footer/Footer.tsx b/apps/frontend/src/components/Footer/Footer.tsx index b9149b4..e0a254b 100644 --- a/apps/frontend/src/components/Footer/Footer.tsx +++ b/apps/frontend/src/components/Footer/Footer.tsx @@ -2,7 +2,7 @@ import { FooterLink, Footer } from "@nasapds/wds-react"; function PortalFooter() { - const pageLastUpdated="Nov. 14, 2024" + const pageLastUpdated="Jan. 23, 2025" const primaryLinks:FooterLink[] = [ { diff --git a/apps/frontend/src/components/HomeSearch/HomeSearch.tsx b/apps/frontend/src/components/HomeSearch/HomeSearch.tsx index 0b2dc1c..7e87b8d 100644 --- a/apps/frontend/src/components/HomeSearch/HomeSearch.tsx +++ b/apps/frontend/src/components/HomeSearch/HomeSearch.tsx @@ -27,6 +27,7 @@ import { import { mapFilterIdsToName, mapPageType, + formatIdentifierNameResults, } from "../../pages/search/searchUtils"; import MenuItem from "@mui/material/MenuItem"; import FormControl from "@mui/material/FormControl"; @@ -588,11 +589,13 @@ export const HomeSearch = () => { } const investigationNames: IdentifierNameDoc[] = - investigationsData.response.docs; + formatIdentifierNameResults(investigationsData).response + .docs; const instrumentNames: IdentifierNameDoc[] = - instrumentsData.response.docs; + formatIdentifierNameResults(instrumentsData).response + .docs; const targetNames: IdentifierNameDoc[] = - targetsData.response.docs; + formatIdentifierNameResults(targetsData).response.docs; const investigationFilterOptions = mapFilterIdsToName( investigationFilterIds, diff --git a/apps/frontend/src/components/IndexedListComponent/InstrumentsIndexedListComponent.tsx b/apps/frontend/src/components/IndexedListComponent/InstrumentsIndexedListComponent.tsx index a3de5ee..0260668 100644 --- a/apps/frontend/src/components/IndexedListComponent/InstrumentsIndexedListComponent.tsx +++ b/apps/frontend/src/components/IndexedListComponent/InstrumentsIndexedListComponent.tsx @@ -10,6 +10,7 @@ import { InstrumentHost } from "src/types/instrumentHost"; import { ExpandMore } from "@mui/icons-material"; import { FeaturedLink, FeaturedLinkDetails, FeaturedLinkDetailsVariant, Typography } from "@nasapds/wds-react"; import { getLinkToInstrumentDetailPage } from "src/utils/links"; +import { getInstrumentDescription } from "src/utils/strings"; type InstrumentsIndexedListComponentProps = { instruments: Instrument[]; @@ -213,7 +214,7 @@ function InstrumentsIndexedListComponent(props:InstrumentsIndexedListComponentPr (instrument: Instrument, instrumentIndex) => { return ( { return ( { return ( { return ( { ); }; - const handleFilterCheckedRadio = (e: ChangeEvent) => { - const { name, checked, value } = e.target; + const handleFilterCheckedRadio = ( + name: string, + checked: boolean, + value: string + ) => { let filters = ""; if (name === "all") { @@ -1246,7 +1257,7 @@ const SearchPage = () => { {getDocType(doc) === "databundle" ? ( { columns={[ { horizontalAlign: "center", - data: "Data Bundle", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1332,7 +1343,7 @@ const SearchPage = () => { {getDocType(doc) === "datacollection" ? ( { columns={[ { horizontalAlign: "center", - data: "Data Collection", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1420,7 +1431,7 @@ const SearchPage = () => { {getDocType(doc) === "dataset" ? ( { columns={[ { horizontalAlign: "center", - data: "Data Set", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1492,11 +1503,14 @@ const SearchPage = () => { {getDocType(doc) === "facility" ? ( { columns={[ { horizontalAlign: "center", - data: "Facility", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1542,13 +1556,22 @@ const SearchPage = () => { {getDocType(doc) === "instrument" ? ( { columns={[ { horizontalAlign: "center", - data: "Instrument", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1576,10 +1599,9 @@ const SearchPage = () => { : "/", }} investigation={ - doc["form-instrument-host"] + doc.instrument_host_name ? { - value: - doc["form-instrument-host"][0], + value: doc.instrument_host_name[0], } : { value: "-" } } @@ -1591,13 +1613,22 @@ const SearchPage = () => { {getDocType(doc) === "instrument_host" ? ( { columns={[ { horizontalAlign: "center", - data: "Instrument Host", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1659,15 +1690,24 @@ const SearchPage = () => { {getDocType(doc) === "investigation" ? ( { columns={[ { horizontalAlign: "center", - data: "Investigation", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1730,7 +1770,7 @@ const SearchPage = () => { {getDocType(doc) === "resource" ? ( { columns={[ { horizontalAlign: "center", - data: "Resource", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1767,9 +1807,14 @@ const SearchPage = () => { {getDocType(doc) === "target" ? ( { columns={[ { horizontalAlign: "center", - data: "Target", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1805,11 +1850,17 @@ const SearchPage = () => { {getDocType(doc) === "telescope" ? ( { columns={[ { horizontalAlign: "center", - data: "Telescope", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1850,7 +1901,7 @@ const SearchPage = () => { {getDocType(doc) === "tool" ? ( { columns={[ { horizontalAlign: "center", - data: "Tool", + data: doc.page_type[0], verticalAlign: "center", width: 1, }, @@ -1870,7 +1921,7 @@ const SearchPage = () => { { const rows = Number(data.responseHeader.params.rows); const hits = data.response.numFound; @@ -82,14 +93,6 @@ export const formatFilterQueries = (filters: string) => { return formattedFilterQueryString; }; -export const formatIdentifierNameResults = (data: SolrIdentifierNameResponse) => { - return data; -}; - -export const formatSearchResults = (data: SolrSearchResponse) => { - return data; -}; - export const getDocType = (doc: SearchResultDoc) => { let docType = ""; if (doc.product_class) { @@ -227,7 +230,7 @@ const getUnmatchedFilterName = ( } for(let i = 0; i < originals.length; i++){ - if(originals[i].identifier === identifier){ + if(originals[i].identifier[0] === identifier){ if(parentName === "target_ref"){ return originals[i].target_name[0]; } @@ -306,7 +309,7 @@ export const mapFilterIdsToName = (ids: string[], names: IdentifierNameDoc[], se let name: string = ""; if (nameDoc.title) { - name = nameDoc.title; + name = nameDoc.title[0]; } filtersMap.push({ @@ -352,4 +355,192 @@ export const mapPageType = (ids: string[], searchResultFacets?: (number | string }); return filtersMap; -}; \ No newline at end of file +}; + +export const formatSearchResults = (data: SolrSearchResponseExpected) => { + const formattedData: SolrSearchResponse = transformSolrSearchResponseExpected(data); + + return formattedData; +}; + + +const transformSolrSearchResponseExpected = (data: SolrSearchResponseExpected) => { + const formattedData: SolrSearchResponse = { + response: transformResponse(data.response), + responseHeader: data.responseHeader, + facet_counts: data.facet_counts + } + + return formattedData; +}; + + +const transformResponse = (data: ResponseExpected) => { + const formattedData: Response = { + numFound: data.numFound, + start: data.start, + maxScore: data.maxScore, + docs: transformDocs(data.docs) + } + + return formattedData; +} + +const transformDocs = (data: SearchResultDocExpected[]) => { + const formattedData: SearchResultDoc[] = []; + + data.forEach((docExpected) => { + const doc: SearchResultDoc = { + page_type: convertToStringArray(docExpected.page_type), + file_ref_location: convertToStringArray(docExpected.file_ref_location), + data_class:convertToStringArray(docExpected.data_class), + description: convertToStringArray(docExpected.description), + file_ref_url: convertToStringArray(docExpected.file_ref_url), + title: convertToStringArray(docExpected.title), + resLocation: convertToStringArray(docExpected.resLocation), + objectType: convertToStringArray(docExpected.objectType), + product_class: convertToStringArray(docExpected.product_class), + data_product_type: convertToStringArray(docExpected.data_product_type), + file_ref_size: convertToStringArray(docExpected.file_ref_size), + modification_date: convertToStringArray(docExpected.modification_date), + file_ref_name: convertToStringArray(docExpected.file_ref_name), + identifier: convertToStringArray(docExpected.identifier), + resource_url: convertToStringArray(docExpected.resource_url), + agency_name: convertToStringArray(docExpected.agency_name), + 'form-agency': convertToStringArray(docExpected['form-agency']), + modification_description: convertToStringArray(docExpected.modification_description), + resource_type: convertToStringArray(docExpected.resource_type), + search_id: convertToStringArray(docExpected.search_id), + pds_model_version: convertToStringArray(docExpected.pds_model_version), + resource_description: convertToStringArray(docExpected.resource_description), + resource_name: convertToStringArray(docExpected.resource_name), + timestamp: convertToStringArray(docExpected.timestamp), + score: docExpected.score, + investigation_type: convertToStringArray(docExpected.investigation_type), + primary_result_purpose: convertToStringArray(docExpected.primary_result_purpose), + node_id: convertToStringArray(docExpected.node_id), + instrument_type: convertToStringArray(docExpected.instrument_type), + facility_country: convertToStringArray(docExpected.facility_country), + facility_type: convertToStringArray(docExpected.facility_type), + facility_description: convertToStringArray(docExpected.facility_description), + telescope_description: convertToStringArray(docExpected.telescope_description), + telescope_aperture: convertToStringArray(docExpected.telescope_aperture), + instrument_name: convertToStringArray(docExpected.instrument_name), + investigation_ref: convertToStringArray(docExpected.investigation_ref), + citation_publication_year: convertToStringArray(docExpected.citation_publication_year), + } + + if(docExpected.collection_type){ + doc.collection_type = convertToStringArray(docExpected.collection_type); + } + if(docExpected.investigation_description){ + doc.investigation_description = convertToStringArray(docExpected.investigation_description); + } + if(docExpected.instrument_host_name){ + doc.instrument_host_name = convertToStringArray(docExpected.instrument_host_name); + } + if(docExpected.investigation_start_date){ + doc.investigation_start_date = convertToStringArray(docExpected.investigation_start_date); + } + if(docExpected.investigation_stop_date){ + doc.investigation_stop_date = convertToStringArray(docExpected.investigation_stop_date); + } + if(docExpected.instrument_description){ + doc.instrument_description = convertToStringArray(docExpected.instrument_description); + } + if(docExpected['form-instrument-host']){ + doc['form-instrument-host'] = convertToStringArray(docExpected['form-instrument-host']); + } + if(docExpected.citation_doi){ + doc.citation_doi = convertToStringArray(docExpected.citation_doi); + } + if(docExpected.primary_result_processing_level){ + doc.primary_result_processing_level = convertToStringArray(docExpected.primary_result_processing_level); + } + if(docExpected.observation_start_date_time){ + doc.observation_start_date_time = convertToStringArray(docExpected.observation_start_date_time); + } + if(docExpected.observation_stop_date_time){ + doc.observation_stop_date_time = convertToStringArray(docExpected.observation_stop_date_time); + } + if(docExpected.investigation_name){ + doc.investigation_name = convertToStringArray(docExpected.investigation_name); + } + if(docExpected.primary_result_discipline_name){ + doc.primary_result_discipline_name = convertToStringArray(docExpected.primary_result_discipline_name); + } + if(docExpected.target_type){ + doc.target_type = convertToStringArray(docExpected.target_type); + } + if(docExpected.service_url){ + doc.service_url = convertToStringArray(docExpected.service_url); + } + if(docExpected.version_id){ + doc.version_id = convertToStringArray(docExpected.version_id); + } + if(docExpected.service_category){ + doc.service_category = convertToStringArray(docExpected.service_category); + } + if(docExpected['form-target']){ + doc['form-target'] = convertToStringArray(docExpected['form-target']); + } + if(docExpected.target_description){ + doc.target_description = convertToStringArray(docExpected.target_description); + } + if(docExpected.instrument_host_description){ + doc.instrument_host_description = convertToStringArray(docExpected.instrument_host_description); + } + + formattedData.push(doc); + }); + + return formattedData; +} + +export const formatIdentifierNameResults = (data: SolrIdentifierNameResponseExpected) => { + const formattedData: SolrIdentifierNameResponse = transformSolrIdentifierNameResponse(data); + + return formattedData; +}; + + +const transformSolrIdentifierNameResponse = (data: SolrIdentifierNameResponseExpected) => { + const formattedData: SolrIdentifierNameResponse = { + response: transformIdentifierNameResponse(data.response), + responseHeader: data.responseHeader, + facet_counts: data.facet_counts + } + + return formattedData; +} + +const transformIdentifierNameResponse = (data: IdentifierNameResponseExpected) => { + const formattedData: IdentifierNameResponse = { + numFound: data.numFound, + start: data.start, + maxScore: data.maxScore, + docs: transformIdentifierNameDocs(data.docs) + } + + return formattedData; +} + +const transformIdentifierNameDocs = (data: IdentifierNameDocExpected[]) => { + const formattedData: IdentifierNameDoc[] = []; + + data.forEach((docExpected) => { + const doc = { + identifier: convertToStringArray(docExpected.identifier), + investigation_name: convertToStringArray(docExpected.investigation_name), + instrument_name: convertToStringArray(docExpected.instrument_name), + target_name: convertToStringArray(docExpected.target_name), + title: convertToStringArray(docExpected.title), + } + + formattedData.push(doc); + }); + + return formattedData; +} + +const convertToStringArray = (param: string | string[]): string[] => Array.isArray(param) ? param : [param]; \ No newline at end of file diff --git a/apps/frontend/src/types/solrSearchResponse.d.ts b/apps/frontend/src/types/solrSearchResponse.d.ts index b12b2f3..d779105 100644 --- a/apps/frontend/src/types/solrSearchResponse.d.ts +++ b/apps/frontend/src/types/solrSearchResponse.d.ts @@ -26,7 +26,6 @@ export type Facetfields = { facet_instrument: (number | string)[]; facet_primary_result_purpose: (number | string)[]; facet_primary_result_processing_level: string[]; - page_type: string[]; investigation_ref: string[]; target_ref: string[]; @@ -35,7 +34,7 @@ export type Facetfields = { type Facetqueries = object; -type Response = { +export type Response = { numFound: number; start: number; maxScore: number; @@ -50,45 +49,46 @@ type IdentifierNameResponse = { } type SearchResultDoc = { + page_type: string[]; file_ref_location: string[]; data_class: string[]; description: string[]; file_ref_url: string[]; - title: string; - resLocation: string; - objectType: string; + title: string[]; + resLocation: string[]; + objectType: string[]; product_class: string[]; data_product_type: string[]; file_ref_size: string[]; modification_date: string[]; file_ref_name: string[]; - identifier: string; + identifier: string[]; resource_url: string[]; agency_name: string[]; 'form-agency': string[]; modification_description: string[]; resource_type: string[]; version_id: string[]; - search_id: string; - pds_model_version: string; + search_id: string[]; + pds_model_version: string[]; resource_description: string[]; resource_name: string[]; - timestamp: string; + timestamp: string[]; score: number; collection_type?: string[]; investigation_description?: string[]; instrument_host_name?: string[]; + instrument_host_type?: string[]; investigation_start_date?: string[]; investigation_stop_date?: string[]; instrument_description?: string[]; - 'form-instrument-type'?: string[]; 'form-instrument-host'?: string[]; - 'form-investigation'?: string[]; citation_doi?: string[]; primary_result_processing_level?: string[]; observation_start_date_time?: string[]; observation_stop_date_time?: string[]; investigation_name?: string[]; + investigation_type?: string[]; primary_result_discipline_name?: string[]; target_type?: string[]; service_url?: string[]; @@ -109,16 +109,14 @@ type SearchResultDoc = { instrument_name: string[]; investigation_ref: string[]; citation_publication_year: string[]; - - } type IdentifierNameDoc = { - identifier: string; + identifier: string[]; investigation_name: string[]; instrument_name: string[]; target_name: string[]; - title: string; + title: string[]; } type ResponseHeader = { diff --git a/apps/frontend/src/types/solrSearchResponseExpected.d.ts b/apps/frontend/src/types/solrSearchResponseExpected.d.ts new file mode 100644 index 0000000..054f8f7 --- /dev/null +++ b/apps/frontend/src/types/solrSearchResponseExpected.d.ts @@ -0,0 +1,131 @@ +export type SolrSearchResponse = { + responseHeader: ResponseHeader; + response: Response; + facet_counts: Facetcounts; +} + +export type SolrIdentifierNameResponse = { + responseHeader: ResponseHeader; + response: IdentifierNameResponse; + facet_counts: Facetcounts; +} + +export type Facetcounts = { + facet_queries: Facetqueries; + facet_fields: Facetfields; + facet_dates: Facetqueries; + facet_ranges: Facetqueries; +} + +export type Facetfields = { + facet_pds_model_version: (number | string)[]; + facet_agency: (number | string)[]; + facet_type: (number | string)[]; + facet_target: (number | string)[]; + facet_investigation: (number | string)[]; + facet_instrument: (number | string)[]; + facet_primary_result_purpose: (number | string)[]; + facet_primary_result_processing_level: string[]; + page_type: string[]; + investigation_ref: string[]; + target_ref: string[]; + instrument_ref: string[]; +} + +type Facetqueries = object; + +export type Response = { + numFound: number; + start: number; + maxScore: number; + docs: SearchResultDoc[]; +} + +type IdentifierNameResponse = { + numFound: number; + start: number; + maxScore: number; + docs: IdentifierNameDoc[]; +} + +export type SearchResultDoc = { + page_type: string | string[]; + file_ref_location: string | string[]; + data_class: string | string[]; + description: string | string[]; + file_ref_url: string | string[]; + title: string | string[]; + resLocation: string | string[]; + objectType: string | string[]; + product_class: string | string[]; + data_product_type: string | string[]; + file_ref_size: string | string[]; + modification_date: string | string[]; + file_ref_name: string | string[]; + identifier: string | string[]; + resource_url: string | string[]; + agency_name: string | string[]; + 'form-agency': string | string[]; + modification_description: string | string[]; + resource_type: string | string[]; + search_id: string | string[]; + pds_model_version: string | string[]; + resource_description: string | string[]; + resource_name: string | string[]; + timestamp: string | string[]; + score: number; + collection_type?: string | string[]; + investigation_description?: string | string[]; + instrument_host_name?: string | string[]; + investigation_start_date?: string | string[]; + investigation_stop_date?: string | string[]; + instrument_description?: string | string[]; + 'form-instrument-host'?: string | string[]; + citation_doi?: string | string[]; + primary_result_processing_level?: string | string[]; + observation_start_date_time?: string | string[]; + observation_stop_date_time?: string | string[]; + investigation_name?: string | string[]; + primary_result_discipline_name?: string | string[]; + target_type?: string | string[]; + service_url?: string | string[]; + version_id?: string | string[]; + service_category?: string | string[]; + 'form-target'?: string | string[]; + target_description?: string | string[]; + instrument_host_description?: string | string[]; + investigation_type: string | string[]; + primary_result_purpose: string | string[]; + node_id: string | string[]; + instrument_type: string | string[]; + facility_country: string | string[]; + facility_type: string | string[]; + facility_description: string | string[]; + telescope_description: string | string[]; + telescope_aperture: string | string[]; + instrument_name: string | string[]; + investigation_ref: string | string[]; + citation_publication_year: string | string[]; +} + +type IdentifierNameDoc = { + identifier: string | string[]; + investigation_name: string | string[]; + instrument_name: string | string[]; + target_name: string | string[]; + title: string | string[]; +} + +type ResponseHeader = { + status: number; + QTime: number; + params: Params; +} + +type Params = { + q: string; + start: string; + fq: string[] | string; + rows: string; + wt: string; +} \ No newline at end of file diff --git a/apps/frontend/src/utils/strings.ts b/apps/frontend/src/utils/strings.ts index 1f9a6e9..968ff73 100644 --- a/apps/frontend/src/utils/strings.ts +++ b/apps/frontend/src/utils/strings.ts @@ -37,4 +37,28 @@ export const copyToClipboard = async (element:string) => { } catch (err) { console.error('Failed to copy: ', err); } +} + +export const getFacilityDescription = (title:string, description:string) => { + return `Portal for ${title}, providing data, telescopes, and other resources. ${description}`; +} + +export const getInstrumentDescription = (title:string, description:string) => { + return `Portal for the ${title} instrument, providing data, tools, and other resources. ${description}`; +} + +export const getInstrumentHostDescription = (title:string, description:string) => { + return `Portal for the ${title} instrument host, providing data, instruments, and other resources. ${description}`; +} + +export const getInvestigationDescription = (title:string, description:string) => { + return `Portal for the ${title} investigation, providing data, instrument hosts, instruments, and other resources. ${description}`; +} + +export const getTargetDescription = (title:string, description:string) => { + return `Portal for the target ${title}, providing data, investigations, and other resources. ${description}`; +} + +export const getTelescopeDescription = (title:string, description:string) => { + return `Portal for ${title}, providing data, instruments, and other resources. ${description}`; } \ No newline at end of file