Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring a Neo4j Browser with a default custom GRASS style #171

Closed
dhimmel opened this issue May 26, 2016 · 18 comments
Closed

Configuring a Neo4j Browser with a default custom GRASS style #171

dhimmel opened this issue May 26, 2016 · 18 comments

Comments

@dhimmel
Copy link

dhimmel commented May 26, 2016

I've created a public read-only instance of our Neo4j database at http://neo4j.het.io/ (thanks @jexp for the help). I'd like to have a custom GRASS style applied to every browser instance by default.

On StackOverflow @ikwattro mentioned that:

The style is set in the browser local storage, I'm afraid all users will have to issue the :style command.

So I could always instruct users to run:

:style https://raw.githubusercontent.com/dhimmel/hetionet/383152be2c07f8f5427dd7069535c82b0c5e8d85/hetnet/neo4j/graphstyle.grass

Is there an automated workaround, so users don't have to execute this command? If not, then I'd like suggest a feature request to couple a specific Neo4j database with a custom style. It seems like styles make sense on a per database level, rather than a per browser level. Or perhaps on a per database per browser level, but with a database default.

@oskarhane
Copy link
Member

oskarhane commented May 26, 2016

Sure, you can set the server config

browser.post_connect_cmd=style https://raw.githubusercontent.com/dhimmel/hetionet/383152be2c07f8f5427dd7069535c82b0c5e8d85/hetnet/neo4j/graphstyle.grass

in the file neo4j.conf.

Untested, but should work.
Notice the lack of : before style because of the command character is a user setting so the browser takes care of prefixing that to the command.

@ikwattro
Copy link

ikwattro commented May 26, 2016

@oskarhane Wow that's very cool. Correct me if I'm wrong but there is no such setting in the operations manual ?

Anyway guys, this is awesome !

@oskarhane
Copy link
Member

@ikwattro you might be correct, it's a quite new feature: http://neo4j.com/release-notes/neo4j-3-0-1/
I'll put it on the docs teams wall. Thanks.

@ikwattro
Copy link

ikwattro commented May 26, 2016

Thanks, you guys rock ! Shame on me for not having checked the changelog

@dhimmel
Copy link
Author

dhimmel commented May 26, 2016

Thanks @oskarhane. The browser.post_connect_cmd setting in neo4j.conf is a great feature!. I've gotten browser.post_connect_cmd=play cypher to work and pre-play the cypher guide.

