Skip to content
Snippets Groups Projects
Commit bff2f8fc authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merge branch '791-add-ispyb-logo-for-each-mx-dataset' into 'main'

Resolve "Add ISPyB logo for each MX Dataset"

Closes #791

See merge request !687
parents 50641a5d 7b33ecdf
No related branches found
No related tags found
1 merge request!687Resolve "Add ISPyB logo for each MX Dataset"
Pipeline #222895 passed
...@@ -160,6 +160,11 @@ export default function MXInvestigationViewer({ ...@@ -160,6 +160,11 @@ export default function MXInvestigationViewer({
sampleIdNumber ? [sampleIdNumber.toString()] : undefined sampleIdNumber ? [sampleIdNumber.toString()] : undefined
} }
parameterFilter={parametersFilters} parameterFilter={parametersFilters}
paginationBarLogo={{
src: '/images/ispyb/black_logo_ispyb.gif',
alt: 'ISPyB',
url: 'https://doi.org/10.1093/bioinformatics/btr535',
}}
/> />
</> </>
)} )}
......
apps/portal/public/images/ispyb/black_logo_ispyb.gif

2.5 KiB

...@@ -13,6 +13,7 @@ import { Loading, NoData } from 'components/utils'; ...@@ -13,6 +13,7 @@ import { Loading, NoData } from 'components/utils';
import { DatasetViewerType, useViewers } from 'context'; import { DatasetViewerType, useViewers } from 'context';
import { formatDateToDay } from 'helpers'; import { formatDateToDay } from 'helpers';
import { PaginationMenu, useEndpointPagination, useParam } from 'hooks'; import { PaginationMenu, useEndpointPagination, useParam } from 'hooks';
import { LogoHeaderType } from 'components/utils/LogoHeader';
import React, { import React, {
Suspense, Suspense,
useCallback, useCallback,
...@@ -30,6 +31,7 @@ export function DatasetList( ...@@ -30,6 +31,7 @@ export function DatasetList(
showInvestigation?: boolean; showInvestigation?: boolean;
parameterFilter?: string; parameterFilter?: string;
datasetViewerType?: DatasetViewerType; datasetViewerType?: DatasetViewerType;
paginationBarLogo?: LogoHeaderType;
} & ( } & (
| { | {
groupBy: 'dataset'; groupBy: 'dataset';
...@@ -46,12 +48,15 @@ export function DatasetList( ...@@ -46,12 +48,15 @@ export function DatasetList(
} }
), ),
) { ) {
// State to handle scrolling to a specific sample
const [scrollToSample, setScrollToSample] = useParam('scrollToSample', ''); const [scrollToSample, setScrollToSample] = useParam('scrollToSample', '');
// Callback to reset scroll state after scrolling is done
const onScrollDone = useCallback(() => { const onScrollDone = useCallback(() => {
setScrollToSample(undefined); setScrollToSample(undefined);
}, [setScrollToSample]); }, [setScrollToSample]);
// Conditionally render datasets or samples based on `groupBy` argument
switch (args.groupBy) { switch (args.groupBy) {
case 'dataset': case 'dataset':
if (args.datasets) { if (args.datasets) {
...@@ -95,6 +100,7 @@ export function DatasetList( ...@@ -95,6 +100,7 @@ export function DatasetList(
} }
} }
// Component to load sample-based dataset lists dynamically
function LoadDatasetListBySamples({ function LoadDatasetListBySamples({
instrumentName, instrumentName,
investigationId, investigationId,
...@@ -103,6 +109,7 @@ function LoadDatasetListBySamples({ ...@@ -103,6 +109,7 @@ function LoadDatasetListBySamples({
showInvestigation, showInvestigation,
scrollToSampleId, scrollToSampleId,
onScrollDone, onScrollDone,
paginationBarLogo,
}: { }: {
instrumentName?: string; instrumentName?: string;
investigationId?: string; investigationId?: string;
...@@ -111,7 +118,9 @@ function LoadDatasetListBySamples({ ...@@ -111,7 +118,9 @@ function LoadDatasetListBySamples({
showInvestigation?: boolean; showInvestigation?: boolean;
scrollToSampleId?: string; scrollToSampleId?: string;
onScrollDone?: () => void; onScrollDone?: () => void;
paginationBarLogo?: LogoHeaderType;
}) { }) {
// Construct API parameters
const sampleListParams = useMemo( const sampleListParams = useMemo(
() => ({ () => ({
...(investigationId ? { investigationId: Number(investigationId) } : {}), ...(investigationId ? { investigationId: Number(investigationId) } : {}),
...@@ -159,7 +168,11 @@ function LoadDatasetListBySamples({ ...@@ -159,7 +168,11 @@ function LoadDatasetListBySamples({
return ( return (
<Col> <Col>
<PaginationMenu {...samples} showScrollToBottom /> <PaginationMenu
{...samples}
showScrollToBottom
logo={paginationBarLogo}
/>
<Row> <Row>
<SampleObjectList <SampleObjectList
samples={samples.data} samples={samples.data}
...@@ -267,6 +280,7 @@ function LoadDatasetListByDataset({ ...@@ -267,6 +280,7 @@ function LoadDatasetListByDataset({
sampleId, sampleId,
showInvestigation, showInvestigation,
datasetViewerType, datasetViewerType,
logoHeader,
}: { }: {
instrumentName?: string; instrumentName?: string;
investigationId?: string; investigationId?: string;
...@@ -277,6 +291,7 @@ function LoadDatasetListByDataset({ ...@@ -277,6 +291,7 @@ function LoadDatasetListByDataset({
sampleId?: string; sampleId?: string;
showInvestigation?: boolean; showInvestigation?: boolean;
datasetViewerType?: DatasetViewerType; datasetViewerType?: DatasetViewerType;
logoHeader?: LogoHeaderType;
}) { }) {
const datasets = useEndpointPagination({ const datasets = useEndpointPagination({
endpoint: DATASET_LIST_ENDPOINT, endpoint: DATASET_LIST_ENDPOINT,
...@@ -299,7 +314,7 @@ function LoadDatasetListByDataset({ ...@@ -299,7 +314,7 @@ function LoadDatasetListByDataset({
return ( return (
<Col> <Col>
<PaginationMenu {...datasets} showScrollToBottom /> <PaginationMenu {...datasets} showScrollToBottom logo={logoHeader} />
<Row> <Row>
<DatasetObjectList <DatasetObjectList
datasets={datasets.data} datasets={datasets.data}
......
/**
* This type defines an object used to display the logo in the pagination bar
* src will be the href of the image to be displayed
* alt is the alternative text
* url when it exists will be a link
*/
export type LogoHeaderType = {
src: string;
alt: string;
url?: string;
};
/**
* Component: LogoHeader
* Renders a logo image with an optional hyperlink.
*
* @param {string} props.header.src - Image source URL.
* @param {string} props.header.alt - Alternative text for the image.
* @param {string} [props.header.url] - Optional hyperlink URL.
*/
export function LogoHeader({ header }: { header: LogoHeaderType }) {
const { src, alt, url } = header;
// Create an image element
const img = <img src={src} alt={alt} />;
return (
<>
{/* If URL is provided, wrap image in an anchor tag */}
{url && (
<a href={url} target="_blank" rel="noreferrer">
{img}
</a>
)}
{/* If no URL, render only the image */}
{!url && { img }}
</>
);
}
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
faAngleDoubleDown, faAngleDoubleDown,
faAngleDoubleUp, faAngleDoubleUp,
} from '@fortawesome/free-solid-svg-icons'; } from '@fortawesome/free-solid-svg-icons';
import { LogoHeader, LogoHeaderType } from 'components/utils/LogoHeader';
export interface Pagination { export interface Pagination {
page: number; page: number;
...@@ -27,6 +28,7 @@ export interface Pagination { ...@@ -27,6 +28,7 @@ export interface Pagination {
handlePageChange: (newPage: number) => void; handlePageChange: (newPage: number) => void;
handlePageSizeChange: (newSize: number) => void; handlePageSizeChange: (newSize: number) => void;
availableSizes: number[]; availableSizes: number[];
logo?: LogoHeaderType;
} }
export function PaginationMenu({ export function PaginationMenu({
...@@ -37,6 +39,7 @@ export function PaginationMenu({ ...@@ -37,6 +39,7 @@ export function PaginationMenu({
margin, margin,
showScrollToTop = false, showScrollToTop = false,
showScrollToBottom = false, showScrollToBottom = false,
logo,
}: { }: {
pagination: Pagination; pagination: Pagination;
totalPages: number; totalPages: number;
...@@ -45,6 +48,7 @@ export function PaginationMenu({ ...@@ -45,6 +48,7 @@ export function PaginationMenu({
margin?: string; margin?: string;
showScrollToTop?: boolean; showScrollToTop?: boolean;
showScrollToBottom?: boolean; showScrollToBottom?: boolean;
logo?: LogoHeaderType;
}) { }) {
const canPrevious = pagination.page > 0; const canPrevious = pagination.page > 0;
const canNext = pagination.page < totalPages - 1; const canNext = pagination.page < totalPages - 1;
...@@ -205,6 +209,11 @@ export function PaginationMenu({ ...@@ -205,6 +209,11 @@ export function PaginationMenu({
</Button> </Button>
</Col> </Col>
)} )}
{logo && (
<Col xs="auto" className="ms-auto">
<LogoHeader header={logo}></LogoHeader>
</Col>
)}
</Row> </Row>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment