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

Added support to links on fields #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

perotta
Copy link

@perotta perotta commented Dec 2, 2022

This solves issue #20 and is a very simple (3 line solution).

the way to use it is by specifying a links array in the fields JSON

{ "edges_fields": [ { "field_name": "id", "type": "string" }, { "field_name": "source", "type": "string" }, { "field_name": "target", "type": "string" }, { "field_name": "mainStat", "type": "number" } ], "nodes_fields": [ { "field_name": "id", "type": "string", "links": [ { "title": "Section One/First Link", "url": "https://google.com/${__data.fields.title}" }, { "title": "Section One/Second Link", "url": "https://google.com" }, { "title": "Section One/Second Link", "url": "https://google.com" }, }, { "field_name": "title", "type": "string" }, { "field_name": "mainStat", "type": "string" }, { "field_name": "secondaryStat", "type": "number" }, { "color": "red", "field_name": "arc__failed", "type": "number" }, { "color": "green", "field_name": "arc__passed", "type": "number" }, { "displayName": "Role", "field_name": "detail__role", "type": "string" } ] }

This way it also supports all the internal links and stuff that Node Graph have on their example:
image

@perotta perotta mentioned this pull request Dec 2, 2022
@hoptical
Copy link
Owner

@perotta Thanks for your contribution and sorry for being very late in sending my feedback.
I'm reviewing it and will get back to you soon.

@perotta
Copy link
Author

perotta commented Feb 10, 2023

Hi @hoptical,

My implementation is pretty simple both on the changes and on how to use links on fields.

As I mention on the other issue, this is how I declare my fields (PHP code which will just json_encode this after to get a JSON):
image_2023-02-10_11-12-18

This PR solves issue #17

@zosocanuck
Copy link

@perotta Just curious if you can share your code (python?) as I'm also attempting to leverage the context menu to provide links for additional data about the node.

@perotta
Copy link
Author

perotta commented Mar 1, 2023

Hi @zosocanuck. The image above (#23 (comment)) is literally the code (PHP) that matters to declare links. Showing the rest of my code would be pointless as it just encodes the array to json using json_encode() function and writes the json to buffer on the HTTP response (nothing different from the other stuff this library does)

On the other end, this does require you to manually modify nodegraph-api-plugin to add these 4 lines
main...perotta:nodegraph-api-plugin:links-support
Then you need to create your own unsinged grafana plugin and load it into your grafana instance.

Unless @hoptical accepts this PR and publishes a new version on the official signed plugin, this is the only way to get the Links working.

@zosocanuck
Copy link

Hi @perotta I ended up forking a plugin with your PR however it had no impact. Here is my sample json:

{"edges_fields":[{"field_name":"id","type":"string"},{"field_name":"source","type":"string"},{"field_name":"target","type":"string"},{"field_name":"mainStat","type":"number"}],"nodes_fields":[{"field_name":"id","links":[{"title":"Section One/First Link","url":"https://myservice/info"}],"type":"string"},{"field_name":"title","type":"string"},{"field_name":"subTitle","type":"string"},{"field_name":"mainStat","type":"string"},{"field_name":"secondaryStat","type":"number"},{"color":"red","displayName":"Failed","field_name":"arc__failed","type":"number"},{"color":"green","displayName":"Passed","field_name":"arc__passed","type":"number"},{"displayName":"Role","field_name":"detail__role","type":"string"}]}

I'm using grafana v9.4.1, and not sure if that makes a difference.

@perotta
Copy link
Author

perotta commented Mar 1, 2023

Hi @perotta I ended up forking a plugin with your PR however it had no impact. Here is my sample json:

{"edges_fields":[{"field_name":"id","type":"string"},{"field_name":"source","type":"string"},{"field_name":"target","type":"string"},{"field_name":"mainStat","type":"number"}],"nodes_fields":[{"field_name":"id","links":[{"title":"Section One/First Link","url":"https://myservice/info"}],"type":"string"},{"field_name":"title","type":"string"},{"field_name":"subTitle","type":"string"},{"field_name":"mainStat","type":"string"},{"field_name":"secondaryStat","type":"number"},{"color":"red","displayName":"Failed","field_name":"arc__failed","type":"number"},{"color":"green","displayName":"Passed","field_name":"arc__passed","type":"number"},{"displayName":"Role","field_name":"detail__role","type":"string"}]}

I'm using grafana v9.4.1, and not sure if that makes a difference.

This looks like should be working to me. My final json looks essentially the same as yours and it works just find. The problem must be elsewhere?

No idea if it's your case, but for me it was a little tricky to get grafana to use my unsigned plugin instead of the official one

zosocanuck added a commit to zosocanuck/nodegraph-api-plugin that referenced this pull request Mar 2, 2023
@JulianJesacher
Copy link

Hey @hoptical , can we expect this feature to get merged soon? I would really need this too!

1 similar comment
@Chaos2Byte
Copy link

Hey @hoptical , can we expect this feature to get merged soon? I would really need this too!

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

Successfully merging this pull request may close these issues.

5 participants