From ac7196abf6a3bc6a973b571974fa8ab0af0aec34 Mon Sep 17 00:00:00 2001 From: aashimgarg Date: Wed, 8 May 2024 23:36:52 +0530 Subject: [PATCH 1/4] allow multiple files in dropzone --- .../[id]/edit/components/DistributionList.tsx | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx index e082f3db..efbfa1fa 100644 --- a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx @@ -1,7 +1,10 @@ import React from 'react'; +import Link from 'next/link'; +import router from 'next/router'; import { Button, ButtonGroup, + Combobox, Divider, DropZone, Icon, @@ -40,21 +43,19 @@ const NoList = ({ const fileTypes = ['PDF', 'CSV', 'XLS', 'XLSX', 'TXT']; const [fileSelected, setFileSelected] = React.useState(false); - - const [file, setFile] = React.useState(); + const [file, setFile] = React.useState([]); const handleDropZoneDrop = React.useCallback( (_dropFiles: File[], acceptedFiles: File[]) => { - setFile(acceptedFiles[0]); + setFile((files) => [...files, ...acceptedFiles]); setFileSelected(true); }, [] ); - function handleFileDelete(props: React.MouseEvent) { - props.stopPropagation(); - setFileSelected(false); - setFile(undefined); + function handleFileDelete(index: any) { + const updatedFiles = [...file.slice(0, index), ...file.slice(index + 1)]; + setFile(updatedFiles); } const hint = ( @@ -76,42 +77,34 @@ const NoList = ({ ); - const fileUpload = !file && ; - const uploadedFile = file && ( -
-
- -
-
- - {file.name} - -
- - {bytesToSize(file.size)} - + const fileUpload = file.length === 0 && ( + + ); + const uploadedFile = file.length > 0 && ( +
+
+
+ +
{file[0].name.substring(0, 15) + ' ...'}
+ {file[0].size} bytes
-
); return ( - - {uploadedFile} - {fileUpload} - + <> + + {uploadedFile} + {fileUpload} + + ); }; From 5350a3fd1f32f6223d04006c15975648d248afe6 Mon Sep 17 00:00:00 2001 From: aashimgarg Date: Wed, 8 May 2024 23:56:02 +0530 Subject: [PATCH 2/4] add edit resource component --- .../[id]/edit/components/DistributionList.tsx | 31 ++- .../[id]/edit/components/EditResource.tsx | 190 ++++++++++++++++++ 2 files changed, 210 insertions(+), 11 deletions(-) create mode 100644 app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx index efbfa1fa..9b52784b 100644 --- a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx @@ -15,6 +15,7 @@ import { bytesToSize } from '@/lib/utils'; import { Icons } from '@/components/icons'; import { LinkButton } from '@/components/Link'; import { EditDistribution } from './EditDistribution'; +import { EditResource } from './EditResource'; export function DistributionList({ setPage, @@ -94,17 +95,25 @@ const NoList = ({ return ( <> - - {uploadedFile} - {fileUpload} - + {fileSelected ? ( + + ) : ( + + {uploadedFile} + {fileUpload} + + )} ); }; diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx new file mode 100644 index 00000000..a4cbf048 --- /dev/null +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx @@ -0,0 +1,190 @@ +import React from 'react'; +import Link from 'next/link'; +import GraphqlTable from '@/app/[locale]/dashboard/components/GraphqlTable/graphqlTable'; +import { IconTrash } from '@tabler/icons-react'; +import { + Button, + ButtonGroup, + Checkbox, + Combobox, + DataTable, + Divider, + DropZone, + Icon, + IconButton, + Text, + TextField, +} from 'opub-ui'; + +import { Icons } from '@/components/icons'; + +export const EditResource = ({ + uploadedFile, + handleDropZoneDrop, + file, +}: any) => { + const fileUpload = file.length === 0 && ; + + return ( +
+
+ Resource Name : +
+ +
+ + + + Go back to
+ Resource List +
+ + +
+ +
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ + {uploadedFile} + {fileUpload} + +
+
+
+
+ console.log('hi')}> + Enabel Preview + + +
+ +
+
+ + Select Rows to be
shown in the Preview +
+ + +
+
+
+ See Preview +
+
+
+ ); +}; From 51a46801798f66fa7e23964fd92a17c364c5b393 Mon Sep 17 00:00:00 2001 From: aashimgarg Date: Thu, 9 May 2024 00:00:12 +0530 Subject: [PATCH 3/4] add DATA_TABLE with rowActions --- .../[id]/edit/components/EditResource.tsx | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx index a4cbf048..0f47c451 100644 --- a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx @@ -25,6 +25,58 @@ export const EditResource = ({ }: any) => { const fileUpload = file.length === 0 && ; + const table = { + columns: [ + { + accessorKey: 'field_key', + header: 'FIELD KEY', + }, + { + accessorKey: 'display_name', + header: 'DISPLAY NAME', + }, + { + accessorKey: 'description', + header: 'DESCRIPTION', + }, + { + accessorKey: 'format', + header: 'FORMAT', + }, + ], + rows: [ + { + field_key: 'date', + display_name: 'Date', + description: 'Date on which measurements are taken', + format: 'Date', + }, + { + field_key: 'date', + display_name: 'Date', + description: 'Date on which measurements are taken', + format: 'Date', + }, + { + field_key: 'date', + display_name: 'Date', + description: 'Date on which measurements are taken', + format: 'Date', + }, + ], + }; + + const rowActions = [ + { + content: 'Delete', + destructive: true, + icon: IconTrash, + onAction: (e: any) => { + console.log(e, ' deleted'); + }, + }, + ]; + return (
@@ -185,6 +237,32 @@ export const EditResource = ({ See Preview
+
+ Fields in the Resource +
+ + Refetch Fields{' '} + + + + Reset Fields {' '} + + +
+
+ + The Field settings apply to the Resource on a master level and can not + be changed in Access Models. + +
+ +
); }; From 1f2ec91ab2a55c139998240020b4e73c76babd72 Mon Sep 17 00:00:00 2001 From: aashimgarg Date: Thu, 9 May 2024 00:14:46 +0530 Subject: [PATCH 4/4] add custom column action to data table --- .../[id]/edit/components/EditResource.tsx | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx index 0f47c451..7d6bd2a0 100644 --- a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx @@ -43,6 +43,19 @@ export const EditResource = ({ accessorKey: 'format', header: 'FORMAT', }, + { + header: 'DELETE', + cell: ({ row }: any) => ( + console.log(row.original) } + > + Delete + + ), + }, ], rows: [ { @@ -66,17 +79,6 @@ export const EditResource = ({ ], }; - const rowActions = [ - { - content: 'Delete', - destructive: true, - icon: IconTrash, - onAction: (e: any) => { - console.log(e, ' deleted'); - }, - }, - ]; - return (
@@ -256,7 +258,6 @@ export const EditResource = ({