However, it looks like my style command from above doesn't work even when I run it directly from the browser. I'm guessing it could be a CORS issue (as with playing guides from URL in #170). However, the failure is silent. Assuming that reading from a URL is the cause of failure, is there a way to put the GRASS file inside of the Neo4j instance's directory structure and specify a local file with :style?

@oskarhane
Copy link
Member

oskarhane commented May 27, 2016

Yes, that's probably due to a CORS issue.
There's no supported way of loading a local grass file without user interaction.
Pretty ugly solution, but you could load grass by giving the :style command raw grass input.

:style

node {
  diameter: 50px;
  color: #A5ABB6;
  border-color: #9AA1AC;
  border-width: 2px;
  text-color-internal: #FFFFFF;
  font-size: 10px;
}

relationship {
  color: #A5ABB6;
  shaft-width: 1px;
  font-size: 8px;
  padding: 3px;
  text-color-external: #000000;
  text-color-internal: #FFFFFF;
  caption: '<type>';
}

node.Movie {
  color: #68BDF6;
  border-color: #5CA8DB;
  text-color-internal: #FFFFFF;
  caption: '{title}';
}

node.Person {
  color: #6DCE9E;
  border-color: #60B58B;
  text-color-internal: #FFFFFF;
  caption: '{name}';
}

To put that in the conf file you probably have to replace newlines with spaces.

@dhimmel
Copy link
Author

dhimmel commented May 27, 2016

Confirming that the failure to load the style from URL was a CORS issue. My web browser console picked up the following error:

XMLHttpRequest cannot load https://raw.githubusercontent.com/dhimmel/hetionet/383152be2c07f8f5427dd7069535c82b0c5e8d85/hetnet/neo4j/graphstyle.grass. Request header field Pragma is not allowed by Access-Control-Allow-Headers in preflight response.

I plan to proceed by applying one of the workarounds, but I think a way to preload a local grass file without user interaction would be good in the longterm.

Also confirming that the one line hack (see code snippet below) works. Therefore, if #172 gets implemented, configuration with a local grass file would be less pressing.

:style node {   diameter: 50px;   color: #A5ABB6;   border-color: #9AA1AC;   border-width: 1px;   text-color-internal: #FFFFFF;   font-size: 10px; }  relationship {   color: #A5ABB6;   shaft-width: 1.5px;   font-size: 8px;   padding: 3px;   text-color-external: #000000;   text-color-internal: #FFFFFF;   caption: '<type>'; }  node.Gene {   color: #0096FF;   border-color: #FFFFFF;   text-color-internal: #FFFFFF;   caption: '{name}'; }  node.Pathway {   color: #FF9300;   border-color: #FFFFFF;   text-color-internal: #000000;   caption: '{name}'; }  node.Anatomy {   color: #008F00;   border-color: #FFFFFF;   text-color-internal: #FFFFFF;   caption: '{name}'; }  node.Disease {   color: #8E4F00;   border-color: #FFFFFF;   text-color-internal: #FFFFFF;   caption: '{name}'; }  node.Compound {   color: #FF2600;   border-color: #FFFFFF;   text-color-internal: #FFFFFF;   caption: '{name}'; }  node.CellularComponent {   color: #FF9300;   border-color: #FFFFFF;   text-color-internal: #000000;   caption: '{name}'; }  node.BiologicalProcess {   color: #FF9300;   border-color: #FFFFFF;   text-color-internal: #000000;   caption: '{name}'; }  node.SideEffect {   color: #FFFB00;   border-color: #FFFFFF;   text-color-internal: #000000;   caption: '{name}'; }  node.Symptom {   color: #A5ABB6;   border-color: #FFFFFF;   text-color-internal: #FFFFFF;   caption: '{name}'; }  node.PharmacologicClass {   color: #FF85FF;   border-color: #FFFFFF;   text-color-internal: #FFFFFF;   caption: '{name}'; }  node.MolecularFunction {   color: #FF9300;   border-color: #FFFFFF;   text-color-internal: #000000;   caption: '{name}'; } 

dhimmel added a commit to dhimmel/neo4j-guides that referenced this issue Jun 10, 2016
Since there's no supported builtin way of loading a local grass file
(see neo4j/neo4j-browser#171), hosting grass files using the guide-extension
would be handy.
jexp pushed a commit to neo4j-contrib/neo4j-guides that referenced this issue Jun 10, 2016
Since there's no supported builtin way of loading a local grass file
(see neo4j/neo4j-browser#171), hosting grass files using the guide-extension
would be handy.
JanetMatsen added a commit to JanetMatsen/Neo4j_meta4 that referenced this issue Nov 7, 2016
Need to be able to color by node.
I think this will help: neo4j/neo4j-browser#171
@oskarhane
Copy link
Member

This looks like it's resolved, so I'll close this.

@Khazl
Copy link

Khazl commented Feb 7, 2018

I run neo4j Version: 3.3.2 in a docker container and tried to configure a default style as described above.

When i start my container with this config and run match (n) return n i see nothing.
Then i run :style http://domain.com/resources/style.grass and it works... Why?
That leads me to conclude that the grass file ifself (content) and the accessible of this file are not the problem.
It seems that there is an error with the default style configuration.
Do you have any tips to debug this? The logs are clean.

@chillier
Copy link

For Khazl and others: The solution is to strip carriage returns from style.grass file, (with no "play" command in the grass file). Then the config command has the "style" command -

browser.post_connect_cmd=style http://domain.com/resources/style.grass

You may will have to whitelist "domain.com" with a config statement.
browser.remote_content_hostname_whitelist=*
#(or domain.com)

@suchetaswabhav
Copy link

Hi,

Can you please tell me where can i find the neo4j.conf file. Because if i make it manually and insert like i did for .grass file and inserted it in favorites, the neo4j.conf file is not acceptable .

Error - .conf is not a valid extension.

@oskarhane
Copy link
Member

@suchetaswabhav The neo4j conf file is in the database directory, under the conf/ folder.

@suchetaswabhav
Copy link

suchetaswabhav commented Mar 25, 2019

I use the image file to open the Neo4j browser and database ..what to do ?

@suchetaswabhav
Copy link

Thanks oskarhane... i found out . You get it in Graph Applications tab - > Open folder -> configuration

@Evin686
Copy link

Evin686 commented Aug 22, 2019

Hi,guys
Is there a way to preload a local grass file? one line hack,doesn't seem to work

@TheRealMarcusChiu
Copy link

@Evin686 it probably broke because of this feature implementation #548

@FatihSarigol
Copy link

FatihSarigol commented Feb 10, 2022

Sure, you can set the server config

browser.post_connect_cmd=style https://raw.githubusercontent.com/dhimmel/hetionet/383152be2c07f8f5427dd7069535c82b0c5e8d85/hetnet/neo4j/graphstyle.grass

in the file neo4j.conf.

Untested, but should work. Notice the lack of : before style because of the command character is a user setting so the browser takes care of prefixing that to the command.

This is great but I just wanna make a remark here because importing grass file from some websites just doesn't work, I tried 1 https and 1 http server to host my grass file but both failed, finally I hoped that it would work from github rawfiles and it did. I don't know why the other servers did not work, I can LOAD CSV files from one of them to the same NEO4J browser for instance, but when it is a :style grassfile command it just didn't access the file, regardless of my permission for the server in conf settings.

by the way, calling the grass file from the neo4j/import directory also failed, and so did the one liner style trick inside the conf file

@Evin686
Copy link

Evin686 commented Feb 10, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants