Skip to content

Commit

Permalink
Merge pull request #358 from GenomicDataInfrastructure/ART-6899
Browse files Browse the repository at this point in the history
feat: dataset detail page
  • Loading branch information
brunopacheco1 authored Jul 29, 2024
2 parents d12f9c1 + f3ddaba commit 3007d26
Show file tree
Hide file tree
Showing 14 changed files with 610 additions and 120 deletions.
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
Expand Down
6 changes: 5 additions & 1 deletion src/app/applications/[id]/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ function DateField({ formId, field, title, editable }: DateFieldProps) {
<DatePicker
selected={inputValue}
onChange={handleDateChange}
className={`mt-4 h-12 w-full rounded-lg border-2 border-primary px-4 py-[9px] text-md text-base shadow-sm ${isDisabled ? "border-slate-200 bg-background ring-offset-background placeholder:text-muted-foreground flex file:border-0 file:bg-transparent file:font-medium file:text-sm focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50" : "bg-white focus:outline-none focus:ring-primary"}`}
className={`mt-4 h-12 w-full rounded-lg border-2 border-primary px-4 py-[9px] text-md text-base shadow-sm ${
isDisabled
? "border-slate-200 bg-background ring-offset-background placeholder:text-muted-foreground flex file:border-0 file:bg-transparent file:font-medium file:text-sm focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
: "bg-white focus:outline-none focus:ring-primary"
}`}
placeholderText="dd/mm/yyyy"
dateFormat="dd/MM/yyyy"
calendarClassName="rounded-lg shadow-lg p-2"
Expand Down
6 changes: 5 additions & 1 deletion src/app/applications/[id]/GenericInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ function GenericInputField({
name={field.id.toString()}
value={inputValue}
onChange={handleInputChange}
className={`h-12 w-full rounded-lg border-2 border-primary px-4 text-md py-[9px] ${isDisabled ? "border-slate-200 bg-background ring-offset-background placeholder:text-muted-foreground flex file:border-0 file:bg-transparent file:font-medium file:text-sm focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50" : "bg-white border-primary"}`}
className={`h-12 w-full rounded-lg border-2 border-primary px-4 text-md py-[9px] ${
isDisabled
? "border-slate-200 bg-background ring-offset-background placeholder:text-muted-foreground flex file:border-0 file:bg-transparent file:font-medium file:text-sm focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
: "bg-white border-primary"
}`}
placeholder={placeholder}
disabled={!editable || isLoading}
/>
Expand Down
6 changes: 5 additions & 1 deletion src/app/applications/[id]/TextAreaFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ function TextAreaFormField({
placeholder={title}
rows={5}
value={inputValue}
className={`mt-4 w-full rounded-lg border-2 border-primary px-4 py-[9px] text-md ${isDisabled ? "border-slate-200 bg-background ring-offset-background placeholder:text-muted-foreground flex file:border-0 file:bg-transparent file:font-medium file:text-sm focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50" : "bg-white focus:outline-none focus:ring-primary"}`}
className={`mt-4 w-full rounded-lg border-2 border-primary px-4 py-[9px] text-md ${
isDisabled
? "border-slate-200 bg-background ring-offset-background placeholder:text-muted-foreground flex file:border-0 file:bg-transparent file:font-medium file:text-sm focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
: "bg-white focus:outline-none focus:ring-primary"
}`}
onChange={handleInputChange}
disabled={isDisabled}
/>
Expand Down
17 changes: 14 additions & 3 deletions src/app/datasets/[id]/ClientSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

"use client";

import Sidebar from "@/components/Sidebar";
import { RetrievedDataset } from "@/services/discovery/types/dataset.types";
import { createDatasetSidebarItems } from "./sidebarItems";

Expand All @@ -14,9 +13,21 @@ type ClientSidebarProps = {

function ClientSidebar({ dataset }: ClientSidebarProps) {
const sidebarItems = createDatasetSidebarItems(dataset);

return (
<aside className="w-full lg:w-1/3">
<Sidebar items={sidebarItems} />
<aside className="w-full lg:w-1/3 lg:sticky top-24">
<div className="flex flex-col gap-4 pb-8">
{sidebarItems.map((item, index) => (
<div key={index} className="mb-3">
<h3 className="text-base text-primary sm:text-lg lg:text-xl">
{item.label}
</h3>
<span className="text-sm sm:text-base lg:text-lg">
{item.value}
</span>
</div>
))}
</div>
</aside>
);
}
Expand Down
225 changes: 225 additions & 0 deletions src/app/datasets/[id]/DatasetMetadata.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

"use client";

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faSyncAlt,
faBuilding,
faTag,
faFile,
faCalendarAlt,
faKey,
faLanguage,
faIdBadge,
} from "@fortawesome/free-solid-svg-icons";
import { formatDate } from "@/utils/formatDate";
import {
RetrievedDataset,
DatasetRelationship,
DatasetDictionaryEntry,
} from "@/services/discovery/types/dataset.types";
import { formatRelationshipType } from "@/utils/datasetRelationshipUtils";
import {
formatFieldName,
formatDescription,
} from "@/utils/datasetDictionaryUtils";
import DistributionAccordion from "./DistributionAccordion";
import Link from "next/link";

const DatasetMetadata = ({
dataset,
relationships,
dictionary,
}: {
dataset: RetrievedDataset;
relationships: DatasetRelationship[];
dictionary: DatasetDictionaryEntry[];
}) => {
return (
<>
<div className="flex flex-col sm:flex-row sm:flex-wrap gap-3 font-[400] text-gray">
{dataset.createdAt && (
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faCalendarAlt}
className="align-middle text-primary"
/>
<span className="align-middle">
Created on {formatDate(dataset.createdAt)}
</span>
</span>
)}
{dataset.createdAt && dataset.modifiedAt && (
<div className="text-lightaccent hidden sm:inline-block">|</div>
)}
{dataset.modifiedAt && (
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faSyncAlt}
className="align-middle text-primary"
/>
<span className="align-middle">
Modified on {formatDate(dataset.modifiedAt)}
</span>
</span>
)}
{dataset.catalogue && (
<>
<div className="text-lightaccent hidden sm:inline-block">|</div>
<span className="inline sm:flex-row flex flex-col gap-2">
<div className="flex gap-2 items-center">
<FontAwesomeIcon
icon={faBuilding}
className="align-middle text-primary"
/>
</div>
<div className="pl-5 sm:pl-0 lg:pl-0 flex items-center">
<Link href={``}>
<h1 className="m-auto md:m-0 underline inline">
{dataset.catalogue || "No title."}
</h1>
</Link>
</div>
</span>
</>
)}
{dataset.accessRights && (
<>
<div className="text-lightaccent hidden sm:inline-block">|</div>
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faTag}
className="align-middle text-primary"
/>
<span className="align-middle">
{dataset.accessRights.label || "No access rights information."}
</span>
</span>
</>
)}
{dataset.identifier && (
<>
<div className="text-lightaccent hidden sm:inline-block">|</div>
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faIdBadge}
className="align-middle text-primary"
/>
<span className="align-middle">
Identifier: {dataset.identifier}
</span>
</span>
</>
)}
{dataset.languages?.length > 0 && (
<>
<div className="text-lightaccent hidden sm:inline-block">|</div>
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faLanguage}
className="align-middle text-primary"
/>
<span className="align-middle">
Languages:{" "}
{dataset.languages?.map((lang) => lang.label).join(", ")}
</span>
</span>
</>
)}
{dataset.distributions?.length > 0 && (
<>
<div className="text-lightaccent hidden sm:inline-block">|</div>
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faFile}
className="align-middle text-primary "
/>
<span className="align-middle">
{dataset.distributions.length} Distribution(s)
</span>
</span>
</>
)}
</div>
{dataset.keywords?.length > 0 && (
<div className="mt-4">
<span className="inline flex gap-2 items-center">
<FontAwesomeIcon
icon={faKey}
className="align-middle text-primary"
/>
<span className="align-middle">Keywords:</span>
<div className="flex flex-wrap gap-1">
{dataset.keywords?.map((keyword) => (
<span
className="bg-[var(--color-warning)] bg-opacity-50 px-4 py-1 rounded-md text-gray font-[500] text-[14px] inline-block"
key={keyword.value}
>
{keyword.label}
</span>
))}
</div>
</span>
</div>
)}
{relationships.length > 0 && (
<div className="flex flex-col mt-4 space-y-2">
<div className="flex flex-col gap-1">
{relationships.map((relationship, index) => (
<div
key={index}
className="inline-flex bg-[#EFFAFE] px-4 py-1 rounded-md text-gray font-[500] text-[14px] group"
>
<Link
href={`/@${dataset.catalogue}/${relationship.related_dataset}`}
className="group-hover:text-red hover:font-bold"
>
<FontAwesomeIcon
icon={faTag}
className="align-middle text-primary"
/>
<span className="align-middle">
{formatRelationshipType(relationship.relationship_type)}:{" "}
{relationship.related_dataset}
</span>
</Link>
</div>
))}
</div>
</div>
)}
{dictionary.length > 0 && (
<div className="mt-4">
<h2 className="text-[18px] font-semibold py-2.5">
Dataset Dictionary
</h2>
<div className="flex flex-col gap-2">
{dictionary.map((entry, index) => (
<div key={index} className="flex items-center gap-2">
<span className="inline-flex items-center gap-2 text-gray-800 text-[15px] font-bold">
<FontAwesomeIcon
icon={faTag}
className="align-middle text-primary"
/>
{formatFieldName(entry.field_name)}
</span>
<span className="text-sm text-gray-800">
({entry.data_type}):
</span>
<p className="text-sm font-normal text-gray text-[15px] m-0">
{formatDescription(entry.description)}
</p>
</div>
))}
</div>
</div>
)}
<DistributionAccordion distributions={dataset.distributions || []} />
</>
);
};

export default DatasetMetadata;
Loading

0 comments on commit 3007d26

Please sign in to comment.