From 19aa3e072259ad40eaea8b24d2497a516987ccb0 Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Sun, 20 Nov 2022 00:25:04 +0100 Subject: [PATCH] link graph --- graph/views.py | 3 ++- static/js/graph.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/graph/views.py b/graph/views.py index ca32da1..174e6ee 100644 --- a/graph/views.py +++ b/graph/views.py @@ -26,7 +26,8 @@ class Graph: "key": el.graphkey, "attributes": { "label": label, - "size": 10 + "size": 10, + "url": el.get_absolute_url() if hasattr(el, "get_absolute_url") else "/" } }) diff --git a/static/js/graph.ts b/static/js/graph.ts index f50289b..f93f7f1 100644 --- a/static/js/graph.ts +++ b/static/js/graph.ts @@ -41,6 +41,13 @@ if (container) { labelSize: 20, edgeLabelSize: 200, }); + + + renderer.on("clickNode", (e) => { + const url = graph.getNodeAttribute(e.node, "url") + window.open(url, 'graphURL') + + }) }