softvis-research/jqa-dashboard

Relative context path

DirkMahler opened this issue · 3 comments

We're preparing an integration of the dashboard as a plugin of jQA, a project has been created in the jQA contrib area (https://github.com/jqassistant-contrib/jqassistant-dashboard-plugin). Therefore the embedded Neo4j server in jQA has been extended such that plugins can provide static resources (HTML/JS/CSS etc.) which are then available in a specific context path. For the dashboard plugin the proposed URL after starting the server is http://localhost:7474/jqassistant/dashboard.

During evaluation it turned out that the current implementation of the dashboard relies on accessing resources etc. in the root context, e.g. http://localhost:3000. Is there a chance to change this behaviour, e.g. by specifyfing a configuration containing a relative root path?

Hi @DirkMahler!

Thank you for your issue. I have already tested some things, but I'm not sure if we can come to the desired result. Your concern is more about deploying a Create-React-App (which Core UI uses) rather than the dashboard itself.

In the dashboard code itself, I could (as far as I know) only adapt the routes and there insert an additional path.
For example: http://localhost:3000/#/custom/dashboard
The "#" most likely comes from the internal React router. For this I found something under the keyword "hashHistory". I think this is used by default for CoreUI.

However, we probably can not solve the problem with customizations at these locations because resources are still loaded in the root context.
So I took a closer look at the build process (npm run build). This process uses the entry "homepage" in the package.json. For example, if you change this entry to "http://localhost/jqassistant/dashboard" and run "npm run build", you'll see the following message:
"The project was built assuming it is hosted at /jqassistant/dashboard/."
This should allow the mapping of relative paths.

In the root folder of the dashboard is then (as now after running the Dockerfile) the folder "build", which contains the complete build.
The interesting point is the deployment. How did you manage (if that already works) to get /jqassistant/ on port 7474? This port is already used by the neo4j browser.
I did't manage to call the dashboard on port 7474 using "serve" (for example, "serve -l 7474 -n -s build"). I hope that I can still learn from you there. :)

In principle, it should be possible to integrate the dashboard with the help of the "build" folder. I hope that I could help with this information.
Please keep me up to date if I misunderstood or overlooked something. I'm looking forward to your feedback.

Best regards
Tino

Hi @tmewes,

setting the path at build time probably already solves my problem, we'll give it a try.

Regarding port 7474: we implemented a Neo4j extension for jQAssistant that serves static content (i.e. it is served by the same HTTP server as for the Neo4j browser). The resouces (HTML/JS/CSS, etc.) must be available at a specific location in the classpath, namely META-INF/jqassistant-static-content. The plugin mentioned in the description of this ticket will make use of this mechanism by simply placing the built content of the dashboard there (see https://github.com/jqassistant-contrib/jqassistant-dashboard-plugin/tree/master/src/main/resources/META-INF/jqassistant-static-content/dashboard).

Hi @DirkMahler,

sorry for my late response. Thank you very much for your instructive answer.
I just reviewed and merged the great work from @SebastianWendorf, thank you for the improvements!

Hopefully you can run the dashboard in the plugin now. Please let me know if I can help you.
I'll close this issue for now.

Best regards
Tino