Skip to content

Commit

Permalink
add double click on node
Browse files Browse the repository at this point in the history
  • Loading branch information
gkorland committed Jan 8, 2024
1 parent 66486f9 commit 1c605b7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/api/repo/[graph]/[node]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Graph, createClient } from "falkordb";
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest, { params }: { params: { graph: string, node: string } }) {

const graphId = params.graph;
const node = params.node;


const client = createClient({
url: process.env.FALKORDB_URL || 'redis://localhost:6379',
});
await client.connect();

const graph = new Graph(client, graphId);

// Get the node neighbors, the edges and their properties
let nodes = await graph.query(`MATCH ({name:'${node}'})-[]-(n) RETURN n`);
let edges = await graph.query(`MATCH ({name:'${node}'})-[e]-() RETURN e`);

return NextResponse.json({ id: graphId, nodes: nodes, edges: edges }, { status: 200 })
}
File renamed without changes.
24 changes: 24 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,30 @@ export default function Home() {
if (params.zoom) {
handleZoomClick(params.zoom)
}
},
dblclick: async (params: any) => {

let value = params?.data?.value;
if (!value) {
return
}
let node = JSON.parse(value)

fetch(`/api/repo/${graph.id}/${node.name}`, {
method: 'GET'
})
.then(response => response.json())
.then(data => {
let graph = extractData(data)
setGraph(graph)
})
.catch((error) => {
toast({
variant: "destructive",
title: "Uh oh! Something went wrong.",
description: error.message,
})
})
}
}}
/>
Expand Down

0 comments on commit 1c605b7

Please sign in to comment.