neo4j-labs / neodash

NeoDash - a Dashboard Builder for Neo4j
https://neo4j.com/labs/neodash/
Apache License 2.0
408 stars 135 forks source link

Show pictures whose urls are node properties #761

Closed gcthys closed 7 months ago

gcthys commented 7 months ago

I want to show pictures related to persons in my database. These pictures are stored on my website and a typical url would be https://tapitta.be/wp-content/uploads/I3mark_1.jpg This url is a property (i.url) of the pictures node i:Pictures:

MATCH (p:Producer)-[r:HAS_NAME_VARIANT]->(n:Name) WHERE n.NameID = $neodash_name_nameid OPTIONAL MATCH (p)-[r2:HAS_PICTURES]->(i:Pictures {type: "mark"}) RETURN i.url

Would it be possible to show these pictures, either in a markdown report, an iFrame or in any other way? Thanks.

jacobbleakley-neo4j commented 7 months ago

Hi gcthys, we use react markdown and as such the image url needs to be wrapped in the format ![image](url). (without the backslashes). When this is done, react markdown will identify the desired image format and display the image in your markdown. To achieve this, we can modify our cypher query. In your case it would look something like:

'MATCH (p:Producer)-[r:HAS_NAME_VARIANT]->(n:Name) WHERE n.NameID = $neodash_name_nameid OPTIONAL MATCH (p)-[r2:HAS_PICTURES]->(i:Pictures {type: "mark"}) RETURN '![Image](' + i.url + ')' AS imageUrl'

This might give you unwanted text on your markdown on top of your image if you feed the query directly into the markdown. To avoid this you can set the link as a global parameter (i.e. $neodash_image_link = '![Image](https://tapitta.be/wp-content/uploads/I3mark_1.jpg)', and feed $neodash_image_link into the markdown cypher editor.

I hope this helps. If you have any more issues, please let us know.

gcthys commented 7 months ago

Hi @jacobbleakley-neo4j , thanks for your suggestion. I follow you upto your point about the unwanted text on the markdown (which I dont want indeed). Can you tell me how to set all the links resulting from the query (we're talking about 100s and growing) as global parameters? As far as I understand, global parameters can only be set manually in the general settings, or did I miss something (as often happens :-).

jacobbleakley-neo4j commented 7 months ago

Global parameters can be set manually in the db, but also using report actions or parameter select. In your case I'd recommend looking into implementing report actions on a chart or table, i.e. create a table with one column of urls and one column of corresponding names, set up 'on-click cell containing url, set $neodash_parameterName to url. Then when you click on the cell of the link corresponding to the name you want to see, the image will appear in your markdown (providing the parameter name is specified in the markdown cypher editor) .

If you look into report actions, hopefully this will make sense. Please let us know if you require any more guidance or clarification.

gcthys commented 7 months ago

Hi @jacobbleakley-neo4j ,

That works perfectly! (I use report actions quite extensively but I never made the connection with parameters in markdown - as I wrote: I missed something again! :-) Thanks!

btw, you wouldn't have an equally magical solution to https://github.com/neo4j-labs/neodash/issues/549, would you?