-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
165 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { Graph } from 'falkordb'; | ||
import { getServerSession } from "next-auth/next"; | ||
import authOptions, { connections } from "../../../auth/[...nextauth]/options"; | ||
|
||
export async function GET(request: NextRequest, { params }: { params: { graph: string, node: string } }) { | ||
|
||
const session = await getServerSession(authOptions) | ||
const id = session?.user?.id | ||
if (!id) { | ||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 }) | ||
} | ||
|
||
let client = connections.get(id) | ||
if (!client) { | ||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 }) | ||
} | ||
|
||
const nodeId = parseInt(params.node); | ||
const graphId = params.graph; | ||
|
||
const graph = new Graph(client, graphId); | ||
|
||
// Get node's neighbors | ||
const query = `MATCH (src)-[e]-(n) | ||
WHERE ID(src) = $nodeId | ||
RETURN e, n`; | ||
|
||
try { | ||
let result: any = await graph.query(query, { params: { nodeId: nodeId } }); | ||
return NextResponse.json({ result: result }, { status: 200 }) | ||
} catch (err: any) { | ||
return NextResponse.json({ message: err.message }, { status: 400 }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; | ||
import { Category, getCategoryColors } from "./model"; | ||
import { cn } from "@/lib/utils"; | ||
import { MinusCircle, Palette, PlusCircle } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
export function Labels(params: { categories: Category[], className?: string, onClick: (category: Category) => void }) { | ||
|
||
// fake stae to force reload | ||
const [reload, setReload] = useState(false) | ||
|
||
return ( | ||
<div className={cn("flex flex-row", params.className)} > | ||
<TooltipProvider> | ||
{params.categories.map((category) => { | ||
return ( | ||
<Tooltip key={category.index}> | ||
<TooltipTrigger | ||
className={`bg-${getCategoryColors(category.index)}-${category.show ? 500 : 200} rounded-lg border border-gray-300 p-2`} | ||
onClick={() => { | ||
params.onClick(category) | ||
setReload(!reload) | ||
}} | ||
> | ||
{ category.show ? <MinusCircle /> : <PlusCircle /> } | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>{category.name}</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
) | ||
})} | ||
</TooltipProvider> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters