Skip to content

Commit

Permalink
Suppport new version of MASS (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored Aug 12, 2024
1 parent 4c4ec99 commit 95fb0bd
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 128 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-portal-ui",
"version": "1.2.3",
"version": "1.3.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "~6.4.2",
Expand Down
22 changes: 12 additions & 10 deletions src/api/browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type getDatasetsSearchRespType = (
* function with search results, returns nothing.
* @param callbackFunc - Function takes an argument conforms to the searchResponseModel.
* @param filterQuery - Filters to be applied, array of objects that conform to the facetFilterModel.
* @param searchKeyword - String representing the search keyword. Default: "*".
* @param searchKeyword - String representing the search keyword. Default: "".
* @param skip - Number of results to skip in the search results. Default: 0.
* @param limit - Maximum number of results to be returned by the search. Default: 20.
* @param documentType - String representing the document type to search. Default: "Dataset".
Expand All @@ -43,16 +43,18 @@ export const querySearchService: getDatasetsSearchRespType = async (
limit = 20,
documentType = "EmbeddedDataset"
) => {
let url = new URL("rpc/search", MASS_URL);
const payload = {
class_name: documentType,
query: searchKeyword,
filters: filterQuery,
skip: skip,
limit: limit,
};
let url = new URL("search", MASS_URL);
const params = url.searchParams;
params.append("class_name", documentType);
if (searchKeyword) params.append("query", searchKeyword);
filterQuery.forEach((filter) => {
params.append("filter_by", filter.key);
params.append("value", filter.value);
});
if (skip) params.append("skip", skip.toString());
params.append("limit", limit.toString());
try {
const response = await fetchJson(url, "POST", payload);
const response = await fetchJson(url, "GET");
const data = await response.json();
if (response.status !== 200) {
throw new Error(`Status code ${response.status} in search response`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ const DatasetAccordion = (props: DataSetListProps) => {
{props.dsList.map((hit, index) => (
<Accordion.Item
key={index}
eventKey={hit.content.accession}
eventKey={hit.id_}
className="mb-3 border border-1 rounded-0"
title={hit.content.title}
>
<Accordion.Button
className="bg-light align-items-start text-break py-2 px-1 px-lg-2 text-black"
onClick={() => getDetails(hit.content.accession)}
onClick={() => getDetails(hit.id_)}
>
<Col xs={5} sm={4} xl={3}>
{hit.content.accession}
{hit.content.ega_accession ? (
{hit.id_}
{hit.content.alias ? (
<>
<br />
{hit.content.ega_accession}
{hit.content.alias}
</>
) : (
""
Expand All @@ -74,10 +74,7 @@ const DatasetAccordion = (props: DataSetListProps) => {
</Col>
</Accordion.Button>
<Accordion.Body className="p-2">
<DatasetSummary
hit={hit}
summary={summaryMap.get(hit.content.accession)}
/>
<DatasetSummary hit={hit} summary={summaryMap.get(hit.id_)} />
</Accordion.Body>
</Accordion.Item>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface BoldenedProps {
const BoldenedSummaryDetails = (props: BoldenedProps) => {
return (
<div>
{props.x.value} <strong>{props.x.count}</strong>
{props.x.value.replace(/_/g, " ")} <strong>{props.x.count}</strong>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ const DatasetSummary = (props: DataSetDetailsProps) => {
<div className="float-end ps-0 ps-md-4 ms-1">
{props.summary ? (
<>
{props.hit.content.ega_accession ? (
{props.hit.content.alias ? (
<Button
variant="outline-quinary"
href={
"https://ega-archive.org/datasets/" +
props.hit.content.ega_accession
props.hit.content.alias
}
className="mb-3 fs-7 shadow-md-dark d-block"
title="EGA Dataset page"
Expand All @@ -68,11 +68,11 @@ const DatasetSummary = (props: DataSetDetailsProps) => {
<></>
)}
<RequestAccessButton
accession={props.hit.content.accession}
accession={props.hit.id_}
handleOpen={handleOpen}
classes="d-block"
/>
<Link to={props.hit.content.accession}>
<Link to={props.hit.id_}>
<Button
variant="quinary"
className="text-white mb-3 fs-7 shadow-md-dark d-block"
Expand Down Expand Up @@ -110,12 +110,12 @@ const DatasetSummary = (props: DataSetDetailsProps) => {
<div className="text-break mb-3">
<p className={pClass}>
<strong>Dataset ID:&nbsp;</strong>
{props.hit.content.accession}
{props.hit.id_}
</p>
{props.hit.content.ega_accession ? (
{props.hit.content.alias ? (
<p className={pClass}>
<strong>EGA ID:&nbsp;</strong>
{props.hit.content.ega_accession}
{props.hit.content.alias}
</p>
) : (
<></>
Expand All @@ -124,21 +124,31 @@ const DatasetSummary = (props: DataSetDetailsProps) => {
<strong>Full title:&nbsp;</strong>
{props.hit.content.title}
</p>
<p className={pClass}>
<strong>Description:&nbsp;</strong>
{props.hit.content.description}
</p>
<p className={pClass}>
<strong>Types:&nbsp;</strong>
{props.hit.content.types.map((x) => (
<Badge
className="me-1 bg-white text-black border-primary border px-1 fw-normal"
key={x}
>
{x}
</Badge>
))}
</p>
{props.hit.content.description || props.summary?.description ? (
<p className={pClass}>
<strong>Description:&nbsp;</strong>
{props.hit.content.description || props.summary?.description}
</p>
) : (
<></>
)}
{(props.hit.content.types || props.summary?.types || []).length ? (
<p className={pClass}>
<strong>Types:&nbsp;</strong>
{(props.hit.content.types || props.summary?.types || []).map(
(x) => (
<Badge
className="me-1 bg-white text-black border-primary border px-1 fw-normal"
key={x}
>
{x}
</Badge>
)
)}
</p>
) : (
<></>
)}
</div>
{props.summary ? (
<div>
Expand All @@ -163,7 +173,7 @@ const DatasetSummary = (props: DataSetDetailsProps) => {
)}
</div>
<DataRequestFormModal
accession={props.hit.content.accession}
accession={props.hit.id_}
copyEmail={copyEmail}
show={show}
handleClose={handleClose}
Expand Down
32 changes: 25 additions & 7 deletions src/components/browse/dataset/datasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,31 @@ const DatasetList = (props: DataSetProps) => {
<PaginatedDataset />
</Col>
<Col xs={4} md={2} className="ps-0 ps-lg-4 pe-0">
<Form.Select
value={props.limit}
onChange={(event) => handleSelect(event)}
>
<option value="10">10</option>
{props.dsCount >= 25 ? <option value="25">25</option> : ""}
</Form.Select>
{(props.page - 1) * 50 <= props.dsCount ? (
<Form.Select
value={props.limit}
onChange={(event) => handleSelect(event)}
>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
</Form.Select>
) : (props.page - 1) * 25 <= props.dsCount ? (
<Form.Select
value={props.limit}
onChange={(event) => handleSelect(event)}
>
<option value="10">10</option>
<option value="25">25</option>
</Form.Select>
) : (
<Form.Select
value={props.limit}
onChange={(event) => handleSelect(event)}
>
<option value="10">10</option>
</Form.Select>
)}
</Col>
</Row>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/browse/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Sidebar = (props: SidebarProps) => {
querySearchService(
props.setSearchResults,
[],
"*",
"",
skip,
props.limit,
"EmbeddedDataset"
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/homeMidSection/homeMidSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const HomeMidSection = () => {
{protocolTypes.map((x) => (
<tr key={x.value}>
<th className="text-end pe-2">{x.count}</th>
<td>{x.value}</td>
<td>{x.value.replace(/_/g, " ")}</td>
</tr>
))}
</tbody>
Expand Down
Loading

0 comments on commit 95fb0bd

Please sign in to comment.