Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat: rightPanel

dextmorgnfd4d528a06a7
diff --git a/flowsint-web/src/app/api/investigations/route.ts b/flowsint-web/src/app/api/latest-investigations/route.ts
similarity index 88%
rename from flowsint-web/src/app/api/investigations/route.ts
rename to flowsint-web/src/app/api/latest-investigations/route.ts
index ec577806..03af9081 100644
--- a/flowsint-web/src/app/api/investigations/route.ts
+++ b/flowsint-web/src/app/api/latest-investigations/route.ts
@@ -12,7 +12,7 @@ export async function GET() {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
const { data: investigations, error } = await supabase.from("investigations")
- .select("id, title, description, status, last_updated_at")
+ .select("id, title, description, status, project_id, last_updated_at, project:projects(id, name)")
.order("last_updated_at", { ascending: false })
.limit(4)
if (error) {
diff --git a/flowsint-web/src/app/api/projects/[project_id]/documents/route.ts b/flowsint-web/src/app/api/projects/[project_id]/documents/route.ts
index d953fa2c..35a2979b 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/documents/route.ts
+++ b/flowsint-web/src/app/api/projects/[project_id]/documents/route.ts
@@ -1,4 +1,5 @@
import { createClient } from "@/lib/supabase/server"
+import { formatFileSize } from "@/lib/utils";
import { NextResponse } from "next/server"
export async function GET(_: Request, { params }: { params: Promise<{ project_id: string }> }) {
@@ -37,7 +38,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ project_id
id: file.id,
name: file.name,
type: file.metadata.mimetype,
- size: file.metadata.size,
+ size: formatFileSize(file.metadata.size),
created_at: file.created_at,
last_updated_at: file.updated_at || file.created_at,
url: urlData?.signedUrl,
@@ -54,3 +55,23 @@ export async function GET(_: Request, { params }: { params: Promise<{ project_id
}
}
+
+export async function DELETE(request: Request, { params }: { params: Promise<{ project_id: string }> }) {
+ const { project_id: projectId } = await params
+ const { searchParams } = new URL(request.url)
+ const fileName = searchParams.get("fileName")
+ if (!fileName) {
+ return NextResponse.json({ error: "File name is required" }, { status: 400 })
+ }
+ try {
+ const supabase = await createClient()
+ const { error } = await supabase.storage.from("documents").remove([`${projectId}/${fileName}`])
+ if (error) {
+ throw error
+ }
+ return NextResponse.json({ success: true })
+ } catch (error) {
+ console.error("Error deleting document:", error)
+ return NextResponse.json({ error: "Failed to delete document" }, { status: 500 })
+ }
+}
\ No newline at end of file
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/data/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/data/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/data/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/data/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/emails/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/emails/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/emails/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/emails/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/individuals/[individual_id]/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/[individual_id]/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/individuals/[individual_id]/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/[individual_id]/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/individuals/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/individuals/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/ips/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/ips/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/ips/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/ips/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/phones/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/phones/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/phones/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/phones/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/route.ts
similarity index 79%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/route.ts
index b7f6d772..9b5c4cb2 100644
--- a/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts
+++ b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string, project_id: string }> }) {
+ const { investigation_id, project_id } = await params
try {
const supabase = await createClient()
const {
@@ -14,8 +14,9 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
}
const { data: investigation, error } = await supabase
.from("investigations")
- .select("id, title, description")
+ .select("id, title, description, last_updated_at, project_id, project:projects(id, name)")
.eq("id", investigation_id)
+ .eq("project_id", project_id)
.single()
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/scans/[scan_id]/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/[scan_id]/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/scans/[scan_id]/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/[scan_id]/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/scans/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/scans/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/route.ts
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/socials/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/socials/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/investigations/[investigation_id]/socials/route.ts
rename to flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/socials/route.ts
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/route.ts
new file mode 100644
index 00000000..03af9081
--- /dev/null
+++ b/flowsint-web/src/app/api/projects/[project_id]/investigations/route.ts
@@ -0,0 +1,26 @@
+import { createClient } from "@/lib/supabase/server"
+import { NextResponse } from "next/server"
+
+export async function GET() {
+ try {
+ const supabase = await createClient()
+ const {
+ data: { user },
+ error: userError,
+ } = await supabase.auth.getUser();
+ if (!user || userError) {
+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
+ }
+ const { data: investigations, error } = await supabase.from("investigations")
+ .select("id, title, description, status, project_id, last_updated_at, project:projects(id, name)")
+ .order("last_updated_at", { ascending: false })
+ .limit(4)
+ if (error) {
+ return NextResponse.json({ error: error.message }, { status: 500 })
+ }
+ return NextResponse.json(investigations)
+ } catch (error) {
+ return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
+ }
+}
+
diff --git a/flowsint-web/src/app/dashboard/keys/page.tsx b/flowsint-web/src/app/dashboard/keys/page.tsx
index 43fe2342..06fc6198 100644
--- a/flowsint-web/src/app/dashboard/keys/page.tsx
+++ b/flowsint-web/src/app/dashboard/keys/page.tsx
@@ -16,7 +16,7 @@ export default function TokensPage() {
])
return (
- <div className="space-y-12">
+ <div className="space-y-12 container mx-auto py-12 px-8">
<div>
<div className="flex justify-between items-start mb-4">
<div>
diff --git a/flowsint-web/src/app/dashboard/layout.tsx b/flowsint-web/src/app/dashboard/layout.tsx
index 388fadbb..7bca6243 100644
--- a/flowsint-web/src/app/dashboard/layout.tsx
+++ b/flowsint-web/src/app/dashboard/layout.tsx
@@ -22,12 +22,7 @@ const DashboardLayout = async ({
<SidebarProvider>
<AppSidebar user={data?.user} />
<SidebarInset>
- <header className="flex h-14 sticky top-0 bg-background/60 backdrop-blur border-b border-border justify-end shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
- <div className="flex items-center gap-2 px-4">
- <Button variant={"outline"}>Feedback</Button>
- </div>
- </header>
- <div className="flex flex-1 flex-col gap-4 container mx-auto py-12 px-8">
+ <div className="flex flex-1 flex-col gap-4">
{children}
</div>
</SidebarInset>
diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsx
index 483984eb..07fdcbb4 100644
--- a/flowsint-web/src/app/dashboard/page.tsx
+++ b/flowsint-web/src/app/dashboard/page.tsx
@@ -15,6 +15,7 @@ import Link from "next/link"
import { Project } from "@/types/project"
import RecentSketches from "@/components/dashboard/recent-sketches"
import NewProject from "@/components/dashboard/new-project"
+import { AvatarList } from "@/components/avatar-list"
const DashboardPage = () => {
const [searchQuery, setSearchQuery] = useState("")
@@ -36,7 +37,7 @@ const DashboardPage = () => {
)
return (
- <div className="w-full space-y-8">
+ <div className="w-full space-y-8 container mx-auto py-12 px-8">
<div>
<h1 className="text-3xl font-bold">Welcome back, Eliott</h1>
</div>
@@ -89,6 +90,7 @@ const DashboardPage = () => {
<TableHead>Owner</TableHead>
<TableHead className="hidden md:table-cell">Size</TableHead>
<TableHead className="hidden sm:table-cell">Last modified</TableHead>
+ <TableHead className="hidden sm:table-cell">Members</TableHead>
<TableHead className="hidden sm:table-cell">Creation</TableHead>
<TableHead className="w-[50px]"></TableHead>
</TableRow>
@@ -116,6 +118,9 @@ const DashboardPage = () => {
<TableCell className="hidden sm:table-cell text-muted-foreground">
{formatDistanceToNow(new Date(project.last_updated_at), { addSuffix: true })}
</TableCell>
+ <TableCell className="hidden sm:table-cell text-muted-foreground">
+ <AvatarList users={[{ id: "1", name: "Jean" }, { id: "2", name: "Eliott" }, { id: "4", name: "Marc" }, { id: "2", name: "Frank" }]} size="sm" />
+ </TableCell>
<TableCell className="hidden sm:table-cell text-muted-foreground">
{format(new Date(project.created_at), "dd.MM.yyyy")}
</TableCell>
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/client.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/client.tsx
similarity index 76%
rename from flowsint-web/src/app/investigations/[investigation_id]/client.tsx
rename to flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/client.tsx
index 4178fd3f..5fa0313d 100644
--- a/flowsint-web/src/app/investigations/[investigation_id]/client.tsx
+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/client.tsx
@@ -1,20 +1,21 @@
"use client"
import { useQuery } from "@tanstack/react-query"
-import InvestigationGraph from "@/components/investigations/graph"
-import LargeInvestigationGraph from '@/components/investigations/large-data-graph'
+import InvestigationGraph from "@/components/investigations/sketch/graph"
+import LargeInvestigationGraph from '@/components/investigations/sketch/large-data-graph'
import IndividualModal from "@/components/investigations/individual-modal"
import { notFound } from "next/navigation"
import { useQueryState } from "nuqs"
interface DashboardClientProps {
+ projectId: string
investigationId: string
}
-export default function DashboardClient({ investigationId }: DashboardClientProps) {
+export default function DashboardClient({ projectId, investigationId }: DashboardClientProps) {
// Use the initial data from the server, but enable background updates
const [view, _] = useQueryState("view", { defaultValue: "flow-graph" })
const graphQuery = useQuery({
queryKey: ["investigation", investigationId, "data"],
queryFn: async () => {
- const res = await fetch(`/api/investigations/${investigationId}/data`)
+ const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/data`)
if (!res.ok) {
notFound()
}
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/layout.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/layout.tsx
similarity index 79%
rename from flowsint-web/src/app/investigations/[investigation_id]/layout.tsx
rename to flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/layout.tsx
index 1ef72ce7..902ebf2b 100644
--- a/flowsint-web/src/app/investigations/[investigation_id]/layout.tsx
+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/layout.tsx
@@ -10,19 +10,19 @@ const DashboardLayout = async ({
params,
}: {
children: React.ReactNode;
- params: Promise<{ investigation_id: string }>
+ params: Promise<{ project_id: string, investigation_id: string }>
}) => {
const supabase = await createClient()
const { data, error: userError } = await supabase.auth.getUser()
if (userError || !data?.user) {
redirect('/login')
}
- const { investigation_id } = await (params)
+ const { project_id, investigation_id } = await (params)
return (
<InvestigationProvider>
<SearchProvider>
<ChatProvider>
- <InvestigationLayout user={data.user} investigation_id={investigation_id} left={<Left investigation_id={investigation_id} />}>
+ <InvestigationLayout user={data.user} investigation_id={investigation_id} left={<Left project_id={project_id} investigation_id={investigation_id} />}>
{children}
</InvestigationLayout>
</ChatProvider>
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/left.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/left.tsx
similarity index 91%
rename from flowsint-web/src/app/investigations/[investigation_id]/left.tsx
rename to flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/left.tsx
index 2f357f01..88606e3f 100644
--- a/flowsint-web/src/app/investigations/[investigation_id]/left.tsx
+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/left.tsx
@@ -10,7 +10,7 @@ import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { useState, useMemo } from "react"
-const Left = ({ investigation_id }: { investigation_id: string }) => {
+const Left = ({ project_id, investigation_id }: { project_id: string, investigation_id: string }) => {
const platformsIcons = usePlatformIcons()
const { currentNode, setCurrentNode } = useFlowStore()
const [filterValue, setFilterValue] = useState("")
@@ -22,7 +22,7 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {
phones,
socials,
refetchAll
- } = useInvestigationStore((state) => state.useInvestigationData(investigation_id))
+ } = useInvestigationStore((state) => state.useInvestigationData(project_id, investigation_id))
const { isRefetching } = useInvestigationStore()
// Filtrer les données
@@ -85,12 +85,12 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {
<li
className={cn(
"hover:bg-sidebar-accent text-sidebar-accent-foreground/90 hover:text-sidebar-accent-foreground text-sm truncate",
- currentNode === individual.id && "bg-sidebar-accent text-sidebar-accent-foreground",
+ currentNode?.id === individual.id && "bg-sidebar-accent text-sidebar-accent-foreground",
)}
key={individual.id}
>
<button
- onClick={() => setCurrentNode(individual.id)}
+ onClick={() => setCurrentNode(individual)}
className="flex items-center p-1 px-4 w-full gap-2 truncate"
>
<UserIcon className="h-3 w-3 opacity-60" />
@@ -118,11 +118,11 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {
<li
className={cn(
"hover:bg-sidebar-accent text-sidebar-accent-foreground/90 hover:text-sidebar-accent-foreground text-sm",
- currentNode === email.id && "bg-sidebar-accent text-sidebar-accent-foreground",
+ currentNode?.id === email.id && "bg-sidebar-accent text-sidebar-accent-foreground",
)}
key={email.id}
>
- <button onClick={() => setCurrentNode(email.id)} className="flex items-center p-1 px-4 w-full gap-2">
+ <button onClick={() => setCurrentNode(email)} className="flex items-center p-1 px-4 w-full gap-2">
<AtSignIcon className="h-3 w-3 opacity-60" />
{email.email}
</button>
@@ -147,11 +147,11 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {
<li
className={cn(
"hover:bg-sidebar-accent text-sidebar-accent-foreground/90 hover:text-sidebar-accent-foreground text-sm",
- currentNode === phone.id && "bg-sidebar-accent text-sidebar-accent-foreground",
+ currentNode?.id === phone.id && "bg-sidebar-accent text-sidebar-accent-foreground",
)}
key={phone.id}
>
- <button onClick={() => setCurrentNode(phone.id)} className="flex items-center p-1 px-4 w-full gap-2">
+ <button onClick={() => setCurrentNode(phone)} className="flex items-center p-1 px-4 w-full gap-2">
<PhoneIcon className="h-3 w-3 opacity-60" />
{phone.phone_number}
</button>
@@ -177,11 +177,11 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {
<li
className={cn(
"hover:bg-sidebar-accent text-sidebar-accent-foreground/90 hover:text-sidebar-accent-foreground text-sm",
- currentNode === social.id && "bg-sidebar-accent text-sidebar-accent-foreground",
+ currentNode?.id === social.id && "bg-sidebar-accent text-sidebar-accent-foreground",
)}
key={social.id}
>
- <button onClick={() => setCurrentNode(social.id)} className="flex items-center p-1 px-4 w-full gap-2">
+ <button onClick={() => setCurrentNode(social)} className="flex items-center p-1 px-4 w-full gap-2">
<span className="opacity-60">
{/* @ts-ignore */}
{platformsIcons?.[social.platform]?.icon}
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/loading.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/loading.tsx
similarity index 100%
rename from flowsint-web/src/app/investigations/[investigation_id]/loading.tsx
rename to flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/loading.tsx
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/page.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx
similarity index 76%
rename from flowsint-web/src/app/investigations/[investigation_id]/page.tsx
rename to flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx
index ace79f86..787c2b9b 100644
--- a/flowsint-web/src/app/investigations/[investigation_id]/page.tsx
+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx
@@ -6,10 +6,10 @@ import { createClient } from "@/lib/supabase/server"
const DashboardPage = async ({
params,
}: {
- params: Promise<{ investigation_id: string }>
+ params: Promise<{ project_id: string, investigation_id: string }>
}) => {
const supabase = await createClient()
- const { investigation_id } = await (params)
+ const { project_id, investigation_id } = await (params)
const {
data: { user },
error: userError,
@@ -21,7 +21,7 @@ const DashboardPage = async ({
if (!investigation || error) {
return notFound()
}
- return <DashboardClient investigationId={investigation_id} />
+ return <DashboardClient projectId={project_id} investigationId={investigation_id} />
}
export default DashboardPage
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx
index 0de696a0..c656010a 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx
+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx
@@ -40,7 +40,7 @@ const DashboardPage = () => {
})
return (
- <div className="w-full space-y-8">
+ <div className="w-full space-y-8 container mx-auto py-12 px-8">
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
@@ -116,7 +116,7 @@ const DashboardPage = () => {
project?.investigations?.map((investigation: Investigation) => (
<TableRow key={investigation.id}>
<TableCell>
- <Link href={`/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline">
+ <Link href={`/dashboard/projects/${investigation.project_id}/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline">
<Waypoints className="h-5 w-5 text-primary" />
<span>{investigation.title}</span>
</Link>
diff --git a/flowsint-web/src/app/error.tsx b/flowsint-web/src/app/error.tsx
index 9ed5104e..e260a7ef 100644
--- a/flowsint-web/src/app/error.tsx
+++ b/flowsint-web/src/app/error.tsx
@@ -1,31 +1,49 @@
-"use client";
+"use client"
-import { useEffect } from "react";
+import { useEffect } from "react"
+import { AlertCircle, RefreshCw } from "lucide-react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card"
export default function Error({
error,
reset,
}: {
- error: Error;
- reset: () => void;
+ error: Error & { digest?: string }
+ reset: () => void
}) {
useEffect(() => {
// Log the error to an error reporting service
- /* eslint-disable no-console */
- console.error(error);
- }, [error]);
+ console.error(error)
+ }, [error])
return (
- <div>
- <h2>Something went wrong!</h2>
- <button
- onClick={
- // Attempt to recover by trying to re-render the segment
- () => reset()
- }
- >
- Try again
- </button>
+ <div className="flex min-h-[50vh] items-center justify-center p-4">
+ <Card className="w-full max-w-md border-destructive/50 shadow-lg">
+ <CardHeader className="flex flex-row items-center gap-2 border-b pb-4">
+ <AlertCircle className="h-6 w-6 text-destructive" />
+ <h2 className="text-xl font-semibold">Une erreur est survenue</h2>
+ </CardHeader>
+ <CardContent className="pt-6">
+ <div className="space-y-4">
+ <p className="text-muted-foreground">
+ Nous sommes désolés, mais quelque chose s'est mal passé lors du chargement de cette page.
+ </p>
+ {error.digest && (
+ <div className="rounded-md bg-muted p-3">
+ <p className="text-sm font-mono">Code d'erreur: {error.digest}</p>
+ </div>
+ )}
+ </div>
+ </CardContent>
+ <CardFooter className="flex justify-end gap-2 pt-2">
+ <Button onClick={() => reset()} className="group flex items-center gap-2" variant="default">
+ <RefreshCw className="h-4 w-4 transition-transform group-hover:rotate-180" />
+ Réessayer
+ </Button>
+ </CardFooter>
+ </Card>
</div>
- );
+ )
}
+
diff --git a/flowsint-web/src/app/layout.tsx b/flowsint-web/src/app/layout.tsx
index f8904a43..980658db 100644
--- a/flowsint-web/src/app/layout.tsx
+++ b/flowsint-web/src/app/layout.tsx
@@ -50,7 +50,7 @@ export default function RootLayout({
<ConfirmContextProvider>
{children}
</ConfirmContextProvider>
- <Toaster />
+ <Toaster richColors/>
</TooltipProvider>
</main>
</Providers>
diff --git a/flowsint-web/src/components/avatar-list.tsx b/flowsint-web/src/components/avatar-list.tsx
new file mode 100644
index 00000000..25e797ca
--- /dev/null
+++ b/flowsint-web/src/components/avatar-list.tsx
@@ -0,0 +1,122 @@
+"use client"
+
+import type * as React from "react"
+import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
+import { cn } from "@/lib/utils"
+
+export interface User {
+ id: string
+ name: string
+ email?: string
+ image?: string
+}
+
+interface AvatarListProps extends React.HTMLAttributes<HTMLDivElement> {
+ users: User[]
+ /** Maximum number of avatars to display before showing the count */
+ maxCount?: number
+ /** Size of the avatars in pixels */
+ size?: "sm" | "md" | "lg"
+ /** Whether to show tooltips with user names */
+ showTooltips?: boolean
+}
+
+export function AvatarList({
+ users,
+ maxCount = 3,
+ size = "md",
+ showTooltips = true,
+ className,
+ ...props
+}: AvatarListProps) {
+ const visibleUsers = users.slice(0, maxCount)
+ const remainingCount = Math.max(0, users.length - maxCount)
+
+ const sizeClasses = {
+ sm: {
+ avatar: "h-6 w-6",
+ container: "space-x-[-8px]",
+ more: "h-6 w-6 text-xs",
+ },
+ md: {
+ avatar: "h-8 w-8",
+ container: "space-x-[-12px]",
+ more: "h-8 w-8 text-sm",
+ },
+ lg: {
+ avatar: "h-10 w-10",
+ container: "space-x-[-16px]",
+ more: "h-10 w-10 text-base",
+ },
+ }
+
+ const getInitials = (name: string) => {
+ return name
+ .split(" ")
+ .map((part) => part[0])
+ .join("")
+ .toUpperCase()
+ .substring(0, 2)
+ }
+
+ const renderAvatar = (user: User, index: number) => {
+ const avatar = (
+ <Avatar
+ key={user.id}
+ className={cn(
+ sizeClasses[size].avatar,
+ "border-2 border-background",
+ "transition-transform hover:translate-y-[-4px]",
+ "ring-0 ring-offset-0",
+ )}
+ >
+ <AvatarImage src={user.image} alt={`${user.name}'s avatar`} />
+ <AvatarFallback>{getInitials(user.name)}</AvatarFallback>
+ </Avatar>
+ )
+
+ if (showTooltips) {
+ return (
+ <TooltipProvider key={user.id} delayDuration={300}>
+ <Tooltip>
+ <TooltipTrigger asChild>{avatar}</TooltipTrigger>
+ <TooltipContent side="bottom" align="center">
+ {user.name}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )
+ }
+
+ return avatar
+ }
+
+ return (
+ <div className={cn("flex items-center", sizeClasses[size].container, className)} {...props}>
+ {visibleUsers.map(renderAvatar)}
+
+ {remainingCount > 0 && (
+ <TooltipProvider delayDuration={300}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Avatar
+ className={cn(
+ sizeClasses[size].more,
+ "border-2 border-background bg-muted",
+ "flex items-center justify-center font-medium text-muted-foreground",
+ )}
+ >
+ <span>+{remainingCount}</span>
+ </Avatar>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" align="center">
+ {remainingCount} more {remainingCount === 1 ? "user" : "users"}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
+ </div>
+ )
+}
+
diff --git a/flowsint-web/src/components/contexts/node-context.tsx b/flowsint-web/src/components/contexts/node-context.tsx
deleted file mode 100644
index 9eedbf9c..00000000
--- a/flowsint-web/src/components/contexts/node-context.tsx
+++ /dev/null
@@ -1,285 +0,0 @@
-"use client"
-import React, { createContext, useContext, ReactNode, useState, useCallback } from "react";
-import {
- Dialog,
- DialogClose,
- DialogContent,
- DialogDescription,
- DialogTitle,
-} from "@/components/ui/dialog"
-import { Input } from "@/components/ui/input"
-import { Button } from "@/components/ui/button";
-import { useParams } from "next/navigation";
-import { supabase } from "@/lib/supabase/client";
-import { useNodeId, useReactFlow } from "@xyflow/react";
-import { useConfirm } from "@/components/use-confirm-dialog";
-import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
-import { AlertCircle } from "lucide-react";
-import { NodeNotesEditor } from "../node-notes-editor";
-import { useFlowStore } from "@/store/flow-store";
-import { toast } from "sonner";
-
-interface NodeContextType {
- setOpenAddNodeModal: any,
- handleDuplicateNode: any,
- handleDeleteNode: any,
- loading: boolean,
- openNote: boolean,
- setOpenNote: any
-}
-
-const nodesTypes = {
- "emails": { table: "emails", type: "email", fields: ["email"] },
- "individuals": { table: "individuals", type: "individual", fields: ["full_name"] },
- "phone_numbers": { table: "phone_numbers", type: "phone", fields: ["phone_number"] },
- "ip_addresses": { table: "ip_addresses", type: "ip", fields: ["ip_address"] },
- "social_accounts_facebook": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:facebook"] },
- "social_accounts_instagram": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:instagram"] },
- "social_accounts_telegram": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:telegram"] },
- "social_accounts_snapchat": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:snapchat"] },
- "social_accounts_signal": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:signal"] },
- "social_accounts_github": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:github"] },
- "physical_addresses": { table: "physical_addresses", type: "address", fields: ["address", "city", "country", "zip"] },
-}
-
-const NodeContext = createContext<NodeContextType | undefined>(undefined);
-
-interface NodeProviderProps {
- children: ReactNode;
-}
-
-export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {
- const { addNodes, addEdges, setNodes, setEdges } = useReactFlow();
- const { investigation_id } = useParams()
- const [openAddNodeModal, setOpenNodeModal] = useState(false)
- const [error, setError] = useState<null | string>(null)
- const [openNote, setOpenNote] = useState(false)
- const [loading, setLoading] = useState(false)
- const [nodeType, setnodeType] = useState<any | null>(null)
- const nodeId = useNodeId();
- const { setCurrentNode } = useFlowStore()
- const { confirm } = useConfirm();
-
- const returnError = (message: string) => {
- setLoading(false)
- setError(message)
- return
- }
-
- const setOpenAddNodeModal = (e: { stopPropagation: () => void; }, tableName: string) => {
- e.stopPropagation()
- // @ts-ignore
- if (!nodesTypes[tableName]) return
- // @ts-ignore
- setnodeType(nodesTypes[tableName])
- setError(null)
- setOpenNodeModal(true)
- }
-
- const onSubmitNewNodeModal = async (e: { preventDefault: () => void; currentTarget: HTMLFormElement | undefined; }) => {
- e.preventDefault();
- const data = Object.fromEntries(new FormData(e.currentTarget));
- await handleAddNode(data);
- };
-
- const handleAddNode = async (
- data: any,
- ) => {
- try {
- setLoading(true)
-
- // Validate required data
- if (!nodeId) {
- toast.error("No node detected.")
- setLoading(false)
- return
- }
-
- // Prepare data for insertion
- const dataToInsert = { ...data, investigation_id }
- if (nodeType.table !== "individuals") {
- dataToInsert["individual_id"] = nodeId
- }
-
- // Insert the node
- const { data: nodeData, error: insertError } = await supabase
- .from(nodeType.table)
- .insert(dataToInsert)
- .select("*")
- .single()
-
- if (insertError) {
- toast.error(insertError.details)
- setLoading(false)
- return
- }
-
- if (!nodeData) {
- toast.error("Failed to create node.")
- setLoading(false)
- return
- }
-
- // Handle individuals table specific logic
- if (nodeType.table === "individuals") {
- // Create relation to investigation
- const { error: relationError } = await supabase.from("investigation_individuals").insert({
- individual_id: nodeData.id,
- investigation_id: investigation_id,
- })
-
- if (relationError) {
- toast.error("Error creating investigation relation:" + JSON.stringify(relationError))
- }
-
- // Create relationship between individuals
- const { error: relationshipError } = await supabase.from("relationships").upsert({
- individual_a: nodeId,
- individual_b: nodeData.id,
- relation_type: "relation",
- })
-
- if (relationshipError) {
- toast.error(relationshipError.details)
- }
- }
-
- // Add node to graph
- const newNode = {
- id: nodeData.id,
- type: nodeType.type,
- data: { ...nodeData, label: data[nodeType.fields[0]] },
- position: { x: 0, y: 0 },
- }
-
- addNodes(newNode)
-
- // Add edge if needed
- if (nodeId) {
- const newEdge = {
- source: nodeId,
- target: nodeData.id,
- type: "custom",
- id: `${nodeId}-${nodeData.id}`.toString(),
- label: nodeType.type === "individual" ? "relation" : nodeType.type,
- }
-
- addEdges(newEdge)
- }
-
- // Use a callback function with setState to ensure we're working with the latest state
- // This is the fix for the setCurrentNode issue
- const newNodeId = nodeData.id
-
- // Close modal and update state in a specific order
- setOpenNodeModal(false)
- setError(null)
-
- // Use setTimeout to ensure this happens after the current execution context
- // This helps with React's batching of state updates
- setTimeout(() => {
- setCurrentNode(newNodeId)
- setLoading(false)
- }, 0)
- } catch (error) {
- toast.error("An unexpected error occurred")
- setLoading(false)
- }
- }
-
-
-
- const handleDuplicateNode = async () => {
- await supabase.from("individuals")
- .select("*")
- .eq("id", nodeId)
- .single()
- .then(async ({ data, error }) => {
- if (error) throw error
- const { data: node, error: insertError } = await supabase.from("individuals")
- .insert({ full_name: data.full_name })
- .select("*")
- .single()
- if (insertError) toast.error(insertError.details)
- addNodes({
- id: node.id,
- type: "individual",
- data: node,
- position: { x: 0, y: -100 }
- });
- })
- }
-
- const handleDeleteNode = useCallback(async () => {
- if (!nodeId) return
- if (await confirm({ title: "Node deletion", message: "Are you sure you want to delete this node ?" })) {
- await supabase.from("individuals")
- .delete()
- .eq("id", nodeId)
- .then(({ error }) => {
- if (error) toast.error(error.details)
- })
- setNodes((nodes: any[]) => nodes.filter((node: { id: any; }) => node.id !== nodeId.toString()));
- setEdges((edges: any[]) => edges.filter((edge: { source: any; }) => edge.source !== nodeId.toString()));
- }
- }, [nodeId, setNodes, setEdges]);
-
- return (
- <NodeContext.Provider {...props} value={{ setOpenAddNodeModal, handleDuplicateNode, handleDeleteNode, loading, openNote, setOpenNote }}>
- {props.children}
- <Dialog open={openAddNodeModal && nodeType} onOpenChange={setOpenNodeModal}>
- <DialogContent>
- <DialogTitle>New {nodeType?.type}</DialogTitle>
- <DialogDescription>
- Add a new related {nodeType?.type}.
- </DialogDescription>
- <form onSubmit={onSubmitNewNodeModal}>
- <div className="flex flex-col ga-3">
- {nodeType?.fields.map((field: any, i: number) => {
- const [key, value] = field.split(":")
- return (
- <label key={i}>
- <p className="my-2">
- {key}
- </p>
- <Input
- defaultValue={value || ""}
- // disabled={Boolean(value)}
- name={key}
- placeholder={`Your value here (${key})`}
- />
- </label>
- )
- })}
- </div>
- {error &&
- <Alert variant="destructive">
- <AlertCircle className="h-4 w-4" />
- <AlertTitle>Error</AlertTitle>
- <AlertDescription>
- {error}
- </AlertDescription>
- </Alert>}
- <div className="flex items-center gap-2 justify-end mt-4">
- <DialogClose asChild>
- <Button type="button" variant="outline">
- Cancel
- </Button>
- </DialogClose>
- <Button disabled={loading} type="submit">Save</Button>
- </div>
- </form>
- </DialogContent>
- </Dialog>
- <NodeNotesEditor individualId={nodeId as string} />
- </NodeContext.Provider>
- );
-};
-
-export const useNodeContext = (): NodeContextType => {
- const context = useContext(NodeContext);
- if (!context) {
- throw new Error("useNodeContext must be used within a NodeProvider");
- }
- return context;
-};
\ No newline at end of file
diff --git a/flowsint-web/src/components/dashboard/recent-sketches.tsx b/flowsint-web/src/components/dashboard/recent-sketches.tsx
index 5c530456..a7ebcf7d 100644
--- a/flowsint-web/src/components/dashboard/recent-sketches.tsx
+++ b/flowsint-web/src/components/dashboard/recent-sketches.tsx
@@ -17,7 +17,7 @@ const RecentSketches = () => {
} = useQuery({
queryKey: ["dashboard", "investigations"],
queryFn: async () => {
- const res = await fetch(`/api/investigations`)
+ const res = await fetch(`/api/latest-investigations`)
return res.json()
},
refetchOnWindowFocus: true,
@@ -62,14 +62,14 @@ const RecentSketches = () => {
const randomIcon = placeholderIcons[Math.floor(Math.random() * placeholderIcons.length)]
return (
- <Link href={`/investigations/${investigation.id}`} key={investigation.id} className="group">
+ <Link href={`/dashboard/projects/${investigation.project_id}/investigations/${investigation.id}`} key={investigation.id} className="group">
<Card className="bg-transparent shadow-none h-full transition-all duration-200 border-none">
<div className={`flex items-center justify-center bg-foreground/5 h-40 border group-hover:border-primary/80 group-hover:border-2 rounded-md`}>
<div className="transform transition-transform group-hover:scale-105">{randomIcon}</div>
</div>
<CardContent className="p-4 relative">
<h3 className="font-medium line-clamp-1 group-hover:text-primary transition-colors">
- {investigation.title}
+ {investigation?.project?.name}/{investigation.title}
</h3>
<span className="text-xs opacity-60">Last updated {formatDistanceToNow(investigation.last_updated_at, { addSuffix: true })}</span>
</CardContent>
diff --git a/flowsint-web/src/components/investigations/case-selector.tsx b/flowsint-web/src/components/investigations/case-selector.tsx
index 94068afc..10892d8a 100644
--- a/flowsint-web/src/components/investigations/case-selector.tsx
+++ b/flowsint-web/src/components/investigations/case-selector.tsx
@@ -12,15 +12,15 @@ import { Skeleton } from "@/components/ui/skeleton";
export default function CaseSelector() {
const router = useRouter()
- const { investigation_id } = useParams()
+ const { investigation_id, project_id } = useParams()
const useInvestigationData = useInvestigationStore(
(state) => state.useInvestigationData
);
- const { investigations, isLoading } = useInvestigations()
- const { investigation } = useInvestigationData(investigation_id as string);
+ const { investigations, isLoading } = useInvestigations(project_id as string)
+ const { investigation } = useInvestigationData(project_id as string, investigation_id as string);
const handleSelectionChange = (value: string) => {
- router.push(`/investigations/${value}`);
+ router.push(`/dashboard/projects/${project_id}/investigations/${value}`);
};
return (
<div className="flex items-center">
diff --git a/flowsint-web/src/components/investigations/current-node-card.tsx b/flowsint-web/src/components/investigations/current-node-card.tsx
deleted file mode 100644
index e76617e7..00000000
--- a/flowsint-web/src/components/investigations/current-node-card.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
-import { Button } from "@/components/ui/button"
-import { Card, CardContent, CardHeader } from "@/components/ui/card"
-import { Phone, XIcon } from "lucide-react"
-import { useState } from "react"
-import { useInvestigationStore } from '@/store/investigation-store';
-
-interface PhoneNumber {
- id: string
- country: string | null
- phone_number: string
- individual_id: string
- investigation_id: string
-}
-
-interface Individual {
- id: string
- investigation_id: string
- full_name: string
- birth_date: string | null
- gender: string
- nationality: string
- notes: string
- image_url: string
- ip_addresses: string[]
- phone_numbers: PhoneNumber[]
-}
-
-interface CurrentNodeProps {
- individual: Partial<Individual>
-}
-
-export default function CurrentNode({ individual }: CurrentNodeProps) {
- const { handleOpenIndividualModal } = useInvestigationStore()
- const [show, setShow] = useState(true)
- if (!show) return
- return (
- <Card className="w-full max-w-sm overflow-hidden bg-background">
- <div className="h-24 bg-primary relative">
- <Button onClick={() => setShow(false)} className="text-white hover:text-white hover:bg-background/5 absolute top-2 right-2" size={"icon"} variant="ghost">
- <XIcon className="h-4 w-4" />
- </Button>
- </div>
- <div className="relative">
- <div className="absolute -top-12 left-1/2 -translate-x-1/2">
- <Avatar className="h-24 w-24 border-4 border-background">
- <AvatarImage src={individual.image_url} />
- <AvatarFallback className="bg-muted">
- <span className="text-3xl">{individual?.full_name?.[0]}</span>
- </AvatarFallback>
- </Avatar>
- </div>
- </div>
- <CardHeader className="mt-8 text-center">
- <h2 className="text-2xl font-bold">{individual.full_name}</h2>
- <p className="text-sm text-muted-foreground">{individual.notes || <span className="italic">No notes.</span>}</p>
- </CardHeader>
- <CardContent className="grid gap-4">
- {individual?.phone_numbers && individual?.phone_numbers?.length > 0 && (
- <div className="flex items-center gap-2 justify-center text-sm">
- <Phone className="h-4 w-4 text-muted-foreground" />
- {individual?.phone_numbers?.map((phone) => (
- <span key={phone.id}>{phone.phone_number}</span>
- ))}
- </div>
- )}
- <div className="flex gap-2 justify-center">
- <Button onClick={() => handleOpenIndividualModal(individual.id as string)}
- variant="outline">View Details</Button>
- {/* <Button>Contact</Button> */}
- </div>
- <div className="flex justify-between gap-8 text-sm text-muted-foreground border-t pt-4">
- <div className="text-center">
- <p className="font-medium">Nationality</p>
- <p>{individual.nationality || "N/A"}</p>
- </div>
- <div className="text-center">
- <p className="font-medium">Gender</p>
- <p>{individual.gender || "N/A"}</p>
- </div>
- <div className="text-center">
- <p className="font-medium">IPs</p>
- <p>{individual?.ip_addresses?.length}</p>
- </div>
- </div>
- </CardContent>
- </Card>
- )
-}
diff --git a/flowsint-web/src/components/investigations/individual-modal.tsx b/flowsint-web/src/components/investigations/individual-modal.tsx
index 9a1c46c1..c7303355 100644
--- a/flowsint-web/src/components/investigations/individual-modal.tsx
+++ b/flowsint-web/src/components/investigations/individual-modal.tsx
@@ -111,7 +111,7 @@ const IndividualModal = () => {
</div>
<div className="flex-grow w-full">
<Tabs defaultValue="overview" className="w-full">
- <TabsList className="overflow-x-auto w-full justify-start">
+ <TabsList className="overflow-hidden w-full justify-start">
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="social_account">
Social accounts
diff --git a/flowsint-web/src/components/investigations/layout.tsx b/flowsint-web/src/components/investigations/layout.tsx
index 9bbbdb7a..b3df61cc 100644
--- a/flowsint-web/src/components/investigations/layout.tsx
+++ b/flowsint-web/src/components/investigations/layout.tsx
@@ -15,6 +15,7 @@ import { AppSidebar } from '../app-sidebar';
import { SidebarProvider } from '../ui/sidebar';
import { ScanDrawer } from './scan-drawer';
import { ScanButton } from './scans-drawer/scan-button';
+import ProjectSelector from './project-selector';
const InvestigationLayout = ({
children,
@@ -29,10 +30,9 @@ const InvestigationLayout = ({
}) => {
const { panelOpen, setPanelOpen } = useInvestigationStore()
return (
- <SidebarProvider defaultOpen={false}>
- <AppSidebar user={user} />
- <PanelGroup autoSaveId="conditional" className='h-screen w-screen flex' direction="horizontal">
- {panelOpen && <Panel id="left" order={1} className='h-screen' defaultSize={20} minSize={10}>
+ <>
+ {/* <PanelGroup autoSaveId="conditional" className='h-screen w-screen flex' direction="horizontal"> */}
+ {/* {panelOpen && <Panel id="left" order={1} className='h-screen' defaultSize={20} minSize={10}>
<div className='flex flex-col w-full h-full rounded-none shadow-none border-r'>
<div className='w-full rounded-none shadow-none h-12 border-b flex items-center gap-1 flex-row justify-end p-2'>
<div className='flex gap-1'>
@@ -51,16 +51,16 @@ const InvestigationLayout = ({
</ScrollArea>
</div>
</Panel>}
- <PanelResizeHandle />
- <Panel id="right" order={2} defaultSize={90} minSize={50} className='grow flex flex-col'>
+ <PanelResizeHandle /> */}
+ {/* <Panel id="right" order={2} defaultSize={90} minSize={50} className='grow flex flex-col'> */}
<div>
<div className='w-full rounded-none shadow-none h-12 justify-between border-b flex flex-row items-center'>
<div className='grow flex items-center justify-between p-2'>
- <div className='flex gap-1 p-2'>
- <Button onClick={() => setPanelOpen(!panelOpen)} size="icon" variant="outline">
+ <div className='flex gap-1 items-center p-2'>
+ {/* <Button onClick={() => setPanelOpen(!panelOpen)} size="icon" variant="outline">
<PanelRightIcon className='h-4 w-4' />
- </Button>
- <CaseSelector />
+ </Button> */}
+ <ProjectSelector /><span className='opacity-60'>/</span><CaseSelector />
</div>
<MoreMenu />
</div>
@@ -70,10 +70,10 @@ const InvestigationLayout = ({
</div>
{children}
</div>
- </Panel>
+ {/* </Panel>
</PanelGroup >
- <ScanDrawer />
- </SidebarProvider>
+ <ScanDrawer /> */}
+ </>
)
}
diff --git a/flowsint-web/src/components/investigations/nodes/individual.tsx b/flowsint-web/src/components/investigations/nodes/individual.tsx
deleted file mode 100644
index 6aa7de8c..00000000
--- a/flowsint-web/src/components/investigations/nodes/individual.tsx
+++ /dev/null
@@ -1,277 +0,0 @@
-"use client"
-
-import { memo, useMemo, useCallback } from "react"
-// @ts-ignore
-import { Handle, NodeToolbar, Position, useStore } from "@xyflow/react"
-import { useInvestigationStore } from "@/store/investigation-store"
-import { NodeProvider, useNodeContext } from "@/components/contexts/node-context"
-import { useSearchContext } from "@/components/contexts/search-context"
-import { cn, zoomSelector } from "@/lib/utils"
-import { CopyButton } from "@/components/copy"
-import { useChatContext } from "@/components/contexts/chatbot-context"
-import { AtSign, Camera, Facebook, GithubIcon, Instagram, Locate, MapPin, MessageCircleDashed, Send, SquarePenIcon } from "lucide-react"
-import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
-import { Button } from "@/components/ui/button"
-import { Card } from "@/components/ui/card"
-import { Badge } from "@/components/ui/badge"
-import {
- ContextMenu,
- ContextMenuContent,
- ContextMenuItem,
- ContextMenuSeparator,
- ContextMenuSub,
- ContextMenuSubContent,
- ContextMenuSubTrigger,
- ContextMenuTrigger,
-} from "@/components/ui/context-menu"
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
-import { Edit, Phone, User, Zap } from "lucide-react"
-import { useFlowStore } from "@/store/flow-store"
-import { useQueryState } from "nuqs"
-
-// Composant optimisé pour les performances
-function Custom(props: any) {
- const { settings } = useInvestigationStore()
- const { currentNode } = useFlowStore()
- const { setOpenAddNodeModal, handleDuplicateNode, setOpenNote, handleDeleteNode, loading } = useNodeContext()
- const { handleOpenSearchModal } = useSearchContext()
- const { handleOpenChat } = useChatContext()
- // Utilisation d'un sélecteur d'égalité pour éviter les re-rendus inutiles
- const showContent = useStore(zoomSelector, (a, b) => a === b)
- const [_, setIndividualId] = useQueryState("individual_id")
- const { data } = props
-
- // Callbacks mémorisés pour éviter les recréations de fonctions
- const handleEditClick = useCallback(() => setIndividualId(data.id), [data.id, setIndividualId])
- const handleChatClick = useCallback(() => handleOpenChat(data), [data, handleOpenChat])
- const handleSearchClick = useCallback(
- () => handleOpenSearchModal(data.full_name),
- [data.full_name, handleOpenSearchModal],
- )
- const handleDuplicateClick = useCallback(() => handleDuplicateNode(), [handleDuplicateNode])
- const handleDeleteClick = useCallback(() => handleDeleteNode(data.type), [data.type, handleDeleteNode])
- const handleNoteClick = useCallback(() => setOpenNote(true), [setOpenNote])
- const handleDoubleClick = useCallback(() => setIndividualId(data.id), [data.id, setIndividualId])
-
- // Mémorisation des éléments UI complexes
- const nodeToolbar = useMemo(() => {
- if (!settings.showNodeToolbar) return null
-
- return (
- <NodeToolbar isVisible={data.forceToolbarVisible || undefined} position={Position.Top}>
- <Card className="p-1 rounded-full shadow-none backdrop-blur bg-background/40">
- <div className="flex gap-1">
- <Button variant="outline" className="rounded-full" size="sm" onClick={handleEditClick}>
- <Edit className="h-4 w-4 mr-2" />
- Edit
- </Button>
- <Button variant="outline" className="rounded-full" size="sm" onClick={handleChatClick}>
- <Zap className="h-4 w-4 mr-2 text-orange-500" />
- Ask AI
- </Button>
- </div>
- </Card>
- </NodeToolbar>
- )
- }, [settings.showNodeToolbar, data.forceToolbarVisible, handleEditClick, handleChatClick])
-
- // Mémorisation du contenu du nœud pour éviter les recalculs
- const nodeContent = useMemo(() => {
- if (settings.showNodeLabel && showContent) {
- return (
- <Card
- onDoubleClick={handleDoubleClick}
- className={cn(
- "p-1 border border-border hover:border-primary duration-100 rounded-lg shadow-none backdrop-blur bg-background/40",
- currentNode === data.id && "border-primary",
- )}
- >
- <div className="flex gap-2 items-center rounded-full">
- <Avatar className="h-9 w-9">
- <AvatarImage src={data?.image_url} alt={data.full_name} />
- <AvatarFallback>{loading ? "..." : data.full_name[0]}</AvatarFallback>
- </Avatar>
- {settings.showNodeLabel && showContent && (
- <div className="flex items-center gap-1">
- <span className="text-sm">{data.full_name}</span>
- {settings.showCopyIcon && <CopyButton className="rounded-full" content={data.full_name} />}
- </div>
- )}
- </div>
- </Card>
- )
- }
-
- return (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- onDoubleClick={handleDoubleClick}
- className={cn(
- "rounded-full border border-transparent hover:border-primary",
- currentNode === data.id && "border-primary",
- )}
- >
- <Avatar className="h-12 w-12">
- <AvatarImage src={data?.image_url} alt={data.full_name} />
- <AvatarFallback>
- <User className="h-4 w-4" />
- </AvatarFallback>
- </Avatar>
- </button>
- </TooltipTrigger>
- <TooltipContent>{data.full_name}</TooltipContent>
- </Tooltip>
- </TooltipProvider>
- )
- }, [settings.showNodeLabel, showContent, data, loading, currentNode, handleDoubleClick, settings.showCopyIcon])
-
- // Mémorisation des handles pour éviter les recalculs
- const handles = useMemo(
- () => (
- <>
- <Handle
- type="target"
- position={Position.Top}
- className={cn("w-16 bg-teal-500 opacity-0")}
- />
- <Handle
- type="source"
- position={Position.Bottom}
- className={cn("w-16 bg-teal-500 opacity-0")}
- />
- </>
- ),
- [showContent],
- )
-
- // Mémorisation du menu contextuel pour éviter les recalculs
- const contextMenuItems = useMemo(
- () => (
- <ContextMenuContent>
- <ContextMenuItem onClick={handleSearchClick}>Launch search</ContextMenuItem>
- <ContextMenuItem onClick={handleNoteClick}>
- New note
- <SquarePenIcon className="!h-4 !w-4" />
- </ContextMenuItem>
- <ContextMenuSub>
- <ContextMenuSubTrigger>New</ContextMenuSubTrigger>
- <ContextMenuSubContent>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "individuals")}>
- <User className="mr-2 h-4 w-4 opacity-70" /> New relation
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "phone_numbers", data.id)}>
- <Phone className="mr-2 h-4 w-4 opacity-70" />
- Phone number
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "physical_addresses", data.id)}>
- <MapPin className="mr-2 h-4 w-4 opacity-70" />
- Physical address
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "emails", data.id)}>
- <AtSign className="mr-2 h-4 w-4 opacity-70" />
- Email address
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "ip_addresses", data.id)}>
- <Locate className="mr-2 h-4 w-4 opacity-70" />
- IP address
- </ContextMenuItem>
- <ContextMenuSub>
- <ContextMenuSubTrigger>Social account</ContextMenuSubTrigger>
- <ContextMenuSubContent>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_facebook", data.id)}>
- <Facebook className="mr-2 h-4 w-4 opacity-70" />
- Facebook
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_instagram", data.id)}>
- <Instagram className="mr-2 h-4 w-4 opacity-70" />
- Instagram
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_telegram", data.id)}>
- <Send className="mr-2 h-4 w-4 opacity-70" />
- Telegram
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_signal", data.id)}>
- <MessageCircleDashed className="mr-2 h-4 w-4 opacity-70" />
- Signal
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_snapchat", data.id)}>
- <Camera className="mr-2 h-4 w-4 opacity-70" />
- Snapchat
- </ContextMenuItem>
- <ContextMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_github", data.id)}>
- <GithubIcon className="mr-2 h-4 w-4 opacity-70" />
- Github
- </ContextMenuItem>
- <ContextMenuItem disabled onClick={(e) => setOpenAddNodeModal(e, "social_accounts_coco", data.id)}>
- Coco{" "}
- <Badge variant="outline" className="ml-2">
- soon
- </Badge>
- </ContextMenuItem>
- </ContextMenuSubContent>
- </ContextMenuSub>
- </ContextMenuSubContent>
- </ContextMenuSub>
- <ContextMenuItem onClick={handleEditClick}>View and edit</ContextMenuItem>
- <ContextMenuItem onClick={handleDuplicateClick}>Duplicate</ContextMenuItem>
- <ContextMenuSeparator />
- <ContextMenuItem onClick={handleDeleteClick} className="text-red-600">
- Delete
- <span className="ml-auto text-xs text-muted-foreground">⌘ ⌫</span>
- </ContextMenuItem>
- </ContextMenuContent>
- ),
- [
- handleSearchClick,
- handleNoteClick,
- setOpenAddNodeModal,
- data.id,
- handleEditClick,
- handleDuplicateClick,
- handleDeleteClick,
- ],
- )
-
- return (
- <div style={{ ...props.style, borderRadius: "100000px!important" }}>
- {nodeToolbar}
- <ContextMenu>
- <ContextMenuTrigger
- onContextMenu={(e) => {
- e.stopPropagation()
- }}
- >
- <div className={cn(loading ? "opacity-40" : "opacity-100", "overflow-hidden group")}>
- {nodeContent}
- {handles}
- </div>
- </ContextMenuTrigger>
- {contextMenuItems}
- </ContextMenu>
- </div>
- )
-}
-
-// Utilisation de React.memo avec une fonction de comparaison personnalisée
-const IndividualNode = memo(
- (props: any) => (
- <NodeProvider>
- <Custom {...props} />
- </NodeProvider>
- ),
- (prevProps, nextProps) => {
- // Comparaison personnalisée pour éviter les re-rendus inutiles
- // Ne re-rendre que si les données importantes ont changé
- return (
- prevProps.id === nextProps.id &&
- prevProps.data.full_name === nextProps.data.full_name &&
- prevProps.data.image_url === nextProps.data.image_url &&
- prevProps.selected === nextProps.selected
- )
- },
-)
-
-export default IndividualNode
-
diff --git a/flowsint-web/src/components/investigations/project-selector.tsx b/flowsint-web/src/components/investigations/project-selector.tsx
new file mode 100644
index 00000000..61eccb5f
--- /dev/null
+++ b/flowsint-web/src/components/investigations/project-selector.tsx
@@ -0,0 +1,50 @@
+import { useInvestigations } from "@/lib/hooks/investigation/investigation";
+import { useInvestigationStore } from '@/store/investigation-store';
+import { useParams, useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select"
+import { Skeleton } from "@/components/ui/skeleton";
+import { useQuery } from "@tanstack/react-query";
+import { Project } from "@/types/project";
+
+export default function ProjectSelector() {
+ const router = useRouter()
+ const { project_id, investigation_id } = useParams()
+ const { data, isLoading } = useQuery({
+ queryKey: ["dashboard", "projects"],
+ queryFn: async () => {
+ const res = await fetch(`/api/projects`)
+ return res.json()
+ },
+ refetchOnWindowFocus: true,
+ })
+ const useInvestigationData = useInvestigationStore(
+ (state) => state.useInvestigationData
+ );
+ const { investigation } = useInvestigationData(project_id as string, investigation_id as string);
+ const projects = data?.projects || []
+
+ const handleSelectionChange = (value: string) => {
+ router.push(`/dashboard/projects/${value}`);
+ };
+ return (
+ <div className="flex items-center">
+ {isLoading || investigation.isLoading ? <Skeleton className="h-8 w-40 bg-foreground/10" /> :
+ <Select onValueChange={handleSelectionChange} defaultValue={investigation?.data?.project?.id}>
+ <SelectTrigger className="min-w-none w-full hover:bg-sidebar-accent shadow-none border-none text-ellipsis truncate gap-1">
+ <SelectValue defaultValue={investigation?.data?.title || ""} placeholder="Select an investigation" />
+ </SelectTrigger>
+ <SelectContent>
+ {projects?.map((project: Project) => (
+ <SelectItem className="text-ellipsis truncate" key={project.id} value={project.id}>{project.name}</SelectItem>
+ ))}
+ </SelectContent>
+ </Select >}
+ </div>
+ );
+}
diff --git a/flowsint-web/src/components/investigations/custom-edge.tsx b/flowsint-web/src/components/investigations/sketch/custom-edge.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/custom-edge.tsx
rename to flowsint-web/src/components/investigations/sketch/custom-edge.tsx
diff --git a/flowsint-web/src/components/investigations/floating-connection.tsx b/flowsint-web/src/components/investigations/sketch/floating-connection.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/floating-connection.tsx
rename to flowsint-web/src/components/investigations/sketch/floating-connection.tsx
diff --git a/flowsint-web/src/components/investigations/floating-edge.tsx b/flowsint-web/src/components/investigations/sketch/floating-edge.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/floating-edge.tsx
rename to flowsint-web/src/components/investigations/sketch/floating-edge.tsx
diff --git a/flowsint-web/src/components/investigations/graph.tsx b/flowsint-web/src/components/investigations/sketch/graph.tsx
similarity index 73%
rename from flowsint-web/src/components/investigations/graph.tsx
rename to flowsint-web/src/components/investigations/sketch/graph.tsx
index 06686740..5e5e0190 100644
--- a/flowsint-web/src/components/investigations/graph.tsx
+++ b/flowsint-web/src/components/investigations/sketch/graph.tsx
@@ -29,13 +29,9 @@ import {
PlusIcon,
GroupIcon,
WorkflowIcon,
- Trash2Icon,
- CopyIcon,
- EditIcon,
- LinkIcon,
} from "lucide-react"
import { useTheme } from "next-themes"
-import NewActions from "./new-actions"
+import NewActions from "../new-actions"
import FloatingConnectionLine from "./floating-connection"
import { useParams } from "next/navigation"
import { Tooltip, TooltipContent } from "@/components/ui/tooltip"
@@ -43,18 +39,19 @@ import { Button } from "@/components/ui/button"
import { TooltipTrigger } from "@radix-ui/react-tooltip"
import { cn } from "@/lib/utils"
import { useInvestigationStore } from "@/store/investigation-store"
-import { useFlowStore } from "../../store/flow-store"
-import Loader from "../loader"
+import { useFlowStore } from "../../../store/flow-store"
+import Loader from "../../loader"
import { useQueryState } from "nuqs"
-import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "../ui/context-menu"
-import AddNodeModal from "./add-node-modal"
-import { Dialog, DialogTrigger } from "../ui/dialog"
+import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "../../ui/context-menu"
+import AddNodeModal from "../add-node-modal"
+import { Dialog, DialogTrigger } from "../../ui/dialog"
import { memo } from "react"
import { shallow } from "zustand/shallow"
import FloatingEdge from "./simple-floating-edge"
import { TooltipProvider } from "@/components/ui/tooltip"
-
-// Define constants outside component to prevent recreation
+import NodeContextMenu from "./nodes/node-context-menu"
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
+import ProfilePanel from "./profile-panel"
const edgeTypes = {
custom: FloatingEdge,
}
@@ -90,85 +87,13 @@ const actionsSelector = (store: {
onLayout: store.onLayout,
})
-const stateSelector = (store: { currentNode: any; resetNodeStyles: any; reloading: any }) => ({
+const stateSelector = (store: { currentNode: any; setCurrentNode: any, resetNodeStyles: any; reloading: any }) => ({
currentNode: store.currentNode,
resetNodeStyles: store.resetNodeStyles,
reloading: store.reloading,
+ setCurrentNode: store.setCurrentNode,
})
-// Node Context Menu component
-interface NodeContextMenuProps {
- x: number
- y: number
- nodeId: string | null
- nodeType: string | null
- onClose: () => void
-}
-
-const NodeContextMenu = memo(({ x, y, nodeId, nodeType, onClose }: NodeContextMenuProps) => {
- if (!nodeId) return null
-
- const handleEditNode = () => {
- console.log(`Edit node ${nodeId} of type ${nodeType}`)
- onClose()
- }
-
- const handleDeleteNode = () => {
- console.log(`Delete node ${nodeId}`)
- onClose()
- }
-
- const handleDuplicateNode = () => {
- console.log(`Duplicate node ${nodeId}`)
- onClose()
- }
-
- const handleCreateConnection = () => {
- console.log(`Create connection from node ${nodeId}`)
- onClose()
- }
-
- return (
- <div
- className="absolute z-50 min-w-[80px] bg-popover text-popover-foreground rounded-md border shadow-md py-1 overflow-hidden"
- style={{ top: y, left: x }}
- >
- <div className="px-2 py-1.5 text-xs font-medium text-muted-foreground border-b">
- {nodeType?.toUpperCase()} NODE: {nodeId.slice(0, 8)}
- </div>
- <div className="py-1">
- <button
- className="w-full flex items-center gap-2 text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors"
- onClick={handleEditNode}
- >
- <EditIcon className="h-4 w-4" />
- Edit Node
- </button>
- <button
- className="w-full flex items-center gap-2 text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors"
- onClick={handleDeleteNode}
- >
- <Trash2Icon className="h-4 w-4" />
- Delete Node
- </button>
- <button
- className="w-full flex items-center gap-2 text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors"
- onClick={handleDuplicateNode}
- >
- <CopyIcon className="h-4 w-4" />
- Duplicate Node
- </button>
- <button
- className="w-full flex items-center gap-2 text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors"
- onClick={handleCreateConnection}
- >
- <LinkIcon className="h-4 w-4" />
- Create Connection
- </button>
- </div>
- </div>
- )
-})
interface FlowControlsProps {
onLayout: (direction: string, fitView: () => void) => void
@@ -179,13 +104,20 @@ interface FlowControlsProps {
zoomIn: () => void
zoomOut: () => void
addNodes: (payload: Node | Node[]) => void
+ currentNode: any | null | undefined
}
const FlowControls = memo(
- ({ onLayout, fitView, handleRefetch, reloading, setView, zoomIn, zoomOut, addNodes }: FlowControlsProps) => {
+ ({ onLayout, fitView, handleRefetch, reloading, setView, zoomIn, zoomOut, addNodes, currentNode }: FlowControlsProps) => {
return (
<>
- <Panel position="top-left" className="flex items-center gap-1 w-53">
+ <Panel position="top-left" className="flex flex-col items-center gap-1">
+ <NewActions addNodes={addNodes} />
+ <Button size="icon" disabled={reloading} variant="outline" onClick={handleRefetch}>
+ <RotateCwIcon className={cn("h-4 w-4", reloading && "animate-spin")} />
+ </Button>
+ </Panel>
+ <Panel position="bottom-left" className="flex flex-col items-center gap-1">
<Tooltip>
<TooltipTrigger asChild>
<Button
@@ -211,18 +143,6 @@ const FlowControls = memo(
</TooltipTrigger>
<TooltipContent>View 2D Graph</TooltipContent>
</Tooltip>
- </Panel>
- <Panel position="top-right" className="flex items-center gap-1">
- <div className="flex flex-col items-end gap-2">
- <div className="flex gap-1 items-center">
- <Button size="icon" disabled={reloading} variant="outline" onClick={handleRefetch}>
- <RotateCwIcon className={cn("h-4 w-4", reloading && "animate-spin")} />
- </Button>
- <NewActions addNodes={addNodes} />
- </div>
- </div>
- </Panel>
- <Panel position="bottom-left" className="flex flex-col items-center gap-1">
<Tooltip>
<TooltipTrigger asChild>
<Button size="icon" variant="outline" onClick={() => fitView()}>
@@ -248,6 +168,19 @@ const FlowControls = memo(
<TooltipContent>Zoom out</TooltipContent>
</Tooltip>
</Panel>
+ <Panel position="top-center" className="text-center">
+ <Tabs defaultValue="sketch">
+ <TabsList>
+ <TabsTrigger value="sketch">Sketch</TabsTrigger>
+ <TabsTrigger value="map" disabled>Map</TabsTrigger>
+ <TabsTrigger value="timeline" disabled>Timeline</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ </Panel>
+ {currentNode && (
+ <Panel position="top-right">
+ <ProfilePanel type={currentNode.type} data={currentNode.data} />
+ </Panel>)}
</>
)
},
@@ -270,6 +203,7 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
y: number
nodeId: string | null
nodeType: string | null
+ data: any
} | null>(null)
// Split store access to minimize re-renders
@@ -278,7 +212,7 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
actionsSelector,
shallow,
)
- const { currentNode, resetNodeStyles, reloading } = useFlowStore(stateSelector, shallow)
+ const { currentNode, setCurrentNode, resetNodeStyles, reloading } = useFlowStore(stateSelector, shallow)
// Initial layout
useEffect(() => {
@@ -303,7 +237,7 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
resetNodeStyles()
if (!currentNode) return
- const internalNode = getNode(currentNode)
+ const internalNode = getNode(currentNode.id)
if (!internalNode) return
useFlowStore.getState().updateNode(internalNode.id, {
@@ -329,13 +263,14 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
// Handle node context menu
const handleNodeContextMenu: NodeMouseHandler = useCallback((event, node) => {
- console.log(node, event)
+ setCurrentNode(node)
// Prevent default context menu
event.preventDefault()
setNodeContextMenu({
x: event.screenX - 200,
y: event.screenY - 150,
nodeId: node.id,
+ data: node.data,
nodeType: node.type || "default",
})
}, [])
@@ -390,9 +325,10 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
zoomOut={zoomOut}
// @ts-ignore
addNodes={addNodes}
+ currentNode={currentNode}
/>
<Background />
- {settings.showMiniMap && <MiniMap pannable />}
+ {settings.showMiniMap && <MiniMap className="!z-40" pannable />}
</ReactFlow>
</ContextMenuTrigger>
<ContextMenuContent className="w-32">
@@ -410,17 +346,11 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
</ContextMenu>
<AddNodeModal addNodes={addNodes} />
</Dialog>
-
- {/* Node-specific context menu */}
- {nodeContextMenu && (
- <NodeContextMenu
- x={nodeContextMenu.x}
- y={nodeContextMenu.y}
- nodeId={nodeContextMenu.nodeId}
- nodeType={nodeContextMenu.nodeType}
- onClose={closeNodeContextMenu}
- />
- )}
+ <NodeContextMenu
+ x={nodeContextMenu?.x}
+ y={nodeContextMenu?.y}
+ onClose={closeNodeContextMenu}
+ />
</TooltipProvider>
</div>
)
diff --git a/flowsint-web/src/components/investigations/large-data-graph.tsx b/flowsint-web/src/components/investigations/sketch/large-data-graph.tsx
similarity index 99%
rename from flowsint-web/src/components/investigations/large-data-graph.tsx
rename to flowsint-web/src/components/investigations/sketch/large-data-graph.tsx
index eacccab6..794979ec 100644
--- a/flowsint-web/src/components/investigations/large-data-graph.tsx
+++ b/flowsint-web/src/components/investigations/sketch/large-data-graph.tsx
@@ -6,8 +6,8 @@ import { Button } from "@/components/ui/button"
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from "@/components/ui/tooltip"
import { AlignCenterVertical, PencilRulerIcon, RotateCwIcon, ZoomInIcon, ZoomOutIcon } from "lucide-react"
import { useTheme } from "next-themes"
-import { useFlowStore } from "../../store/flow-store"
-import Loader from "../loader"
+import { useFlowStore } from "../../../store/flow-store"
+import Loader from "../../loader"
import { useQueryState } from "nuqs"
// @ts-ignore
import * as d3 from 'd3'
diff --git a/flowsint-web/src/components/investigations/nodes/email.tsx b/flowsint-web/src/components/investigations/sketch/nodes/email.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/nodes/email.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/email.tsx
diff --git a/flowsint-web/src/components/investigations/nodes/ip_address.tsx b/flowsint-web/src/components/investigations/sketch/nodes/ip_address.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/nodes/ip_address.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/ip_address.tsx
diff --git a/flowsint-web/src/components/investigations/sketch/nodes/node-context-menu.tsx b/flowsint-web/src/components/investigations/sketch/nodes/node-context-menu.tsx
new file mode 100644
index 00000000..f78aa248
--- /dev/null
+++ b/flowsint-web/src/components/investigations/sketch/nodes/node-context-menu.tsx
@@ -0,0 +1,359 @@
+"use client"
+import { Badge } from "@/components/ui/badge"
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+} from "@/components/ui/dropdown-menu"
+import {
+ AtSign,
+ Camera,
+ Facebook,
+ GithubIcon,
+ Instagram,
+ Locate,
+ MapPin,
+ MessageCircleDashed,
+ Phone,
+ Send,
+ SquarePenIcon,
+ User,
+} from "lucide-react"
+import { useQueryState } from "nuqs"
+import { memo, useCallback, useState } from "react"
+import { useParams } from "next/navigation"
+import { supabase } from "@/lib/supabase/client"
+import { useReactFlow } from "@xyflow/react"
+import { useConfirm } from "@/components/use-confirm-dialog"
+import { toast } from "sonner"
+import { useFlowStore } from "@/store/flow-store"
+import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog"
+import { Input } from "@/components/ui/input"
+import { Button } from "@/components/ui/button"
+import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"
+import { AlertCircle } from "lucide-react"
+import { NodeNotesEditor } from "./node-notes-editor"
+
+// Node types definition
+const nodesTypes = {
+ emails: { table: "emails", type: "email", fields: ["email"] },
+ individuals: { table: "individuals", type: "individual", fields: ["full_name"] },
+ phone_numbers: { table: "phone_numbers", type: "phone", fields: ["phone_number"] },
+ ip_addresses: { table: "ip_addresses", type: "ip", fields: ["ip_address"] },
+ social_accounts_facebook: {
+ table: "social_accounts",
+ type: "social",
+ fields: ["profile_url", "username", "platform:facebook"],
+ },
+ social_accounts_instagram: {
+ table: "social_accounts",
+ type: "social",
+ fields: ["profile_url", "username", "platform:instagram"],
+ },
+ social_accounts_telegram: {
+ table: "social_accounts",
+ type: "social",
+ fields: ["profile_url", "username", "platform:telegram"],
+ },
+ social_accounts_snapchat: {
+ table: "social_accounts",
+ type: "social",
+ fields: ["profile_url", "username", "platform:snapchat"],
+ },
+ social_accounts_signal: {
+ table: "social_accounts",
+ type: "social",
+ fields: ["profile_url", "username", "platform:signal"],
+ },
+ social_accounts_github: {
+ table: "social_accounts",
+ type: "social",
+ fields: ["profile_url", "username", "platform:github"],
+ },
+ physical_addresses: { table: "physical_addresses", type: "address", fields: ["address", "city", "country", "zip"] },
+}
+
+// Node Context Menu component
+interface NodeContextMenuProps {
+ x: number | undefined
+ y: number | undefined
+ onClose: () => void | null | undefined
+}
+
+const NodeContextMenu = memo(
+ ({ x, y, onClose }: NodeContextMenuProps) => {
+ const { currentNode, setCurrentNode } = useFlowStore()
+ const { addNodes, addEdges, setNodes, setEdges } = useReactFlow()
+ const { investigation_id } = useParams()
+ const [openAddNodeModal, setOpenNodeModal] = useState(false)
+ const [error, setError] = useState<null | string>(null)
+ const [openNote, setOpenNote] = useState(false)
+ const [loading, setLoading] = useState(false)
+ const [currentNodeType, setCurrentNodeType] = useState<any | null>(null)
+ const { confirm } = useConfirm()
+ const [_, setIndividualId] = useQueryState("individual_id")
+ const handleDuplicateNode = async () => {
+ if (!currentNode) return
+ await supabase
+ .from("individuals")
+ .select("*")
+ .eq("id", currentNode.id)
+ .single()
+ .then(async ({ data, error }) => {
+ if (error) throw error
+ const { data: node, error: insertError } = await supabase
+ .from("individuals")
+ .insert({ full_name: data.full_name })
+ .select("*")
+ .single()
+ if (insertError) toast.error(insertError.details)
+ addNodes({
+ id: node.id,
+ type: "individual",
+ data: node,
+ position: { x: 0, y: -100 },
+ })
+ })
+ }
+ const _handleDeleteNode = async (type: string) => {
+ if (!currentNode) return
+ if (await confirm({ title: "Node deletion", message: "Are you sure you want to delete this node?" })) {
+ await supabase
+ .from("individuals")
+ .delete()
+ .eq("id", currentNode.id)
+ .then(({ error }) => {
+ if (error) toast.error(error.details)
+ })
+ setNodes((nodes: any[]) => nodes.filter((node: { id: any }) => node.id !== currentNode?.id?.toString()))
+ setEdges((edges: any[]) => edges.filter((edge: { source: any }) => edge.source !== currentNode?.id?.toString()))
+ onClose()
+ toast.success("Node deleted.")
+ }
+ }
+ const handleDeleteNode = useCallback(_handleDeleteNode, [currentNode?.id, setNodes, setEdges, confirm, onClose])
+ const setOpenAddNodeModal = (e: { stopPropagation: () => void }, tableName: string, individualId?: string) => {
+ e.stopPropagation()
+ if (!currentNode) return
+ if (!nodesTypes[tableName as keyof typeof nodesTypes]) {
+ toast.error("Invalid node type.")
+ return
+ }
+ setCurrentNodeType(nodesTypes[tableName as keyof typeof nodesTypes])
+ setError(null)
+ setOpenNodeModal(true)
+ }
+ const onSubmitNewNodeModal = async (e: {
+ preventDefault: () => void
+ currentTarget: HTMLFormElement | undefined
+ }) => {
+ e.preventDefault()
+ const data = Object.fromEntries(new FormData(e.currentTarget))
+ await handleAddNode(data)
+ }
+ const handleAddNode = async (data: any) => {
+ try {
+ setLoading(true)
+ if (!currentNode) {
+ toast.error("No node detected.")
+ setLoading(false)
+ return
+ }
+ const dataToInsert = { ...data, investigation_id }
+ if (currentNodeType.table !== "individuals") {
+ dataToInsert["individual_id"] = currentNode.id
+ }
+ const { data: nodeData, error: insertError } = await supabase
+ .from(currentNodeType.table)
+ .insert(dataToInsert)
+ .select("*")
+ .single()
+ if (insertError) {
+ toast.error(insertError.details)
+ setLoading(false)
+ return
+ }
+ if (!nodeData) {
+ toast.error("Failed to create node.")
+ setLoading(false)
+ return
+ }
+ if (currentNodeType.table === "individuals") {
+ // Create relation to investigation
+ const { error: relationError } = await supabase.from("investigation_individuals").insert({
+ individual_id: nodeData.id,
+ investigation_id: investigation_id,
+ })
+ if (relationError) {
+ toast.error("Error creating investigation relation:" + JSON.stringify(relationError))
+ }
+ const { error: relationshipError } = await supabase.from("relationships").upsert({
+ individual_a: currentNode.id,
+ individual_b: nodeData.id,
+ relation_type: "relation",
+ })
+ if (relationshipError) {
+ toast.error(relationshipError.details)
+ }
+ }
+ const newNode = {
+ id: nodeData.id,
+ type: currentNodeType.type,
+ data: { ...nodeData, label: data[currentNodeType.fields[0]] },
+ position: { x: 0, y: 0 },
+ }
+ addNodes(newNode)
+ if (currentNode.id) {
+ const newEdge = {
+ source: currentNode.id as string,
+ target: nodeData.id,
+ type: "custom",
+ id: `${currentNode.id}-${nodeData.id}`.toString(),
+ label: currentNodeType.type === "individual" ? "relation" : currentNodeType.type,
+ }
+ addEdges(newEdge)
+ }
+ setOpenNodeModal(false)
+ setError(null)
+ setTimeout(() => {
+ setCurrentNode(nodeData)
+ setLoading(false)
+ }, 0)
+ } catch (error) {
+ toast.error("An unexpected error occurred")
+ setLoading(false)
+ }
+ }
+ const handleEditClick = useCallback(() => setIndividualId(currentNode?.id as string), [currentNode?.id, setIndividualId])
+ const handleDuplicateClick = useCallback(() => handleDuplicateNode(), [])
+ const handleDeleteClick = useCallback(() => handleDeleteNode(currentNode?.type as string), [currentNode?.type, handleDeleteNode])
+ const handleNoteClick = useCallback(() => setOpenNote(true), [setOpenNote])
+ if (!currentNode) return null
+ return (
+ <>
+ <DropdownMenu open={Boolean(currentNode) && Boolean(x) && Boolean(y)} onOpenChange={onClose}>
+ <DropdownMenuContent
+ className="absolute z-50 min-w-40 max-w-48 bg-popover text-popover-foreground rounded-md border shadow-md py-1 overflow-hidden"
+ style={{ top: y, left: x }}
+ >
+ <DropdownMenuItem onClick={handleNoteClick}>
+ New note
+ <SquarePenIcon className="!h-4 !w-4" />
+ </DropdownMenuItem>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>New</DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "individuals")}>
+ <User className="mr-2 h-4 w-4 opacity-70" /> New relation
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "phone_numbers", currentNode.id)}>
+ <Phone className="mr-2 h-4 w-4 opacity-70" />
+ Phone number
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "physical_addresses", currentNode.id)}>
+ <MapPin className="mr-2 h-4 w-4 opacity-70" />
+ Physical address
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "emails", currentNode.id)}>
+ <AtSign className="mr-2 h-4 w-4 opacity-70" />
+ Email address
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "ip_addresses", currentNode.id)}>
+ <Locate className="mr-2 h-4 w-4 opacity-70" />
+ IP address
+ </DropdownMenuItem>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>Social account</DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_facebook", currentNode.id)}>
+ <Facebook className="mr-2 h-4 w-4 opacity-70" />
+ Facebook
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_instagram", currentNode.id)}>
+ <Instagram className="mr-2 h-4 w-4 opacity-70" />
+ Instagram
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_telegram", currentNode.id)}>
+ <Send className="mr-2 h-4 w-4 opacity-70" />
+ Telegram
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_signal", currentNode.id)}>
+ <MessageCircleDashed className="mr-2 h-4 w-4 opacity-70" />
+ Signal
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_snapchat", currentNode.id)}>
+ <Camera className="mr-2 h-4 w-4 opacity-70" />
+ Snapchat
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={(e) => setOpenAddNodeModal(e, "social_accounts_github", currentNode.id)}>
+ <GithubIcon className="mr-2 h-4 w-4 opacity-70" />
+ Github
+ </DropdownMenuItem>
+ <DropdownMenuItem disabled onClick={(e) => setOpenAddNodeModal(e, "social_accounts_coco", currentNode.id)}>
+ Coco{" "}
+ <Badge variant="outline" className="ml-2">
+ soon
+ </Badge>
+ </DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ <DropdownMenuItem onClick={handleEditClick}>View and edit</DropdownMenuItem>
+ <DropdownMenuItem onClick={handleDuplicateClick}>Duplicate</DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={handleDeleteClick} className="text-red-600">
+ Delete
+ <span className="ml-auto text-xs text-muted-foreground">⌘ ⌫</span>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <Dialog open={openAddNodeModal && currentNodeType} onOpenChange={setOpenNodeModal}>
+ <DialogContent>
+ <DialogTitle>New {currentNodeType?.type}</DialogTitle>
+ <DialogDescription>Add a new related {currentNodeType?.type}.</DialogDescription>
+ <form onSubmit={onSubmitNewNodeModal}>
+ <div className="flex flex-col ga-3">
+ {currentNodeType?.fields.map((field: any, i: number) => {
+ const [key, value] = field.split(":")
+ return (
+ <label key={i}>
+ <p className="my-2">{key}</p>
+ <Input defaultValue={value || ""} name={key} placeholder={`Your value here (${key})`} />
+ </label>
+ )
+ })}
+ </div>
+ {error && (
+ <Alert variant="destructive">
+ <AlertCircle className="h-4 w-4" />
+ <AlertTitle>Error</AlertTitle>
+ <AlertDescription>{error}</AlertDescription>
+ </Alert>
+ )}
+ <div className="flex items-center gap-2 justify-end mt-4">
+ <DialogClose asChild>
+ <Button type="button" variant="outline">
+ Cancel
+ </Button>
+ </DialogClose>
+ <Button disabled={loading} type="submit">
+ Save
+ </Button>
+ </div>
+ </form>
+ </DialogContent>
+ </Dialog>
+ {currentNode.id && <NodeNotesEditor openNote={openNote} setOpenNote={setOpenNote} individualId={currentNode.id} />}
+ </>
+ )
+ },
+)
+
+export default NodeContextMenu
+
diff --git a/flowsint-web/src/components/node-notes-editor.tsx b/flowsint-web/src/components/investigations/sketch/nodes/node-notes-editor.tsx
similarity index 90%
rename from flowsint-web/src/components/node-notes-editor.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/node-notes-editor.tsx
index 9ee0ac44..5803a334 100644
--- a/flowsint-web/src/components/node-notes-editor.tsx
+++ b/flowsint-web/src/components/investigations/sketch/nodes/node-notes-editor.tsx
@@ -15,18 +15,18 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
-import { useNodeContext } from "./contexts/node-context"
import { useQuery } from "@tanstack/react-query"
import { useParams } from "next/navigation"
import { Individual } from "@/types/investigation"
-import Loader from "./loader"
+import Loader from "../../../loader"
interface NoteEditorModalProps {
+ openNote: boolean
individualId: string | null
+ setOpenNote: (open: boolean) => void
}
-export function NodeNotesEditor({ individualId }: NoteEditorModalProps) {
- const { openNote, setOpenNote } = useNodeContext()
+export function NodeNotesEditor({ openNote, setOpenNote, individualId }: NoteEditorModalProps) {
const { investigation_id } = useParams()
const [isSaving, setIsSaving] = useState(false)
const { data: individual = null, isLoading } = useQuery({
@@ -79,6 +79,14 @@ export function NodeNotesEditor({ individualId }: NoteEditorModalProps) {
return (
<Dialog open={openNote} onOpenChange={setOpenNote}>
+ {!isLoading && !individual && (
+ <DialogContent className="sm:max-w-[600px] max-h-[80vh] overflow-auto">
+ <DialogHeader>
+ <DialogTitle>Error</DialogTitle>
+ <DialogDescription>Could not find individual.</DialogDescription>
+ </DialogHeader>
+ </DialogContent>
+ )}
{isLoading ?
<DialogContent className="sm:max-w-[600px] max-h-[80vh] overflow-auto">
<DialogHeader>
@@ -88,7 +96,7 @@ export function NodeNotesEditor({ individualId }: NoteEditorModalProps) {
<div className="h-[200px] flex items-center justify-center">
<Loader /> Loading individual...
</div>
- </DialogContent> :
+ </DialogContent> : individual &&
<DialogContent onContextMenu={(e) => e.stopPropagation()} className="sm:max-w-[600px] max-h-[80vh] overflow-auto">
<DialogHeader>
<DialogTitle>Add Note for {individual?.full_name}</DialogTitle>
diff --git a/flowsint-web/src/components/investigations/nodes/person.tsx b/flowsint-web/src/components/investigations/sketch/nodes/person.tsx
similarity index 94%
rename from flowsint-web/src/components/investigations/nodes/person.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/person.tsx
index 686e5227..0eaedec0 100644
--- a/flowsint-web/src/components/investigations/nodes/person.tsx
+++ b/flowsint-web/src/components/investigations/sketch/nodes/person.tsx
@@ -13,7 +13,6 @@ export default memo(({ data }: any) => {
position={Position.Top}
className={cn("w-16 bg-teal-500 opacity-0")}
/>
-
<Card
className={cn(
"p-1 border border-border hover:border-primary duration-100 rounded-lg shadow-none backdrop-blur bg-background/40",
@@ -25,7 +24,7 @@ export default memo(({ data }: any) => {
<AvatarFallback>{data.full_name[0]}</AvatarFallback>
</Avatar>
<div className="flex items-center gap-1">
- <span className="text-sm">{data.full_name}</span>
+ <span className="text-sm text-nowrap">{data.full_name}</span>
<CopyButton className="rounded-full" content={data.full_name} />
</div>
</div>
diff --git a/flowsint-web/src/components/investigations/nodes/phone.tsx b/flowsint-web/src/components/investigations/sketch/nodes/phone.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/nodes/phone.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/phone.tsx
diff --git a/flowsint-web/src/components/investigations/nodes/physical_address.tsx b/flowsint-web/src/components/investigations/sketch/nodes/physical_address.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/nodes/physical_address.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/physical_address.tsx
diff --git a/flowsint-web/src/components/investigations/nodes/social.tsx b/flowsint-web/src/components/investigations/sketch/nodes/social.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/nodes/social.tsx
rename to flowsint-web/src/components/investigations/sketch/nodes/social.tsx
diff --git a/flowsint-web/src/components/investigations/sketch/profile-panel.tsx b/flowsint-web/src/components/investigations/sketch/profile-panel.tsx
new file mode 100644
index 00000000..52f608ee
--- /dev/null
+++ b/flowsint-web/src/components/investigations/sketch/profile-panel.tsx
@@ -0,0 +1,213 @@
+"use client"
+
+import { Card } from "@/components/ui/card"
+import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
+import { Badge } from "@/components/ui/badge"
+import { User, MapPin, Globe, Info, AtSign, Phone, Calendar, Link2, Mail, Shield, XIcon } from "lucide-react"
+import { Separator } from "@/components/ui/separator"
+import { useFlowStore } from "@/store/flow-store"
+import { Button } from "@/components/ui/button"
+
+export default function ProfilePanel({ data, type }: { data: any, type: "individual" | "email" }) {
+
+ const { setCurrentNode } = useFlowStore()
+
+ const closePanel = () => {
+ setCurrentNode(null)
+ }
+
+ if (type === "email") {
+ return (
+ <Card className="w-full bg-background max-w-[400px] relative">
+ <Button className="absolute top-2 right-2" size={"icon"} variant={"ghost"} onClick={closePanel}><XIcon className="h-5 w-5" /></Button>
+ <div className="p-6 md:p-8">
+ <div className="grid grid-cols-1 gap-6">
+ {/* Left column with email info */}
+ <div className="space-y-6">
+ <div className="flex flex-col items-center gap-4">
+ <div className="bg-primary/10 p-3 rounded-full">
+ <Mail className="h-8 w-8 text-primary" />
+ </div>
+ <div className="w-full">
+ <h2 className="text-xl w-full font-bold break-all">{data.email}</h2>
+ <p className="text-sm text-muted-foreground">Email Address</p>
+ </div>
+ </div>
+ <Separator />
+ <div className="space-y-4">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Shield className="h-4 w-4" />
+ <span className="text-sm">Security Status</span>
+ </div>
+ <div className="flex gap-2 mt-1">
+ <Badge variant={data.breach_found ? "destructive" : "outline"} className="px-3 py-1">
+ {data.breach_found ? "Breach Found" : "No Breach Detected"}
+ </Badge>
+ </div>
+ </div>
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Info className="h-4 w-4" />
+ <span className="text-sm">Email ID</span>
+ </div>
+ <p className="text-xs font-mono text-muted-foreground">{data.id}</p>
+ </div>
+ </div>
+ </div>
+ {/* Right column with related info */}
+ <div className="space-y-6">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Link2 className="h-4 w-4" />
+ <span className="text-sm">Associated Individual</span>
+ </div>
+ <p className="text-xs font-mono text-muted-foreground">{data.individual_id}</p>
+ </div>
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Info className="h-4 w-4" />
+ <span className="text-sm">Investigation ID</span>
+ </div>
+ <p className="text-xs font-mono text-muted-foreground">{data.investigation_id}</p>
+ </div>
+ <div className="mt-auto pt-4">
+ <Badge variant="outline" className="px-2 py-1">
+ Email Record
+ </Badge>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Card>)
+ }
+ if (type === "individual")
+ return (
+ <Card className="w-full bg-background relative">
+ <Button className="absolute top-2 right-2" size={"icon"} variant={"ghost"} onClick={closePanel}><XIcon className="h-5 w-5" /></Button>
+ <div className="p-6 md:p-8">
+ <div className="grid grid-cols-1 gap-2">
+ {/* Left column with avatar */}
+ <div className="flex flex-col items-center md:items-start gap-6">
+ <div className="relative">
+ <Avatar className="w-40 h-40 border-4 border-primary/20">
+ <AvatarImage src={data.image_url} alt={data.full_name} />
+ <AvatarFallback className="text-2xl">
+ {data.full_name
+ .split(" ")
+ .map((n: any[]) => n[0])
+ .join("")}
+ </AvatarFallback>
+ </Avatar>
+ </div>
+
+ <div className="space-y-1 text-center md:text-left">
+ <div className="flex items-center gap-2 text-primary">
+ <User className="h-4 w-4" />
+ <span className="text-sm">Full Name</span>
+ </div>
+ <h1 className="text-2xl font-bold tracking-tight">{data.full_name}</h1>
+ </div>
+
+ <div className="space-y-1 text-center md:text-left">
+ <div className="flex items-center gap-2 text-primary">
+ <Info className="h-4 w-4" />
+ <span className="text-sm">Investigation ID</span>
+ </div>
+ <p className="text-sm font-mono">{data.investigation_id}</p>
+ </div>
+ </div>
+
+ {/* Middle column */}
+ <div className="space-y-6">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <AtSign className="h-4 w-4" />
+ <span className="text-sm">Email</span>
+ </div>
+ {data?.emails?.length > 0 ? (
+ <p className="font-medium">{data?.emails?.[0].email}</p>
+ ) : (
+ <p className="text-gray-500">No email available</p>
+ )}
+ </div>
+
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Globe className="h-4 w-4" />
+ <span className="text-sm">Nationality</span>
+ </div>
+ <p className="font-medium">{data.nationality || "Unknown"}</p>
+ </div>
+
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <User className="h-4 w-4" />
+ <span className="text-sm">Gender</span>
+ </div>
+ <p className="font-medium">{data.gender || "Unknown"}</p>
+ </div>
+
+ {data?.phone_numbers?.length > 0 && (
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Phone className="h-4 w-4" />
+ <span className="text-sm">Phone Number</span>
+ </div>
+ <p className="font-medium">{data?.phone_numbers?.[0]}</p>
+ </div>
+ )}
+ </div>
+
+ {/* Right column */}
+ <div className="space-y-6">
+ {data.birth_date && (
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Calendar className="h-4 w-4" />
+ <span className="text-sm">Birth Date</span>
+ </div>
+ <p className="font-medium">{data.birth_date}</p>
+ </div>
+ )}
+
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Info className="h-4 w-4" />
+ <span className="text-sm">Email Security</span>
+ </div>
+ <div className="flex gap-2 mt-1">
+ {data?.emails?.length > 0 && (
+ <Badge
+ variant={data.emails?.[0].breach_found ? "destructive" : "outline"}
+ >
+ {data.emails?.[0].breach_found ? "Breach Found" : "No Breach"}
+ </Badge>
+ )}
+ </div>
+ </div>
+
+ {data.physical_addresses?.length > 0 && (
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <MapPin className="h-4 w-4" />
+ <span className="text-sm">Location</span>
+ </div>
+ <p className="font-medium">{data.physical_addresses?.[0]}</p>
+ </div>
+ )}
+
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-primary">
+ <Info className="h-4 w-4" />
+ <span className="text-sm">Individual ID</span>
+ </div>
+ <p className="text-xs font-mono text-gray-400">{data.id}</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Card>
+ )
+}
+
diff --git a/flowsint-web/src/components/investigations/simple-floating-edge.tsx b/flowsint-web/src/components/investigations/sketch/simple-floating-edge.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/simple-floating-edge.tsx
rename to flowsint-web/src/components/investigations/sketch/simple-floating-edge.tsx
diff --git a/flowsint-web/src/components/projects/documents-list.tsx b/flowsint-web/src/components/projects/documents-list.tsx
index e34cb49c..9c56dc2e 100644
--- a/flowsint-web/src/components/projects/documents-list.tsx
+++ b/flowsint-web/src/components/projects/documents-list.tsx
@@ -3,7 +3,7 @@
import { JSX, useState } from "react"
import { useQuery } from "@tanstack/react-query"
import { format, formatDistanceToNow } from "date-fns"
-import { FileIcon, ImageIcon, MoreHorizontal } from "lucide-react"
+import { FileIcon, FileJson, FileTextIcon, ImageIcon, MoreHorizontal } from "lucide-react"
import { useParams } from "next/navigation"
import { Button } from "@/components/ui/button"
@@ -11,6 +11,8 @@ import { TableCell, TableRow } from "@/components/ui/table"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"
import { Skeleton } from "../ui/skeleton"
+import { useConfirm } from "../use-confirm-dialog"
+import { toast } from "sonner"
interface Document {
id: string
@@ -27,7 +29,9 @@ interface Document {
}
const icons: Record<string, JSX.Element> = {
- "png": <ImageIcon className="h-5 w-5 text-primary" />,
+ "png": <ImageIcon className="h-5 w-5 text-foreground/30" />,
+ "json": <FileJson className="h-5 w-5 text-yellow-500" />,
+ "pdf": <FileTextIcon className="h-5 w-5 text-red-500" />,
"other": <FileIcon className="h-5 w-5 text-primary" />,
}
@@ -36,6 +40,7 @@ export function DocumentList() {
const [searchQuery, setSearchQuery] = useState("")
const [previewUrl, setPreviewUrl] = useState<string | null>(null)
const [previewType, setPreviewType] = useState<string | null>(null)
+ const { confirm } = useConfirm()
const {
data: documents,
@@ -56,12 +61,6 @@ export function DocumentList() {
const filteredDocuments = documents?.filter((doc) => doc.name.toLowerCase().includes(searchQuery.toLowerCase())) || []
- const formatFileSize = (bytes: number) => {
- if (bytes < 1024) return bytes + " B"
- else if (bytes < 1048576) return (bytes / 1024).toFixed(1) + " KB"
- else return (bytes / 1048576).toFixed(1) + " MB"
- }
-
const isPreviewable = (mimeType: string) => {
return (
mimeType.startsWith("image/") ||
@@ -88,6 +87,23 @@ export function DocumentList() {
console.error("Error downloading file:", error)
}
}
+
+ const deleteFile = async (fileName: string) => {
+ if (!await confirm({ title: `Are you sure you want to delete ${fileName}?`, message: "This action is irreversible." })) return
+ try {
+ const res = await fetch(`/api/projects/${project_id}/documents?fileName=${encodeURIComponent(fileName)}`, {
+ method: "DELETE",
+ })
+ if (!res.ok) {
+ toast.error("An error occurred while deleting the file.")
+ }
+ toast.success("File deleted successfully.")
+ refetch()
+ } catch (error) {
+ toast.error("An error occurred while deleting the file.")
+ }
+ }
+
if (isLoading) return (
<>
{Array.from({ length: 3 }).map((_, index) => (
@@ -130,7 +146,7 @@ export function DocumentList() {
</TableCell>
<TableCell className="text-muted-foreground">{`${doc.owner.first_name} ${doc.owner.last_name}`}</TableCell>
<TableCell className="hidden md:table-cell text-muted-foreground">
- {formatFileSize(doc.size)}
+ {doc.size}
</TableCell>
<TableCell className="hidden sm:table-cell text-muted-foreground">
{formatDistanceToNow(new Date(doc.last_updated_at), { addSuffix: true })}
@@ -151,7 +167,7 @@ export function DocumentList() {
<DropdownMenuItem onClick={() => previewFile(doc.url, doc.type)}>Preview</DropdownMenuItem>
)}
<DropdownMenuItem onClick={() => downloadFile(doc.url, doc.name)}>Download</DropdownMenuItem>
- <DropdownMenuItem className="text-destructive" disabled>
+ <DropdownMenuItem className="text-destructive" onClick={() => deleteFile(doc.name)}>
Delete
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/flowsint-web/src/components/projects/file-upload.tsx b/flowsint-web/src/components/projects/file-upload.tsx
index 1498d07a..3eef1f5d 100644
--- a/flowsint-web/src/components/projects/file-upload.tsx
+++ b/flowsint-web/src/components/projects/file-upload.tsx
@@ -16,7 +16,6 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
- DialogTrigger,
} from "@/components/ui/dialog"
import { Progress } from "@/components/ui/progress"
import { useProjectStore } from "@/store/project-store"
@@ -130,7 +129,7 @@ export default function FileUploadDialog() {
}
return (
<Dialog open={open} onOpenChange={setOpen}>
- <DialogContent className="sm:max-w-[900px] overflow-y-auto max-h-[80vh]">
+ <DialogContent className="sm:max-w-[700px] overflow-y-auto max-h-[80vh]">
<DialogHeader>
<DialogTitle>Upload Files</DialogTitle>
<DialogDescription>Drag and drop files to upload to the documents bucket.</DialogDescription>
diff --git a/flowsint-web/src/components/ui/sidebar.tsx b/flowsint-web/src/components/ui/sidebar.tsx
index aeea93c9..145b6df4 100644
--- a/flowsint-web/src/components/ui/sidebar.tsx
+++ b/flowsint-web/src/components/ui/sidebar.tsx
@@ -24,6 +24,8 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip"
+import { usePathname } from "next/navigation"
+import useLocalStorage from "@/lib/hooks/use-local-storage"
const SIDEBAR_COOKIE_NAME = "sidebar_state"
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
@@ -75,10 +77,10 @@ const SidebarProvider = React.forwardRef<
) => {
const isMobile = useIsMobile()
const [openMobile, setOpenMobile] = React.useState(false)
-
+ const pathname = usePathname()
// This is the internal state of the sidebar.
// We use openProp and setOpenProp for control from outside the component.
- const [_open, _setOpen] = React.useState(defaultOpen)
+ const [_open, _setOpen] = useLocalStorage("sidebar_open", defaultOpen)
const open = openProp ?? _open
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
@@ -383,7 +385,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto overflow-x-hidden group-data-[collapsible=icon]:overflow-hidden",
className
)}
{...props}
@@ -578,7 +580,7 @@ function SidebarMenuAction({
"peer-data-[size=lg]/menu-button:top-2.5",
"group-data-[collapsible=icon]:hidden",
showOnHover &&
- "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
+ "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
className
)}
{...props}
diff --git a/flowsint-web/src/lib/hooks/investigation/investigation.ts b/flowsint-web/src/lib/hooks/investigation/investigation.ts
index 080fc5c3..78df521b 100644
--- a/flowsint-web/src/lib/hooks/investigation/investigation.ts
+++ b/flowsint-web/src/lib/hooks/investigation/investigation.ts
@@ -1,12 +1,13 @@
import { supabase } from "@/lib/supabase/client";
import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-import { notFound } from "next/navigation";
-export function useInvestigations() {
+export function useInvestigations(project_id: string) {
const { data: investigations, count, mutate, isLoading, error } = useQuery(
supabase
.from('investigations')
- .select('id, title, description'),
+ .select('id, title, description')
+ .eq("project_id", project_id)
+ .order("last_updated_at", { ascending: false }),
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
diff --git a/flowsint-web/src/lib/utils.ts b/flowsint-web/src/lib/utils.ts
index ddc0e9aa..85ff0044 100644
--- a/flowsint-web/src/lib/utils.ts
+++ b/flowsint-web/src/lib/utils.ts
@@ -215,4 +215,10 @@ export const sanitize = (name: string) => {
.replace(/_{2,}/g, "_") // Replace multiple underscores with a single one
.replace(/^_|_$/g, "") // Trim leading or trailing underscores
.toLowerCase(); // Convert to lowercase for consistency
-};
\ No newline at end of file
+};
+
+export const formatFileSize = (bytes: number) => {
+ if (bytes < 1024) return bytes + " B"
+ else if (bytes < 1048576) return (bytes / 1024).toFixed(1) + " KB"
+ else return (bytes / 1048576).toFixed(1) + " MB"
+}
\ No newline at end of file
diff --git a/flowsint-web/src/store/flow-store.ts b/flowsint-web/src/store/flow-store.ts
index 78930c65..f79d2288 100644
--- a/flowsint-web/src/store/flow-store.ts
+++ b/flowsint-web/src/store/flow-store.ts
@@ -1,6 +1,5 @@
import { create } from 'zustand';
import { addEdge, applyNodeChanges, applyEdgeChanges, getIncomers, getOutgoers } from '@xyflow/react';
-import Dagre from '@dagrejs/dagre';
import { supabase } from '@/lib/supabase/client';
import {
type Edge,
@@ -12,11 +11,12 @@ import getLayoutedElements from '@/lib/utils';
export type AppNode = Node;
+
export type AppState = {
nodes: AppNode[];
edges: Edge[];
reloading: boolean;
- currentNode: string | null;
+ currentNode: Partial<Node> | null;
onNodesChange: OnNodesChange<AppNode>;
onEdgesChange: OnEdgesChange;
setNodes: (nodes: AppNode[]) => void;
@@ -26,7 +26,7 @@ export type AppState = {
onConnect: (params: any, investigation_id?: string) => Promise<void>;
onNodeClick: (_: React.MouseEvent, node: Node) => void;
onPaneClick: (_: React.MouseEvent) => void,
- setCurrentNode: (nodeId: string | null) => void;
+ setCurrentNode: (node: object | null) => void;
updateNode: (nodeId: string, nodeData: Partial<Node>) => void;
resetNodeStyles: () => void;
};
@@ -46,8 +46,8 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>
edges: applyEdgeChanges(changes, get().edges),
});
},
- setCurrentNode: (nodeId: string | null) => {
- set({ currentNode: nodeId });
+ setCurrentNode: (node: Partial<Node> | null) => {
+ set({ currentNode: node });
},
onConnect: async (params: any, investigation_id?: string) => {
console.log(investigation_id)
@@ -110,13 +110,13 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>
style: {
...edge.style,
stroke: "#b1b1b750",
- opacity: 1,
+ opacity: 0.7,
},
})),
});
},
- onNodeClick: (_event: any, node: { id: string; }) => {
- set({ currentNode: node.id });
+ onNodeClick: (_event: any, node: Partial<Node>) => {
+ set({ currentNode: node });
get().resetNodeStyles();
},
onPaneClick: (_envent: any) => {
@@ -141,7 +141,7 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>
edges: get().edges.map((edge) => ({
...edge,
animated: false,
- style: { ...edge.style, stroke: "#b1b1b750", opacity: 1 },
+ style: { ...edge.style, stroke: "#b1b1b750", opacity: 0.7 },
}))
});
return;
diff --git a/flowsint-web/src/store/investigation-store.ts b/flowsint-web/src/store/investigation-store.ts
index 4c7134e8..aad5756f 100644
--- a/flowsint-web/src/store/investigation-store.ts
+++ b/flowsint-web/src/store/investigation-store.ts
@@ -57,7 +57,7 @@ interface InvestigationState {
setHandleDeleteInvestigation: (handler: () => Promise<void>) => void
// Query Hooks
- useInvestigationData: (investigationId: string) => InvestigationData & {
+ useInvestigationData: (projectId: string, investigationId: string) => InvestigationData & {
refetchAll: () => Promise<void>
}
}
@@ -94,15 +94,15 @@ export const useInvestigationStore = create(
setHandleOpenIndividualModal: (handler) => set({ handleOpenIndividualModal: handler }),
handleDeleteInvestigation: async () => { },
setHandleDeleteInvestigation: (handler) => set({ handleDeleteInvestigation: handler }),
- useInvestigationData: (investigationId: string) => {
+ useInvestigationData: (projectId: string, investigationId: string) => {
const wrapRefetch = async (refetch: () => Promise<QueryObserverResult>) => {
await refetch()
}
const investigationQuery = useQuery<Investigation>({
- queryKey: ["investigation", investigationId, 'investigation'],
+ queryKey: ["projects", projectId, "investigation", investigationId, 'investigation'],
queryFn: async () => {
- const res = await fetch(`/api/investigations/${investigationId}`)
+ const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}`)
if (!res.ok) throw new Error("Failed to fetch investigation")
const data = await res.json()
return data.investigation as Investigation
@@ -110,9 +110,9 @@ export const useInvestigationStore = create(
})
const individualsQuery = useQuery<Individual[]>({
- queryKey: ["investigation", investigationId, "individuals"],
+ queryKey: ["projects", projectId, "investigation", investigationId, "individuals"],
queryFn: async () => {
- const res = await fetch(`/api/investigations/${investigationId}/individuals`)
+ const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/individuals`)
if (!res.ok) throw new Error("Failed to fetch individuals")
const data = await res.json()
return data.individuals
@@ -120,9 +120,9 @@ export const useInvestigationStore = create(
})
const emailsQuery = useQuery<Email[]>({
- queryKey: ["investigation", investigationId, "emails"],
+ queryKey: ["projects", projectId, "investigation", investigationId, "emails"],
queryFn: async () => {
- const res = await fetch(`/api/investigations/${investigationId}/emails`)
+ const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/emails`)
if (!res.ok) throw new Error("Failed to fetch emails")
const data = await res.json()
return data.emails
@@ -130,9 +130,9 @@ export const useInvestigationStore = create(
})
const phonesQuery = useQuery<Phone[]>({
- queryKey: ["investigation", investigationId, "phones"],
+ queryKey: ["projects", projectId, "investigation", investigationId, "phones"],
queryFn: async () => {
- const res = await fetch(`/api/investigations/${investigationId}/phones`)
+ const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/phones`)
if (!res.ok) throw new Error("Failed to fetch phones")
const data = await res.json()
return data.phones
@@ -142,7 +142,7 @@ export const useInvestigationStore = create(
const socialsQuery = useQuery<Social[]>({
queryKey: ["investigation", investigationId, "socials"],
queryFn: async () => {
- const res = await fetch(`/api/investigations/${investigationId}/socials`)
+ const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/socials`)
if (!res.ok) throw new Error("Failed to fetch socials")
const data = await res.json()
return data.socials
diff --git a/flowsint-web/src/types/investigation.ts b/flowsint-web/src/types/investigation.ts
index f87759f0..4a5174b9 100644
--- a/flowsint-web/src/types/investigation.ts
+++ b/flowsint-web/src/types/investigation.ts
@@ -1,3 +1,5 @@
+import { Project } from "./project"
+
export interface Investigation {
id: string
title: string
@@ -9,6 +11,8 @@ export interface Investigation {
owner: any
relations?: any[]
individuals?: any[]
+ project?: Project
+ project_id: string
}
export interface Individual {
id: string