diff --git a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/AccessModels/index.tsx b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/AccessModels/index.tsx index ec8dfd6b..c8724b66 100644 --- a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/AccessModels/index.tsx +++ b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/AccessModels/index.tsx @@ -1,116 +1,152 @@ import React from 'react'; +import { useParams } from 'next/navigation'; +import { graphql } from '@/gql'; +import { useQuery } from '@tanstack/react-query'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Button, + Spinner, Text, } from 'opub-ui'; +import { GraphQL } from '@/lib/api'; import CustomTags from '@/components/CustomTags'; import ResourceTable from '../../../components/ResourceTable'; -interface AccessModelProps { - data: any; -} - const generateColumnData = () => { return [ { accessorKey: 'resourceName', header: 'Resource Name', }, - { - accessorKey: 'fields', - header: 'Fields', - isModalTrigger: true, - label: 'Preview', - table: true, - modalHeader: 'Fields', - }, - { - accessorKey: 'rows', - header: 'Rows', - }, - { - accessorKey: 'count', - header: 'Count', - }, - { - accessorKey: 'preview', - header: 'Preview', - isModalTrigger: true, - label: 'Preview', - table: true, - modalHeader: 'Preview', + accessorKey: 'description', + header: 'Resource description', }, + // { + // accessorKey: 'fields', + // header: 'Fields', + // isModalTrigger: true, + // label: 'Preview', + // table: true, + // modalHeader: 'Fields', + // }, + // { + // accessorKey: 'rows', + // header: 'Rows', + // }, + // { + // accessorKey: 'count', + // header: 'Count', + // }, + // { + // accessorKey: 'preview', + // header: 'Preview', + // isModalTrigger: true, + // label: 'Preview', + // table: true, + // modalHeader: 'Preview', + // }, ]; }; -const generateTableData = (resource: any[]) => { - return resource.map((item: any) => ({ - resourceName: item.resourceName, - fields: item.fields, - preview: item.preview, - rows: item.rows, - count: item.count, +const generateTableData = (resources: any[]) => { + return resources.map((item: any) => ({ + resourceName: item.resource.name, + description: item.resource.description, + // fields: item.fields, + // preview: item.preview, + // rows: item.rows, + // count: item.count, })); }; -const AccessModels: React.FC = ({ data }) => { +const accessModelResourcesQuery = graphql(` + query accessModelResources($datasetId: UUID!) { + accessModelResources(datasetId: $datasetId) { + modelResources { + resource { + name + description + id + } + } + id + name + description + type + created + modified + } + } +`); + +const AccessModels = () => { + const params = useParams(); + + const { data, error, isLoading } = useQuery( + [`accessmodel_${params.datasetIdentifier}`], + () => + GraphQL(accessModelResourcesQuery, { + datasetId: params.datasetIdentifier, + }) + ); + return ( <> - {data.map((item: any, index: any) => ( -
-
-
- {item.title} + {isLoading ? ( +
+ +
+ ) : ( + data?.accessModelResources.map((item: any, index: any) => ( +
+
+
+ {item.name} +
+
+ {item.description} +
-
- {item.description} +
+ +
-
-
- - -
-
- - - - {/*
- -
*/} -
- See Resources -
-
- - {item.resource && item.resource.length > 0 && ( +
+ + + +
+ See Resources +
+
+ - )} - -
-
+ + + +
-
- ))} + )) + )} ); }; diff --git a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Metadata/index.tsx b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Metadata/index.tsx index 88247bd8..f8d53ef0 100644 --- a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Metadata/index.tsx +++ b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Metadata/index.tsx @@ -1,20 +1,15 @@ import React from 'react'; import { Button, Icon, Text } from 'opub-ui'; +import { formatDate, toTitleCase } from '@/lib/utils'; import { Icons } from '@/components/icons'; -interface Metadata { - metadata: any; -} - interface MetadataProps { - data: Metadata; + data: any; setOpen?: (isOpen: boolean) => void; } const MetadataComponent: React.FC = ({ data, setOpen }) => { - const { metadata } = data; - return ( <>
@@ -34,30 +29,21 @@ const MetadataComponent: React.FC = ({ data, setOpen }) => { )}
- {/*
*/} -
- Source - {metadata.source} -
-
- Location - {metadata.location} -
-
- Update - {metadata.update} -
+ {data?.metadata?.map((item: any, index: any) => ( +
+ + {toTitleCase(item.metadataItem.label)} + + {item.value} +
+ ))}
- Licence - {metadata.licence} + Created + {formatDate(data?.created)}
- Policy - {metadata.policy} -
-
- Organization - {metadata.organization} + Modified + {formatDate(data?.modified)}
diff --git a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/PrimaryData/index.tsx b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/PrimaryData/index.tsx index dc7b09a8..acb13641 100644 --- a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/PrimaryData/index.tsx +++ b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/PrimaryData/index.tsx @@ -9,32 +9,19 @@ const PrimaryData: React.FC = ({ data }) => { return ( <>
- {data.datasetTitle} + {data?.title}
{/* Tags :  */}
- {data.metadata.tags.map((item: any, index: any) => ( - {item.title} + {data?.tags.map((item: any, index: any) => ( + {item} ))}
- {data.description} + {data?.description}
- {/*
- Categories : -  {data.metadata.category} -
*/} - - {/*
- Formats :  -
- {data.metadata.formats.map((item: any, index: any) => ( - {item.type} - ))} -
-
*/} ); }; diff --git a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources/index.tsx b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources/index.tsx index 088b9cb4..fe486daf 100644 --- a/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources/index.tsx +++ b/app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources/index.tsx @@ -1,5 +1,8 @@ import { table } from 'console'; import React from 'react'; +import { useParams } from 'next/navigation'; +import { graphql } from '@/gql'; +import { useQuery } from '@tanstack/react-query'; import { Accordion, AccordionContent, @@ -7,16 +10,14 @@ import { AccordionTrigger, Button, Dialog, + Spinner, Table, Text, } from 'opub-ui'; +import { GraphQL } from '@/lib/api'; import ResourceTable from '../../../components/ResourceTable'; -interface ResourceProps { - data: any; -} - const generateColumnData = () => { return [ { @@ -66,77 +67,104 @@ const generateTableData = (accessModelData: any[]) => { })); }; -const Resources: React.FC = ({ data }) => { +const datasetResourceQuery = graphql(` + query datasetResources($datasetId: UUID!) { + datasetResources(datasetId: $datasetId) { + id + created + modified + type + name + description + } + } +`); + +const Resources = () => { + const params = useParams(); + + const { data, isLoading } = useQuery( + [`resources_${params.datasetIdentifier}`], + () => GraphQL(datasetResourceQuery, { datasetId: params.datasetIdentifier }) + ); + return ( <> - {data.map((item: any, index: any) => ( -
-
-
- {item.title} + {isLoading ? ( +
+ +
+ ) : ( + data?.datasetResources?.map((item: any, index: any) => ( +
+
+
+ {item.name} +
+
+ {item.description} +
-
- {item.description} +
+ + + + + + + + + +
+ + + +
+ See Access Type +
+
+ + {item.accessModelData && + item.accessModelData.length > 0 && ( + + )} + +
+
-
- - - - - -
- - - -
- - - -
- See Access Type -
-
- - {item.accessModelData && item.accessModelData.length > 0 && ( - - )} - -
-
-
- - ))} + )) + )} ); }; diff --git a/app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx b/app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx index 70928e97..39c9d899 100644 --- a/app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx +++ b/app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx @@ -2,9 +2,19 @@ import { useEffect, useRef, useState } from 'react'; import Image from 'next/image'; +import { useParams } from 'next/navigation'; import { graphql } from '@/gql'; import { useQuery } from '@tanstack/react-query'; -import { Button, Icon, Tab, TabList, TabPanel, Tabs, Tray } from 'opub-ui'; +import { + Button, + Icon, + Spinner, + Tab, + TabList, + TabPanel, + Tabs, + Tray, +} from 'opub-ui'; import { BarChart } from 'opub-ui/viz'; import { GraphQL } from '@/lib/api'; @@ -17,27 +27,44 @@ import PrimaryData from './components/PrimaryData'; import Resources from './components/Resources'; import Visualization from './components/Visualizations'; -const datasetQuery: any = graphql(` - query GetDatasetData { - dataset { +const datasetQuery = graphql(` + query datasets($filters: DatasetFilter) { + datasets(filters: $filters) { + tags id + title + description created modified + metadata { + metadataItem { + id + label + } + value + } + resources { + id + created + modified + type + name + description + } } } `); const DatasetDetailsPage = () => { - const DatasetInfo = datainfo[1]; const [open, setOpen] = useState(false); const primaryDataRef = useRef(null); // Explicitly specify the type of ref const [primaryDataHeight, setPrimaryDataHeight] = useState(0); - const { data, error, isLoading, refetch } = useQuery([], () => - GraphQL(datasetQuery, []) - ); + const params = useParams(); - console.log(data, error, isLoading); + const { data, isLoading } = useQuery([`${params.datasetIdentifier}`], () => + GraphQL(datasetQuery, { filters: { id: params.datasetIdentifier } }) + ); useEffect(() => { if (primaryDataRef.current) { @@ -50,12 +77,12 @@ const DatasetDetailsPage = () => { { label: 'Resources', value: 'resources', - component: , + component: , }, { label: 'Access Models', value: 'accessmodels', - component: , + component: , }, { label: 'Visualizations', @@ -65,10 +92,6 @@ const DatasetDetailsPage = () => { ]; const [activeTab, setActiveTab] = useState('resources'); // State to manage active tab - useEffect(() => { - refetch(); - }, [activeTab]); - const barOptions = { xAxis: { type: 'category', @@ -100,7 +123,13 @@ const DatasetDetailsPage = () => {
- + {isLoading ? ( +
+ +
+ ) : ( + + )}
{ } > - + {isLoading ? ( +
+ +
+ ) : ( + + )}
@@ -157,9 +195,16 @@ const DatasetDetailsPage = () => { Visualizations
-
- -
+ {isLoading ? ( +
+ +
+ ) : ( +
+ +
+ )} +
diff --git a/app/[locale]/(user)/datasets/components/Card/index.tsx b/app/[locale]/(user)/datasets/components/Card/index.tsx index 5c13de98..745c1203 100644 --- a/app/[locale]/(user)/datasets/components/Card/index.tsx +++ b/app/[locale]/(user)/datasets/components/Card/index.tsx @@ -7,7 +7,7 @@ import CustomTags from '@/components/CustomTags'; interface Dataset { datasetTitle: string; description: string; - id: number; + id: string; metadata: Metadata; } diff --git a/app/[locale]/(user)/datasets/data.tsx b/app/[locale]/(user)/datasets/data.tsx index ae3c4488..cdd26a66 100644 --- a/app/[locale]/(user)/datasets/data.tsx +++ b/app/[locale]/(user)/datasets/data.tsx @@ -1,6 +1,6 @@ export const data = [ { - id: 777, + id: 'f473c641-8c7e-4e3c-aa0a-16ca29505641', datasetTitle: 'Assam, India : Historical Weather Data : 2011-2020 - Guwahati(name may extend upto two lines after which ...)', description: @@ -35,7 +35,7 @@ export const data = [ }, }, { - id: 888, + id: '888', datasetTitle: 'Monthly Production of Petroleum Products by Refineries & Fractionators HVD of year 2023-2024', description: @@ -461,7 +461,7 @@ export const data = [ ], }, { - id: 999, + id: '999', datasetTitle: 'Assam, India : Historical Weather Data : 2011-2020 - Guwahati(name may extend upto two lines after which ...)', description: diff --git a/components/CustomTags.tsx b/components/CustomTags.tsx index bab93abb..2fb6f2a1 100644 --- a/components/CustomTags.tsx +++ b/components/CustomTags.tsx @@ -4,7 +4,7 @@ import { Icon, Text } from 'opub-ui'; import { Icons } from './icons'; interface TagProps { - type: 'open' | 'registered' | 'restricted' | string; + type: 'public' | 'protected' | 'private' | string; iconOnly?: boolean; size?: 24 | 40; background?: boolean; @@ -20,23 +20,24 @@ const CustomTags: React.FC = ({ let label; let iconName; let helpText; + switch (type.toLowerCase()) { - case 'open': + case 'public': bgColor = 'var(--base-green-solid-7)'; - label = 'OPEN ACCESS'; + label = 'PUBLIC ACCESS'; helpText = 'Can be downloaded directly'; iconName = Icons.openAccess; break; - case 'registered': + case 'protected': bgColor = 'var(--base-amber-solid-6)'; - label = 'REGISTERED ACCESS'; + label = 'PROTECTED ACCESS'; helpText = 'Register/ Login to download'; iconName = Icons.registeredAccess; break; - case 'restricted': + case 'private': bgColor = 'var(--base-red-solid-7)'; - label = 'RESTRICTED ACCESS'; + label = 'PRIVATE ACCESS'; helpText = 'Request access for download'; iconName = Icons.restrictedAccess; break; diff --git a/gql/generated/gql.ts b/gql/generated/gql.ts index 5c9fdbcd..4eda1e25 100644 --- a/gql/generated/gql.ts +++ b/gql/generated/gql.ts @@ -13,7 +13,9 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { - "\n query GetDatasetData {\n dataset {\n id\n created\n modified\n }\n }\n": types.GetDatasetDataDocument, + "\n query accessModelResources($datasetId: UUID!) {\n accessModelResources(datasetId: $datasetId) {\n modelResources {\n resource {\n name\n description\n id\n }\n }\n id\n name\n description\n type\n created\n modified\n }\n }\n": types.AccessModelResourcesDocument, + "\n query datasetResources($datasetId: UUID!) {\n datasetResources(datasetId: $datasetId) {\n id\n created\n modified\n type\n name\n description\n }\n }\n": types.DatasetResourcesDocument, + "\n query datasets($filters: DatasetFilter) {\n datasets(filters: $filters) {\n tags\n id\n title\n description\n created\n modified\n metadata {\n metadataItem {\n id\n label\n }\n value\n }\n resources {\n id\n created\n modified\n type\n name\n description\n }\n }\n }\n": types.DatasetsDocument, "\n mutation GenerateDatasetName {\n addDataset {\n __typename\n ... on TypeDataset {\n id\n created\n }\n ... on OperationInfo {\n messages {\n kind\n message\n }\n }\n }\n }\n": types.GenerateDatasetNameDocument, }; @@ -34,7 +36,15 @@ export function graphql(source: string): unknown; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query GetDatasetData {\n dataset {\n id\n created\n modified\n }\n }\n"): (typeof documents)["\n query GetDatasetData {\n dataset {\n id\n created\n modified\n }\n }\n"]; +export function graphql(source: "\n query accessModelResources($datasetId: UUID!) {\n accessModelResources(datasetId: $datasetId) {\n modelResources {\n resource {\n name\n description\n id\n }\n }\n id\n name\n description\n type\n created\n modified\n }\n }\n"): (typeof documents)["\n query accessModelResources($datasetId: UUID!) {\n accessModelResources(datasetId: $datasetId) {\n modelResources {\n resource {\n name\n description\n id\n }\n }\n id\n name\n description\n type\n created\n modified\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query datasetResources($datasetId: UUID!) {\n datasetResources(datasetId: $datasetId) {\n id\n created\n modified\n type\n name\n description\n }\n }\n"): (typeof documents)["\n query datasetResources($datasetId: UUID!) {\n datasetResources(datasetId: $datasetId) {\n id\n created\n modified\n type\n name\n description\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query datasets($filters: DatasetFilter) {\n datasets(filters: $filters) {\n tags\n id\n title\n description\n created\n modified\n metadata {\n metadataItem {\n id\n label\n }\n value\n }\n resources {\n id\n created\n modified\n type\n name\n description\n }\n }\n }\n"): (typeof documents)["\n query datasets($filters: DatasetFilter) {\n datasets(filters: $filters) {\n tags\n id\n title\n description\n created\n modified\n metadata {\n metadataItem {\n id\n label\n }\n value\n }\n resources {\n id\n created\n modified\n type\n name\n description\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/gql/generated/graphql.ts b/gql/generated/graphql.ts index 106abb37..fe706844 100644 --- a/gql/generated/graphql.ts +++ b/gql/generated/graphql.ts @@ -17,27 +17,63 @@ export type Scalars = { /** The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID. */ GlobalID: any; UUID: any; + Upload: any; }; +export type AccessModelInput = { + dataset: Scalars['UUID']; + description?: InputMaybe; + name: Scalars['String']; + resources: Array; + type: AccessTypes; +}; + +export type AccessModelResourceInput = { + resource: Scalars['UUID']; +}; + +export enum AccessTypes { + Private = 'PRIVATE', + Protected = 'PROTECTED', + Public = 'PUBLIC' +} + export type AddDatasetPayload = OperationInfo | TypeDataset; export type AddUpdateDatasetMetadataPayload = OperationInfo | TypeDataset; +export type CreateAccessModelPayload = OperationInfo | TypeAccessModel; + +export type CreateFileResourceInput = { + dataset: Scalars['UUID']; + files: Array; +}; + export type DsMetadataItemType = { id: Scalars['String']; value: Scalars['String']; }; +/** Dataset(id, title, description, organization, created, modified) */ +export type DatasetFilter = { + AND?: InputMaybe; + DISTINCT?: InputMaybe; + NOT?: InputMaybe; + OR?: InputMaybe; + id: Scalars['UUID']; +}; + export type DjangoModelType = { __typename?: 'DjangoModelType'; pk: Scalars['ID']; }; -/** Metadata(id, label, data_standard, urn, data_type, options, validator, type, model, enabled) */ +/** Metadata(id, label, data_standard, urn, data_type, options, validator, type, model, enabled, filterable) */ export type MetadataInput = { dataStandard?: InputMaybe; dataType: Scalars['String']; enabled?: InputMaybe; + filterable?: InputMaybe; id?: InputMaybe; label: Scalars['String']; model: Scalars['String']; @@ -47,11 +83,12 @@ export type MetadataInput = { validator?: InputMaybe; }; -/** Metadata(id, label, data_standard, urn, data_type, options, validator, type, model, enabled) */ +/** Metadata(id, label, data_standard, urn, data_type, options, validator, type, model, enabled, filterable) */ export type MetadataInputPartial = { dataStandard?: InputMaybe; dataType?: InputMaybe; enabled?: InputMaybe; + filterable?: InputMaybe; id: Scalars['GlobalID']; label?: InputMaybe; model?: InputMaybe; @@ -65,8 +102,13 @@ export type Mutation = { __typename?: 'Mutation'; addDataset: AddDatasetPayload; addUpdateDatasetMetadata: AddUpdateDatasetMetadataPayload; + createAccessModel: CreateAccessModelPayload; + createFileResources: Array; createMetadata: TypeMetadata; + deleteFileResource: Scalars['Boolean']; deleteMetadata: TypeMetadata; + updateDataset: UpdateDatasetPayload; + updateFileResource: UpdateFileResourcePayload; updateMetadata: TypeMetadata; }; @@ -76,16 +118,41 @@ export type MutationAddUpdateDatasetMetadataArgs = { }; +export type MutationCreateAccessModelArgs = { + accessModelInput: AccessModelInput; +}; + + +export type MutationCreateFileResourcesArgs = { + fileResourceInput: CreateFileResourceInput; +}; + + export type MutationCreateMetadataArgs = { data: MetadataInput; }; +export type MutationDeleteFileResourceArgs = { + resourceId: Scalars['UUID']; +}; + + export type MutationDeleteMetadataArgs = { data: NodeInput; }; +export type MutationUpdateDatasetArgs = { + updateDatasetInput: UpdateDatasetInput; +}; + + +export type MutationUpdateFileResourceArgs = { + fileResourceInput: UpdateFileResourceInput; +}; + + export type MutationUpdateMetadataArgs = { data: MetadataInputPartial; }; @@ -123,18 +190,63 @@ export enum OperationMessageKind { export type Query = { __typename?: 'Query'; - dataset: Array; + accessModelResources: Array; + datasetResources: Array; + datasets: Array; metadata: Array; + resource: Array; }; -/** Dataset(id, organization, created, modified) */ + +export type QueryAccessModelResourcesArgs = { + datasetId: Scalars['UUID']; +}; + + +export type QueryDatasetResourcesArgs = { + datasetId: Scalars['UUID']; +}; + + +export type QueryDatasetsArgs = { + filters?: InputMaybe; +}; + +/** AccessModel(id, name, description, dataset, type, organization, created, modified) */ +export type TypeAccessModel = { + __typename?: 'TypeAccessModel'; + created: Scalars['DateTime']; + dataset: DjangoModelType; + description: Scalars['String']; + id: Scalars['UUID']; + modelResources: Array; + modified: Scalars['DateTime']; + name: Scalars['String']; + organization?: Maybe; + type: Scalars['String']; +}; + +/** AccessModelResource(id, access_model, resource) */ +export type TypeAccessModelResource = { + __typename?: 'TypeAccessModelResource'; + accessModel: DjangoModelType; + id: Scalars['ID']; + resource: TypeResource; +}; + +/** Dataset(id, title, description, organization, created, modified) */ export type TypeDataset = { __typename?: 'TypeDataset'; + accessModels: Array; created: Scalars['DateTime']; + description: Scalars['String']; id: Scalars['UUID']; metadata: Array; modified: Scalars['DateTime']; organization?: Maybe; + resources: Array; + tags: Array; + title: Scalars['String']; }; /** DatasetMetadata(id, dataset, metadata_item, value) */ @@ -142,16 +254,17 @@ export type TypeDatasetMetadata = { __typename?: 'TypeDatasetMetadata'; dataset: DjangoModelType; id: Scalars['ID']; - metadataItem: DjangoModelType; + metadataItem: TypeMetadata; value: Scalars['String']; }; -/** Metadata(id, label, data_standard, urn, data_type, options, validator, type, model, enabled) */ +/** Metadata(id, label, data_standard, urn, data_type, options, validator, type, model, enabled, filterable) */ export type TypeMetadata = { __typename?: 'TypeMetadata'; dataStandard: Scalars['String']; dataType: Scalars['String']; enabled: Scalars['Boolean']; + filterable: Scalars['Boolean']; id: Scalars['ID']; label: Scalars['String']; model: Scalars['String']; @@ -161,15 +274,71 @@ export type TypeMetadata = { validator: Scalars['String']; }; +/** Resource(id, dataset, created, modified, type, name, description) */ +export type TypeResource = { + __typename?: 'TypeResource'; + created: Scalars['DateTime']; + dataset?: Maybe; + description: Scalars['String']; + id: Scalars['UUID']; + metadata: Array; + modified: Scalars['DateTime']; + name: Scalars['String']; + type: Scalars['String']; +}; + +/** ResourceMetadata(id, resource, metadata_item, value) */ +export type TypeResourceMetadata = { + __typename?: 'TypeResourceMetadata'; + id: Scalars['ID']; + metadataItem: TypeMetadata; + resource: DjangoModelType; + value: Scalars['String']; +}; + +export type UpdateDatasetInput = { + dataset: Scalars['UUID']; + description: Scalars['String']; + tags: Array; + title: Scalars['String']; +}; + +export type UpdateDatasetPayload = OperationInfo | TypeDataset; + +export type UpdateFileResourceInput = { + description?: InputMaybe; + file?: InputMaybe; + id: Scalars['UUID']; + name?: InputMaybe; +}; + +export type UpdateFileResourcePayload = OperationInfo | TypeResource; + export type UpdateMetadataInput = { dataset: Scalars['UUID']; metadata: Array; }; -export type GetDatasetDataQueryVariables = Exact<{ [key: string]: never; }>; +export type AccessModelResourcesQueryVariables = Exact<{ + datasetId: Scalars['UUID']; +}>; + + +export type AccessModelResourcesQuery = { __typename?: 'Query', accessModelResources: Array<{ __typename?: 'TypeAccessModel', id: any, name: string, description: string, type: string, created: any, modified: any, modelResources: Array<{ __typename?: 'TypeAccessModelResource', resource: { __typename?: 'TypeResource', name: string, description: string, id: any } }> }> }; + +export type DatasetResourcesQueryVariables = Exact<{ + datasetId: Scalars['UUID']; +}>; + + +export type DatasetResourcesQuery = { __typename?: 'Query', datasetResources: Array<{ __typename?: 'TypeResource', id: any, created: any, modified: any, type: string, name: string, description: string }> }; + +export type DatasetsQueryVariables = Exact<{ + filters?: InputMaybe; +}>; -export type GetDatasetDataQuery = { __typename?: 'Query', dataset: Array<{ __typename?: 'TypeDataset', id: any, created: any, modified: any }> }; +export type DatasetsQuery = { __typename?: 'Query', datasets: Array<{ __typename?: 'TypeDataset', tags: Array, id: any, title: string, description: string, created: any, modified: any, metadata: Array<{ __typename?: 'TypeDatasetMetadata', value: string, metadataItem: { __typename?: 'TypeMetadata', id: string, label: string } }>, resources: Array<{ __typename?: 'TypeResource', id: any, created: any, modified: any, type: string, name: string, description: string }> }> }; export type GenerateDatasetNameMutationVariables = Exact<{ [key: string]: never; }>; @@ -177,5 +346,7 @@ export type GenerateDatasetNameMutationVariables = Exact<{ [key: string]: never; export type GenerateDatasetNameMutation = { __typename?: 'Mutation', addDataset: { __typename: 'OperationInfo', messages: Array<{ __typename?: 'OperationMessage', kind: OperationMessageKind, message: string }> } | { __typename: 'TypeDataset', id: any, created: any } }; -export const GetDatasetDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDatasetData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"dataset"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"created"}},{"kind":"Field","name":{"kind":"Name","value":"modified"}}]}}]}}]} as unknown as DocumentNode; +export const AccessModelResourcesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accessModelResources"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"datasetId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessModelResources"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"datasetId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"datasetId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"modelResources"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"resource"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"created"}},{"kind":"Field","name":{"kind":"Name","value":"modified"}}]}}]}}]} as unknown as DocumentNode; +export const DatasetResourcesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"datasetResources"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"datasetId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"datasetResources"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"datasetId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"datasetId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"created"}},{"kind":"Field","name":{"kind":"Name","value":"modified"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}}]}}]}}]} as unknown as DocumentNode; +export const DatasetsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"datasets"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filters"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DatasetFilter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"datasets"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filters"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filters"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"tags"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"created"}},{"kind":"Field","name":{"kind":"Name","value":"modified"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"metadataItem"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"resources"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"created"}},{"kind":"Field","name":{"kind":"Name","value":"modified"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}}]}}]}}]}}]} as unknown as DocumentNode; export const GenerateDatasetNameDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"GenerateDatasetName"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addDataset"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TypeDataset"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"created"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"OperationInfo"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messages"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"kind"}},{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/lib/utils.ts b/lib/utils.ts index 9240697d..98440a99 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -13,6 +13,12 @@ export function formatDate(input: string | number): string { }); } +export function toTitleCase(str: string) { + return str.replace(/\b\w/g, function (char: string) { + return char.toUpperCase(); + }); +} + const convertMap: any = { border: (value: { width: any; style: any; color: any }) => { return `${value.width} ${value.style} ${value.color}`;