From d4b90dbd6c1235489378e81ad3d2fe8537000cfb Mon Sep 17 00:00:00 2001 From: alfredorubin96 <103421036+alfredorubin96@users.noreply.github.com> Date: Fri, 16 Dec 2022 15:07:20 +0100 Subject: [PATCH] Changing card image download logic (#273) * feature(): Changing download logic for card download by downloading the entire card instead of just the view. This kind of change adds also the buttons to the downloaded image, that is not ideal. * fix(download report image): added missing ref for card expanded view * Removed package-lock.json Co-authored-by: Alfred Rubin Co-authored-by: Niels de Jong --- src/card/Card.tsx | 8 ++++++-- src/card/view/CardView.tsx | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/card/Card.tsx b/src/card/Card.tsx index 317260a44..1552bec3a 100644 --- a/src/card/Card.tsx +++ b/src/card/Card.tsx @@ -30,6 +30,7 @@ import { setReportHelpModalOpen } from '../application/ApplicationActions'; import { loadDatabaseListFromNeo4jThunk } from '../dashboard/DashboardThunks'; import { Neo4jContext, Neo4jContextState } from 'use-neo4j/dist/neo4j.context'; import { getDashboardExtensions } from '../dashboard/DashboardSelectors'; +import { downloadComponentAsImage } from '../chart/ChartUtils'; const NeoCard = ({ index, // index of the card. @@ -61,6 +62,8 @@ const NeoCard = ({ const [databaseList, setDatabaseList] = React.useState([database]); const [databaseListLoaded, setDatabaseListLoaded] = React.useState(false); + const ref = React.useRef(); + // fetching the list of databases from neo4j, filtering out the 'system' db useEffect(() => { if (!databaseListLoaded) { @@ -120,7 +123,7 @@ const NeoCard = ({
{/* The front of the card, referred to as the 'view' */} - + downloadComponentAsImage(ref)} query={report.query} globalParameters={globalParameters} fields={report.fields ? report.fields : []} @@ -199,7 +203,7 @@ const NeoCard = ({ // Look into React Portals: https://stackoverflow.com/questions/61432878/how-to-render-child-component-outside-of-its-parent-component-dom-hierarchy if (expanded) { return ( - + downloadComponentAsImage(ref)} + onDownloadImage={onDownloadImage} onToggleCardExpand={onToggleCardExpand} expanded={expanded} >