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

Features/6364 detail page reramp dataaccess #313

Merged
merged 5 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions playwright/pages/components/tab_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pages.components.tabs.citation import CitationTab
from pages.components.tabs.global_attr import GlobalAttrTab
from pages.components.tabs.lineage import LineageTab
from pages.components.tabs.links import LinksTab
from pages.components.tabs.links import DataAccessTab
from pages.components.tabs.metadata_info import MetadataInfoTab


Expand All @@ -22,8 +22,8 @@ def __init__(self, page: Page):

# Tabs
self.abstract = SummaryTab(page)
self.links = DataAccessTab(page)
self.about = AboutTab(page)
self.links = LinksTab(page)
self.lineage = LineageTab(page)
self.metadata_info = MetadataInfoTab(page)
self.citation = CitationTab(page)
Expand Down
4 changes: 2 additions & 2 deletions playwright/pages/components/tabs/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pages.base_page import BasePage


class LinksTab(BasePage):
TAB_NAME = 'Links'
class DataAccessTab(BasePage):
TAB_NAME = 'Data Access'

def __init__(self, page: Page):
self.page = page
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const detailPageDefault = {
ABOUT: "about",
ASSOCIATED_RECORDS: "associated records",
CITATION: "citation",
LINKS: "links",
DATA_ACCESS: "data_access",
LINEAGE: "lineage",
METADATA_INFORMATION: "metadata information",
SUMMARY: "summary",
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/hover-tip/ComplexMapHoverTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ComplexMapHoverTip: FC<ComplexMapHoverTipProps> = ({
() =>
tabNavigation(
collection.id,
detailPageDefault.LINKS,
detailPageDefault.DATA_ACCESS,
SEARCH_PAGE_REFERER
),
[collection.id, tabNavigation]
Expand Down
9 changes: 8 additions & 1 deletion src/components/common/store/OGCCollectionDefinitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export enum RelationType {
export enum MediaType {
TEXT_HTML = "text/html",
IMAGE_PNG = "image/png",
PYTHON_NOTEBOOK = "application/x-ipynb+json",
}

const getIcon = (href: string, rel: string) => {
Expand Down Expand Up @@ -203,12 +204,18 @@ export class OGCCollection {
getLicense = (): string | undefined => this.propValue?.license;
getCreation = (): string | undefined => this.propValue?.creation;
getRevision = (): string | undefined => this.propValue?.revision;
getPythonNotebook = (): ILink[] | undefined =>
this.links?.filter((link) => link.type === MediaType.PYTHON_NOTEBOOK);
getDataAccessLinks = (): ILink[] | undefined =>
this.links?.filter(
(link) => link.rel === RelationType.WMS || link.rel === RelationType.WFS
);
getDistributionLinks = (): ILink[] | undefined =>
this.links?.filter((link) => link.rel === RelationType.RELATED);
this.links?.filter(
(link) =>
link.rel === RelationType.RELATED &&
link.type !== MediaType.PYTHON_NOTEBOOK
);
getMetadataUrl = (): string | undefined =>
this.links?.filter(
(link) =>
Expand Down
75 changes: 75 additions & 0 deletions src/components/list/DataAccessList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React, { FC, useState } from "react";
import ExpandableList from "./ExpandableList";
import ItemBaseGrid from "./listItem/ItemBaseGrid";
import { ILink } from "../common/store/OGCCollectionDefinitions";
import LinkCard from "./listItem/subitem/LinkCard";
import NaList from "./NaList";

interface DataAccessListProps {
linksToData?: ILink[];
dataAccessLinks?: ILink[];
pythonNotebook?: ILink[];
}

const DataAccessList: FC<DataAccessListProps> = ({
linksToData = [],
dataAccessLinks = [],
pythonNotebook = [],
}) => {
const [clickedCopyLinkButtonIndex, setClickedCopyLinkButtonIndex] = useState<
number[]
>([]);

const pythonNotebookItems = pythonNotebook.map(
(link: ILink, index: number) => (
<ItemBaseGrid key={index} sx={{}}>
<LinkCard
key={index}
index={index}
link={link}
clickedCopyLinkButtonIndex={clickedCopyLinkButtonIndex}
setClickedCopyLinkButtonIndex={setClickedCopyLinkButtonIndex}
/>
</ItemBaseGrid>
)
);

const linksToDataItems = linksToData.map((link: ILink, index: number) => (
<ItemBaseGrid key={index} sx={{}}>
<LinkCard
key={index}
index={index}
link={link}
clickedCopyLinkButtonIndex={clickedCopyLinkButtonIndex}
setClickedCopyLinkButtonIndex={setClickedCopyLinkButtonIndex}
/>
</ItemBaseGrid>
));

const dataAccessItems = dataAccessLinks.map((link: ILink, index: number) => (
<ItemBaseGrid key={index} sx={{}}>
<LinkCard
key={index}
index={index}
link={link}
clickedCopyLinkButtonIndex={clickedCopyLinkButtonIndex}
setClickedCopyLinkButtonIndex={setClickedCopyLinkButtonIndex}
/>
</ItemBaseGrid>
));

return dataAccessItems ? (
<>
<ExpandableList childrenList={linksToDataItems} title="Links to Data" />
<ExpandableList childrenList={dataAccessItems} title="Data Access List" />
<ExpandableList
childrenList={pythonNotebookItems}
title="Python Notebook"
/>
</>
) : (
<NaList title={"Data Access"} />
);
};

export default DataAccessList;
32 changes: 16 additions & 16 deletions src/components/list/listItem/subitem/LinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@ const LinkCard: FC<LinkCardProps> = ({
data-testid="links-card"
>
<Grid container>
{setClickedCopyLinkButtonIndex && (
<Grid item xs={2}>
<Box
sx={{
visibility:
isShowCopyLinkButton || hasBeenCopied ? "visible" : "hidden",
}}
>
<CopyLinkButton
index={index}
setClickedCopyLinkButtonIndex={setClickedCopyLinkButtonIndex}
copyUrl={link.href}
/>
</Box>
</Grid>
)}
<Grid item xs={setClickedCopyLinkButtonIndex ? 10 : 12}>
<Grid container spacing={1} aria-label="link and title">
{icon && link.getIcon && (
Expand Down Expand Up @@ -107,6 +91,22 @@ const LinkCard: FC<LinkCardProps> = ({
</Grid>
</Grid>
</Grid>
{setClickedCopyLinkButtonIndex && (
<Grid item xs={2}>
<Box
sx={{
visibility:
isShowCopyLinkButton || hasBeenCopied ? "visible" : "hidden",
}}
>
<CopyLinkButton
index={index}
setClickedCopyLinkButtonIndex={setClickedCopyLinkButtonIndex}
copyUrl={link.href}
/>
</Box>
</Grid>
)}
</Grid>
</Box>
);
Expand Down
18 changes: 10 additions & 8 deletions src/components/map/mapbox/layers/DetailSymbolLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ const DetailSymbolLayer: FC<LayerBasicType> = ({
data: featureCollection,
});

map?.loadImage("/images/legend1.png", (error, image) => {
if (error) {
throw error;
}
if (image) {
map?.addImage("legend1_img", image);
}
});
if (!map?.hasImage("legend1_img")) {
map?.loadImage("/images/legend1.png", (error, image) => {
if (error) {
throw error;
}
if (image) {
map?.addImage("legend1_img", image);
}
});
}

map?.addLayer({
id: clusterLayer,
Expand Down
2 changes: 1 addition & 1 deletion src/components/result/ResultCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const ResultCards: FC<ResultCardsProps> = ({

const onClickLinks = useCallback(
(uuid: string) =>
goToDetailPage(uuid, detailPageDefault.LINKS, SEARCH_PAGE_REFERER),
goToDetailPage(uuid, detailPageDefault.DATA_ACCESS, SEARCH_PAGE_REFERER),
[goToDetailPage]
);

Expand Down
2 changes: 0 additions & 2 deletions src/pages/detail-page/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import ContentSection from "./subpages/ContentSection";
import SectionContainer from "../../components/layout/components/SectionContainer";
import { LngLatBounds, MapLayerMouseEvent } from "mapbox-gl";
import { useCallback, useState } from "react";
import useBreakpoint from "../../hooks/useBreakpoint";

const DetailsPage = () => {
const { isUnderLaptop } = useBreakpoint();
const [bbox, setBbox] = useState<LngLatBounds | undefined>(undefined);
const onSpatialCoverageLayerClick = useCallback(
(evt: MapLayerMouseEvent) => {
Expand Down
Loading