Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,16 @@ const generateTableData = (resources: any[]) => {
}));
};

const accessModelResourcesQuery = graphql(`
const accessModelResourcesQuery: any = graphql(`
query accessModelResource($datasetId: UUID!) {
accessModelResources(datasetId: $datasetId) {
modelResources {
resourceFields {
resource {
name
description
id
}
fields {
fieldName
format
id
}
fields
}
id
name
Expand All @@ -121,87 +117,91 @@ const accessModelResourcesQuery = graphql(`
const AccessModels = () => {
const params = useParams();

const { data, error, isLoading } = useQuery(
[`accessmodel_${params.datasetIdentifier}`],
() =>
GraphQL(
accessModelResourcesQuery,
{
// Entity Headers if present
},
{
datasetId: params.datasetIdentifier,
}
)
const getAccessModeldetails: {
data: any;
isError: boolean;
isLoading: boolean;
} = useQuery([`accessmodel_${params.datasetIdentifier}`], () =>
GraphQL(
accessModelResourcesQuery,
{
// Entity Headers if present
},
{
datasetId: params.datasetIdentifier,
}
)
);

return (
<>
{isLoading ? (
{getAccessModeldetails.isLoading ? (
<div className=" mt-8 flex justify-center">
<Spinner />
</div>
) : (
data?.accessModelResources.map((item: any, index: any) => (
<div
key={index}
className="my-4 flex flex-col gap-4 rounded-2 p-6 shadow-basicDeep"
>
<div className="mb-1 flex flex-wrap justify-between gap-1 lg:gap-0">
<div className="p2-4 lg:w-2/5">
<Text variant="headingMd">{item.name}</Text>
getAccessModeldetails.data?.accessModelResources.map(
(item: any, index: any) => (
<div
key={index}
className="my-4 flex flex-col gap-4 rounded-2 p-6 shadow-basicDeep"
>
<div className="mb-1 flex flex-wrap justify-between gap-1 lg:gap-0">
<div className="p2-4 lg:w-2/5">
<Text variant="headingMd">{item.name}</Text>
</div>
<div className="lg:w-3/5 lg:pl-4">
<Text>{item.description}</Text>
</div>
</div>
<div className="lg:w-3/5 lg:pl-4">
<Text>{item.description}</Text>
<div className="align-center flex flex-col justify-between gap-4 sm:flex-row lg:items-center">
<CustomTags type={item.type.split('.').pop().toLowerCase()} />
</div>
</div>
<div className="align-center flex flex-col justify-between gap-4 sm:flex-row lg:items-center">
<CustomTags type={item.type.split('.').pop().toLowerCase()} />
</div>
{item?.modelResources?.length > 0 && (
<div className="flex">
<Accordion type="single" collapsible className="w-full">
<AccordionItem value="item-1" className=" border-none">
<div className="flex flex-wrap items-center justify-between">
<AccordionTrigger className="flex w-full flex-wrap items-center gap-2 hover:no-underline">
<div className=" text-baseBlueSolid8 ">
See Resources
</div>
</AccordionTrigger>
<Button
className="h-fit w-fit"
kind="secondary"
onClick={() => {
item.modelResources.forEach((resource: any) => {
// Construct the download URL for each resource
const downloadUrl = `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/resource/${resource.resource.id}`;
// Open the URL in a new tab
window.open(downloadUrl, '_blank');
});
{item?.modelResources?.length > 0 && (
<div className="flex">
<Accordion type="single" collapsible className="w-full">
<AccordionItem value="item-1" className=" border-none">
<div className="flex flex-wrap items-center justify-between">
<AccordionTrigger className="flex w-full flex-wrap items-center gap-2 hover:no-underline">
<div className=" text-baseBlueSolid8 ">
See Resources
</div>
</AccordionTrigger>
<Button
className="h-fit w-fit"
kind="secondary"
onClick={() => {
item.modelResources.forEach((resource: any) => {
// Construct the download URL for each resource
const downloadUrl = `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/resource/${resource.resource.id}`;
// Open the URL in a new tab
window.open(downloadUrl, '_blank');
});
}}
>
Download All Resources
</Button>
</div>
<AccordionContent
className="flex w-full flex-col p-5"
style={{
backgroundColor: 'var( --base-pure-white)',
outline: '1px solid var( --base-pure-white)',
}}
>
Download All Resources
</Button>
</div>
<AccordionContent
className="flex w-full flex-col p-5"
style={{
backgroundColor: 'var( --base-pure-white)',
outline: '1px solid var( --base-pure-white)',
}}
>
<Table
columns={generateColumnData()}
rows={generateTableData(item.modelResources)}
hideFooter
/>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
)}
</div>
))
<Table
columns={generateColumnData()}
rows={generateTableData(item.modelResources)}
hideFooter
/>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
)}
</div>
)
)
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const DetailsQuery: any = graphql(`
description
id
name
chart
chart {
options
}
}
... on TypeResourceChartImage {
name
Expand Down Expand Up @@ -65,7 +67,7 @@ const Details = () => {
);
}

return <ReactECharts option={item.chart} ref={chartRef} />;
return <ReactECharts option={item.chart.options} ref={chartRef} />;
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Button, Spinner, Tag, Text } from 'opub-ui';
import { GraphQL } from '@/lib/api';
import { formatDate } from '@/lib/utils';

const datasetResourceQuery = graphql(`
const datasetResourceQuery: any = graphql(`
query datasetResources($datasetId: UUID!) {
datasetResources(datasetId: $datasetId) {
id
Expand All @@ -19,18 +19,7 @@ const datasetResourceQuery = graphql(`
type
name
description
accessModels {
name
description
type
modelResources {
fields {
format
fieldName
description
}
}
}

schema {
fieldName
id
Expand All @@ -47,7 +36,7 @@ const datasetResourceQuery = graphql(`
const Resources = () => {
const params = useParams();

const { data, isLoading } = useQuery(
const getResourceDetails: { data: any; isLoading: boolean } = useQuery(
[`resources_${params.datasetIdentifier}`],
() =>
GraphQL(
Expand Down Expand Up @@ -87,62 +76,68 @@ const Resources = () => {
}));
}
});
}, [data]);
}, [getResourceDetails.data]);

return (
<div className="w-full">
{isLoading ? (
{getResourceDetails.isLoading ? (
<div className="mt-8 flex justify-center">
<Spinner />
</div>
) : data && data?.datasetResources?.length > 0 ? (
) : getResourceDetails.data &&
getResourceDetails.data?.datasetResources?.length > 0 ? (
<>
<Text variant="bodyLg" className="mx-6 lg:mx-0">
Downloadable Resources
</Text>
<div className="mx-6 mt-5 flex flex-col gap-8 bg-surfaceDefault p-6 lg:mx-0">
{data?.datasetResources.map((item: any, index: number) => (
<div key={index} className="flex flex-wrap justify-between gap-4">
<div className="gap flex flex-col lg:w-4/5">
<div className="item flex items-center gap-2">
<Text variant="headingMd">{item.name}</Text>
<Tag>{item.fileDetails.format}</Tag>
{getResourceDetails.data?.datasetResources.map(
(item: any, index: number) => (
<div
key={index}
className="flex flex-wrap justify-between gap-4"
>
<div className="gap flex flex-col lg:w-4/5">
<div className="item flex items-center gap-2">
<Text variant="headingMd">{item.name}</Text>
<Tag>{item.fileDetails.format}</Tag>
</div>
<div>
<Text>Updated:</Text>
<Text>{formatDate(item.modified)}</Text>
</div>
<div className="flex flex-col">
<div
ref={(el) => (descriptionRefs.current[index] = el)}
className={!showMore[index] ? 'line-clamp-2' : ''}
>
<Text>{item.description}</Text>
</div>
{isDescriptionLong[index] && (
<Button
className="self-start p-2"
onClick={() => toggleShowMore(index)}
variant="interactive"
size="slim"
kind="tertiary"
>
{showMore[index] ? 'Show less' : 'Show more'}
</Button>
)}
</div>
</div>
<div>
<Text>Updated:</Text>
<Text>{formatDate(item.modified)}</Text>
</div>
<div className="flex flex-col">
<div
ref={(el) => (descriptionRefs.current[index] = el)}
className={!showMore[index] ? 'line-clamp-2' : ''}
<Link
href={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/resource/${item.id}`}
target="_blank"
className="flex justify-center"
>
<Text>{item.description}</Text>
</div>
{isDescriptionLong[index] && (
<Button
className="self-start p-2"
onClick={() => toggleShowMore(index)}
variant="interactive"
size="slim"
kind="tertiary"
>
{showMore[index] ? 'Show less' : 'Show more'}
</Button>
)}
<Button>Download</Button>
</Link>
</div>
</div>
<div>
<Link
href={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/resource/${item.id}`}
target="_blank"
className="flex justify-center"
>
<Button>Download</Button>
</Link>
</div>
</div>
))}
)
)}
</div>
</>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const getResourceChartImageDetails: any = graphql(`
}
`);


const getDatasetResourceChartImageDetails: any = graphql(`
query resourceChartImages($datasetId: UUID!) {
datasetResourceCharts(datasetId: $datasetId) {
Expand All @@ -55,9 +54,6 @@ const getDatasetResourceChartImageDetails: any = graphql(`
}
`);




const AddResourceChartimage: any = graphql(`
mutation GenerateResourceChartimage($dataset: UUID!) {
addResourceChartImage(dataset: $dataset) {
Expand All @@ -71,16 +67,18 @@ const AddResourceChartimage: any = graphql(`
`);

const UpdateChartImageMutation: any = graphql(`
mutation updateChartImage($data: ResourceChartImageInputPartial!) {
updateResourceChartImage(data: $data) {
mutation updateChartImage($input: ResourceChartImageInputPartial!) {
updateResourceChartImage(input: $input) {
__typename
... on TypeResourceChartImage {{}
id
name
description
image {
name
path
}
}
}
}
`);
Expand Down Expand Up @@ -126,7 +124,7 @@ const ChartsImage: React.FC<ImageProps> = ({
[params.entityType]: params.entitySlug,
},
{
datasetId: params.id
datasetId: params.id,
}
),
{}
Expand Down
Loading
Loading