Skip to content

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

feat: new dahboard

dextmorgn69a1f022f61e
diff --git a/flowsint-web/src/app/api/investigations/route.ts b/flowsint-web/src/app/api/investigations/route.ts
index d5742e29..c77d9248 100644
--- a/flowsint-web/src/app/api/investigations/route.ts
+++ b/flowsint-web/src/app/api/investigations/route.ts
@@ -11,7 +11,8 @@ export async function GET() {
if (!user || userError) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
- const { data: investigations, error } = await supabase.from("investigations").select("id, title, description")
+ const { data: investigations, error } = await supabase.from("investigations")
+ .select("id, title, description")
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
}
diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsx
index 92859b59..842eddcb 100644
--- a/flowsint-web/src/app/dashboard/page.tsx
+++ b/flowsint-web/src/app/dashboard/page.tsx
@@ -1,37 +1,172 @@
-import React from 'react'
-import Investigation from '@/components/dashboard/investigation'
-import { Button } from '@/components/ui/button'
-import { DownloadIcon, FolderIcon, PlusIcon } from 'lucide-react'
-import NewCase from '@/components/dashboard/new-case'
-import { createClient } from '@/lib/supabase/server'
-import { unauthorized } from 'next/navigation'
+import Investigation from "@/components/dashboard/investigation"
+import { Button } from "@/components/ui/button"
+import { Badge } from "@/components/ui/badge"
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
+import { AlertCircle, ChevronDown, Clock, Filter, Grid3X3, List, Lock, Plus, Search, Target } from "lucide-react"
+import NewCase from "@/components/dashboard/new-case"
+import { createClient } from "@/lib/supabase/server"
+import { Input } from "@/components/ui/input"
+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
+import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"
+import { unauthorized } from "next/navigation"
const DashboardPage = async () => {
const supabase = await createClient()
- const { data: investigations, error } = await supabase.from("investigations").select("id, title, description")
+ const { data: investigations, error } = await supabase.from("investigations").select("*, relations_count:relationships!inner(count), individuals_counts:individuals!inner(count)")
if (error) return unauthorized()
+
+ // Compter les investigations par statut
+ const activeCount = investigations.filter((inv) => inv.status === "active").length || 0
+ const pendingCount = investigations.filter((inv) => inv.status === "pending").length || 0
+ const archivedCount = investigations.filter((inv) => inv.status === "archived").length || 0
+ const totalCount = investigations.length
+
return (
- <div className='space-y-6 w-full p-12'>
- <div className='flex justify-between items-center'>
- <div className=''>
- <h1 className="text-3xl font-semibold mb-2">Vos investigations</h1>
- <p className="mb-6 opacity-70">
- La liste de vos investigations. Vous pouvez également en créer d'autres.
- </p>
+ <div className="space-y-6 w-full">
+ <div className="flex flex-col gap-4 md:gap-8">
+ <div className="flex flex-col gap-2 md:flex-row md:items-center md:justify-between">
+ <div>
+ <h1 className="text-2xl font-bold tracking-tight">Investigations</h1>
+ <p className="text-muted-foreground">Gérez et suivez vos investigations OSINT en cours.</p>
+ </div>
+ <div className="flex items-center gap-2">
+ <NewCase>
+ <Button size="sm" className="h-8 gap-1">
+ <Plus className="h-3.5 w-3.5" />
+ <span>Nouvelle investigation</span>
+ </Button>
+ </NewCase>
+ </div>
</div>
- <div className='flex gap-3'>
- <NewCase>
- <Button><PlusIcon className='h-4 w-4' />Create</Button>
- </NewCase>
- {/* <Button variant='secondary'><DownloadIcon className='h-4 w-4' />Upload</Button>
- <Button variant='secondary'><FolderIcon className='h-4 w-4' />Create organization</Button> */}
+
+ <div className="flex flex-col md:flex-row gap-4 md:items-center">
+ <div className="relative flex-1 md:max-w-sm">
+ <Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
+ <Input
+ type="search"
+ placeholder="Rechercher..."
+ className="w-full rounded-lg bg-background pl-8 md:max-w-sm"
+ />
+ </div>
+
+ <div className="flex items-center gap-2">
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button variant="outline" size="sm" className="h-8 gap-1">
+ <Filter className="h-3.5 w-3.5" />
+ <span>Filtres</span>
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-72">
+ <Command>
+ <CommandInput placeholder="Rechercher un filtre..." />
+ <CommandList>
+ <CommandEmpty>Aucun filtre trouvé.</CommandEmpty>
+ <CommandGroup heading="Statut">
+ <CommandItem>Actif</CommandItem>
+ <CommandItem>En cours</CommandItem>
+ <CommandItem>Archivé</CommandItem>
+ </CommandGroup>
+ <CommandGroup heading="Priorité">
+ <CommandItem>Critique</CommandItem>
+ <CommandItem>Haute</CommandItem>
+ <CommandItem>Moyenne</CommandItem>
+ <CommandItem>Basse</CommandItem>
+ </CommandGroup>
+ <CommandGroup heading="Tags">
+ <CommandItem>Financial</CommandItem>
+ <CommandItem>Corporate</CommandItem>
+ <CommandItem>Cyber</CommandItem>
+ <CommandItem>International</CommandItem>
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+
+ <div className="flex items-center gap-1 md:gap-2">
+ <Button variant="default" size="icon" className="h-8 w-8">
+ <Grid3X3 className="h-4 w-4" />
+ <span className="sr-only">Grid view</span>
+ </Button>
+ <Button variant="ghost" size="icon" className="h-8 w-8">
+ <List className="h-4 w-4" />
+ <span className="sr-only">List view</span>
+ </Button>
+ </div>
+
+ <Button variant="outline" size="sm" className="h-8 gap-1">
+ <span>Trier par</span>
+ <ChevronDown className="h-3.5 w-3.5" />
+ </Button>
+ </div>
</div>
+
+ <Tabs defaultValue="active" className="w-full">
+ <TabsList>
+ <TabsTrigger value="active" className="gap-1.5">
+ <AlertCircle className="h-4 w-4" />
+ <span>Actives</span>
+ <Badge className="ml-1" variant={"outline"}>{activeCount}</Badge>
+ </TabsTrigger>
+ <TabsTrigger value="pending" className="gap-1.5">
+ <Clock className="h-4 w-4" />
+ <span>En cours</span>
+ <Badge className="ml-1" variant={"outline"}>{pendingCount}</Badge>
+ </TabsTrigger>
+ <TabsTrigger value="archived" className="gap-1.5">
+ <Lock className="h-4 w-4" />
+ <span>Archivées</span>
+ <Badge className="ml-1" variant={"outline"}>{archivedCount}</Badge>
+ </TabsTrigger>
+ <TabsTrigger value="all" className="gap-1.5">
+ <Target className="h-4 w-4" />
+ <span>Toutes</span>
+ <Badge className="ml-1" variant={"outline"}>{totalCount}</Badge>
+ </TabsTrigger>
+ </TabsList>
+
+ <TabsContent value="all" className="mt-6">
+ <div className="grid gap-4 sm:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
+ {investigations.map((investigation) => (
+ <Investigation key={investigation.id} investigation={investigation} />
+ ))}
+ </div>
+ </TabsContent>
+
+ <TabsContent value="active" className="mt-6">
+ <div className="grid gap-4 sm:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
+ {investigations
+ .filter((inv) => inv.status === "active")
+ .map((investigation) => (
+ <Investigation key={investigation.id} investigation={investigation} />
+ ))}
+ </div>
+ </TabsContent>
+
+ <TabsContent value="pending" className="mt-6">
+ <div className="grid gap-4 sm:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
+ {investigations
+ .filter((inv) => inv.status === "pending")
+ .map((investigation) => (
+ <Investigation key={investigation.id} investigation={investigation} />
+ ))}
+ </div>
+ </TabsContent>
+ <TabsContent value="archived" className="mt-6">
+ <div className="grid gap-4 sm:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
+ {investigations
+ .filter((inv) => inv.status === "archived")
+ .map((investigation) => (
+ <Investigation key={investigation.id} investigation={investigation} />
+ ))}
+ </div>
+ </TabsContent>
+ </Tabs>
</div>
- <div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-5'>{investigations.map((investigation) => (
- <Investigation key={investigation.id} investigation={investigation} />
- ))}
- </div>
- </div>
+ </div >
)
}
-export default DashboardPage
\ No newline at end of file
+
+export default DashboardPage
+
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/loading.tsx b/flowsint-web/src/app/investigations/[investigation_id]/loading.tsx
index 5b483d30..6b7b0d2d 100644
--- a/flowsint-web/src/app/investigations/[investigation_id]/loading.tsx
+++ b/flowsint-web/src/app/investigations/[investigation_id]/loading.tsx
@@ -3,7 +3,7 @@ import React from 'react'
const loading = () => {
return (
- <div className='h-[90vh] w-full flex items-center justify-center gap-2'><Loader />Loading nodes and edges...</div>
+ <div className='h-[90vh] w-full flex items-center justify-center gap-2'><Loader />Loading...</div>
)
}
diff --git a/flowsint-web/src/app/investigations/[investigation_id]/page.tsx b/flowsint-web/src/app/investigations/[investigation_id]/page.tsx
index 2414a072..ace79f86 100644
--- a/flowsint-web/src/app/investigations/[investigation_id]/page.tsx
+++ b/flowsint-web/src/app/investigations/[investigation_id]/page.tsx
@@ -1,4 +1,4 @@
-import { notFound, unauthorized } from "next/navigation"
+import { notFound, redirect, unauthorized } from "next/navigation"
import DashboardClient from "./client"
import { createClient } from "@/lib/supabase/server"
@@ -15,6 +15,10 @@ const DashboardPage = async ({
error: userError,
} = await supabase.auth.getUser();
if (!user || userError) {
+ return redirect("/login")
+ }
+ const { data: investigation, error } = await supabase.from("investigations").select("id").eq("id", investigation_id).single()
+ if (!investigation || error) {
return notFound()
}
return <DashboardClient investigationId={investigation_id} />
diff --git a/flowsint-web/src/app/providers.tsx b/flowsint-web/src/app/providers.tsx
index 30afcd0d..1f59a635 100644
--- a/flowsint-web/src/app/providers.tsx
+++ b/flowsint-web/src/app/providers.tsx
@@ -24,8 +24,10 @@ export function Providers({ children, themeProps }: ProvidersProps) {
}),
)
return (
- <QueryClientProvider client={queryClient}>
- <NextThemesProvider {...themeProps}>{children}</NextThemesProvider>
- </QueryClientProvider>
+ <NextThemesProvider {...themeProps}>
+ <QueryClientProvider client={queryClient}>
+ {children}
+ </QueryClientProvider>
+ </NextThemesProvider>
);
}
diff --git a/flowsint-web/src/components/app-sidebar.tsx b/flowsint-web/src/components/app-sidebar.tsx
index 35a8d926..e8262cd3 100644
--- a/flowsint-web/src/components/app-sidebar.tsx
+++ b/flowsint-web/src/components/app-sidebar.tsx
@@ -6,12 +6,20 @@ import {
BookOpen,
Bot,
Command,
+ FolderSearch,
Frame,
GalleryVerticalEnd,
+ Globe,
+ KeyIcon,
Map,
+ MapPin,
+ Network,
PieChart,
Settings2,
+ SettingsIcon,
SquareTerminal,
+ UserIcon,
+ Users,
} from "lucide-react"
import { NavMain } from "@/components/nav-main"
@@ -22,8 +30,14 @@ import {
Sidebar,
SidebarContent,
SidebarFooter,
+ SidebarGroup,
+ SidebarGroupLabel,
SidebarHeader,
+ SidebarMenu,
+ SidebarMenuButton,
+ SidebarMenuItem,
SidebarRail,
+ SidebarSeparator,
} from "@/components/ui/sidebar"
// This is sample data.
@@ -156,14 +170,100 @@ export function AppSidebar({ user, ...props }: AppSidebarProps) {
<SidebarHeader>
<TeamSwitcher teams={data.teams} />
</SidebarHeader>
- <SidebarContent>
- {/* <NavMain items={data.navMain} /> */}
- <NavProjects projects={data.projects} />
+ <SidebarContent className="p-0 overflow-hidden">
+ <SidebarGroup className="group-data-[collapsible=icon]:p-auto">
+ <SidebarGroupLabel>NAVIGATION</SidebarGroupLabel>
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild isActive>
+ <a href="/dashboard">
+ <FolderSearch className="h-4 w-4" />
+ <span>Investigations</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/networks">
+ <Network className="h-4 w-4" />
+ <span>Networks</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/entities">
+ <Users className="h-4 w-4" />
+ <span>Entities</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/sources">
+ <Globe className="h-4 w-4" />
+ <span>OSINT sources</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/map">
+ <MapPin className="h-4 w-4" />
+ <span>Map</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarGroup>
+ <SidebarSeparator />
+ <SidebarGroup className="group-data-[collapsible=icon]:p-auto">
+ <SidebarGroupLabel>TEAMS</SidebarGroupLabel>
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/profile">
+ <UserIcon className="h-4 w-4" />
+ <span>My account</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/team">
+ <Users className="h-4 w-4" />
+ <span>Team members</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarGroup>
+ <SidebarGroup className="group-data-[collapsible=icon]:p-auto">
+ <SidebarGroupLabel>Preferences</SidebarGroupLabel>
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/dashboard/settings">
+ <SettingsIcon className="h-4 w-4" />
+ <span>Settings</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton asChild>
+ <a href="/dashboard/keys">
+ <KeyIcon className="h-4 w-4" />
+ <span>API keys</span>
+ </a>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarGroup>
</SidebarContent>
<SidebarFooter>
<NavUser user={user} />
</SidebarFooter>
<SidebarRail />
- </Sidebar>
+ </Sidebar >
)
}
diff --git a/flowsint-web/src/components/contexts/investigation-provider.tsx b/flowsint-web/src/components/contexts/investigation-provider.tsx
index 345a5cb5..898ec540 100644
--- a/flowsint-web/src/components/contexts/investigation-provider.tsx
+++ b/flowsint-web/src/components/contexts/investigation-provider.tsx
@@ -47,7 +47,7 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch
try {
const { error } = await supabase
.from("investigations")
- .delete()
+ .update({ status: "archived" })
.eq("id", investigation_id)
if (error) throw error
diff --git a/flowsint-web/src/components/dashboard/investigation.tsx b/flowsint-web/src/components/dashboard/investigation.tsx
index 41218d5d..b68c62c7 100644
--- a/flowsint-web/src/components/dashboard/investigation.tsx
+++ b/flowsint-web/src/components/dashboard/investigation.tsx
@@ -1,34 +1,172 @@
-"use client"
-import React from 'react'
-import { Investigation } from '@/types/investigation';
-import Link from 'next/link';
-import Image from 'next/image';
-const investigation = ({ investigation }: { investigation: Investigation }) => {
+import { Badge } from "@/components/ui/badge"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
+import { Calendar, MapPin, MoreHorizontal, Network } from "lucide-react"
+import Link from "next/link"
+
+// Composant pour afficher la barre de progression
+// Pour l'instant on garde la primary
+function ProgressBar({ value = 35 }: { value?: number }) {
+ let color = "bg-primary"
+ if (value < 30) color = "bg-primary"
+ else if (value < 70) color = "bg-primary"
+ else color = "bg-primary"
+
+ return (
+ <div className="w-full bg-gray-200 rounded-full h-1.5 dark:bg-gray-700">
+ <div className={`${color} h-1.5 rounded-full`} style={{ width: `${value}%` }}></div>
+ </div>
+ )
+}
+
+// Composant pour afficher un avatar avec initiales
+function Avatar({ name, size = "sm" }: { name: string; size?: "sm" | "md" | "lg" }) {
+ const initials = name.charAt(0).toUpperCase()
+ const colors = {
+ a: "bg-red-500",
+ m: "bg-blue-500",
+ t: "bg-green-500",
+ s: "bg-purple-500",
+ j: "bg-amber-500",
+ }
+ const color = colors[name.charAt(0).toLowerCase() as keyof typeof colors] || "bg-gray-500"
+
+ const sizes = {
+ sm: "w-6 h-6 text-xs",
+ md: "w-8 h-8 text-sm",
+ lg: "w-10 h-10 text-base",
+ }
+
return (
- <Link href={`/investigations/${investigation.id}`} >
- <div className="w-full h-full">
- <div className="group relative h-full overflow-hidden">
- <div className="aspect-video overflow-hidden border">
- <Image
- src={"https://c6p3q0oludlschf8w.lite.vusercontent.net/placeholder.svg"}
- alt={investigation.title}
- width={400}
- height={300}
- className="h-full w-full object-cover transition-transform group-hover:scale-115 dark:invert"
- />
+ <div className={`${sizes[size]} ${color} rounded-full flex items-center justify-center text-white font-medium`}>
+ {initials}
+ </div>
+ )
+}
+
+// Composant pour afficher le statut
+function StatusBadge({ status = "active" }: { status?: string }) {
+ const statusConfig = {
+ active: {
+ class: "bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-300",
+ label: "Active",
+ },
+ pending: {
+ class: "bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-300",
+ label: "Pending",
+ },
+ archived: {
+ class: "bg-slate-100 text-slate-800 dark:bg-slate-800 dark:text-slate-300",
+ label: "Archived",
+ },
+ }
+
+ const config = statusConfig[status as keyof typeof statusConfig] || statusConfig.active
+
+ return (
+ <Badge variant="outline" className={`${config.class} border-0`}>
+ {config.label}
+ </Badge>
+ )
+}
+
+// Composant pour afficher la priorité
+function PriorityBadge({ priority = "medium" }: { priority?: string }) {
+ const colors = {
+ low: "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300",
+ medium: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",
+ high: "bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-300",
+ critical: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300",
+ }
+
+ return (
+ <Badge variant="outline" className={`${colors[priority as keyof typeof colors] || colors.medium} border-0`}>
+ {priority.charAt(0).toUpperCase() + priority.slice(1)}
+ </Badge>
+ )
+}
+
+export default function Investigation({ investigation }: { investigation: any }) {
+ // Utiliser les données de l'investigation ou des valeurs par défaut
+ const {
+ id,
+ title,
+ description = "No description provided.",
+ status = "active",
+ progress = 35,
+ lastUpdated = new Date().toISOString(),
+ tags = ["investigation", "osint", "pedo"],
+ team = ["E", "J"],
+ priority = "medium",
+ entities = investigation?.["individuals_counts"]?.[0]?.count || 0,
+ connections = investigation?.["relations_counts"]?.[0]?.count || 0,
+ location = "Not specified",
+ } = investigation
+
+ return (
+ <Card className="overflow-hidden h-full shadow-none bg-background">
+ <CardHeader className="p-4 pb-2">
+ <div className="flex justify-between items-start">
+ <CardTitle className="text-lg">
+ <Link href={`/investigations/${id}`} className="hover:underline">
+ {title}
+ </Link>
+ </CardTitle>
+ <Button variant="ghost" size="icon" className="h-8 w-8">
+ <MoreHorizontal className="h-4 w-4" />
+ <span className="sr-only">Options</span>
+ </Button>
+ </div>
+ {description && <CardDescription className="line-clamp-2">{description}</CardDescription>}
+ </CardHeader>
+ <CardContent className="p-4 pt-0">
+ <div className="flex flex-col gap-3">
+ <div className="flex items-center justify-between text-sm">
+ <StatusBadge status={status} />
</div>
- <div className="p-4 h-full">
- <div>
- {investigation.title}
- </div>
- <div className='opacity-60'>
- {investigation.description || <span className='italic'>No description provided.</span>}
+ {/* <div className="space-y-1.5">
+ <div className="flex justify-between text-xs">
+ <span className="text-muted-foreground">Progression</span>
+ <span className="font-medium">{progress}%</span>
</div>
+ <ProgressBar value={progress} />
+ </div> */}
+ {/* <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
+ <MapPin className="h-3.5 w-3.5" />
+ <span>{location}</span>
+ </div> */}
+ <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
+ <Network className="h-3.5 w-3.5" />
+ <span>
+ {entities} entities, {connections} connections
+ </span>
</div>
+ <div className="flex flex-wrap gap-1.5">
+ {tags.map((tag: string) => (
+ <Badge key={tag} variant="secondary" className="text-xs">
+ {tag}
+ </Badge>
+ ))}
+ </div>
+ </div>
+ </CardContent>
+ <CardFooter className="p-4 pt-0 flex justify-between items-center mt-auto">
+ <div className="flex -space-x-2">
+ {team.map((member: string) => (
+ <Avatar key={member} name={member} size="sm" />
+ ))}
+ </div>
+ <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
+ <Calendar className="h-3.5 w-3.5" />
+ <span>
+ {new Date(lastUpdated).toLocaleDateString("fr-FR", {
+ day: "numeric",
+ month: "short",
+ })}
+ </span>
</div>
- </div>
- </Link>
+ </CardFooter>
+ </Card>
)
}
-export default investigation
\ No newline at end of file
diff --git a/flowsint-web/src/components/investigations/custom-edge.tsx b/flowsint-web/src/components/investigations/custom-edge.tsx
index e7a20fa0..a90c407b 100644
--- a/flowsint-web/src/components/investigations/custom-edge.tsx
+++ b/flowsint-web/src/components/investigations/custom-edge.tsx
@@ -1,35 +1,82 @@
-import {
- BaseEdge,
- EdgeLabelRenderer,
- getBezierPath,
-} from '@xyflow/react';
-import { useInvestigationStore } from '@/store/investigation-store';
-import { Badge } from '@/components/ui/badge';
-
-export default function CustomEdge(props: any) {
- const { id, label, confidence_level, sourceX, sourceY, targetX, targetY, style } = props
- const [edgePath, labelX, labelY] = getBezierPath({
- sourceX,
- sourceY,
- targetX,
- targetY,
- });
- const { settings } = useInvestigationStore()
- return (
- <>
- <BaseEdge id={id} path={edgePath} style={style} />
- <EdgeLabelRenderer>
- {settings.showEdgeLabel &&
- <Badge color={label === "relation" ? 'orange' : "blue"} style={{
- position: 'absolute',
- transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
- pointerEvents: 'all',
- opacity: style?.opacity || 1
- }}
- className="nodrag nopan text-xs px-1">{label} {confidence_level &&
- <>{confidence_level}%</>}
- </Badge>}
- </EdgeLabelRenderer>
- </>
- );
-}
\ No newline at end of file
+"use client"
+
+import { useMemo, memo } from "react"
+import { BaseEdge, EdgeLabelRenderer, getBezierPath, getSmoothStepPath, type EdgeProps } from "@xyflow/react"
+import { useInvestigationStore } from "@/store/investigation-store"
+import { Badge } from "@/components/ui/badge"
+
+// Define proper types for the component props
+interface CustomEdgeProps extends EdgeProps {
+ label?: string
+ confidence_level?: number
+}
+
+// Predefined styles to avoid object creation on each render
+const getBadgeStyle = (labelX: number, labelY: number, opacity = 1) => ({
+ position: "absolute" as const,
+ transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
+ pointerEvents: "all" as const,
+ opacity,
+})
+
+// Memoize the component to prevent unnecessary re-renders
+const CustomEdge = memo(
+ ({ id, label, confidence_level, sourceX, sourceY, targetX, targetY, style }: CustomEdgeProps) => {
+ // Only access the specific part of the store that's needed
+ const showEdgeLabel = useInvestigationStore((state) => state.settings.showEdgeLabel)
+
+ // Memoize the path calculation to avoid recalculating on every render
+ const [edgePath, labelX, labelY] = useMemo(
+ () =>
+ getSmoothStepPath({
+ sourceX,
+ sourceY,
+ targetX,
+ targetY,
+ }),
+ [sourceX, sourceY, targetX, targetY],
+ )
+
+ // Memoize the badge style to avoid creating a new object on every render
+ const badgeStyle = useMemo(
+ () => getBadgeStyle(labelX, labelY, typeof style?.opacity === 'number' ? style.opacity : 1),
+ [labelX, labelY, style?.opacity],
+ )
+
+ // Determine badge color once
+ const badgeColor = label === "relation" ? "orange" : "blue"
+
+ return (
+ <>
+ <BaseEdge id={id} path={edgePath} style={style} />
+ {showEdgeLabel && (
+ <EdgeLabelRenderer>
+ <Badge variant={label === "relation" ? "default" : "outline"} color={badgeColor} style={badgeStyle} className="nodrag nopan text-xs px-1">
+ {label}
+ {confidence_level != null && ` ${confidence_level}%`}
+ </Badge>
+ </EdgeLabelRenderer>
+ )}
+ </>
+ )
+ },
+ // Custom comparison function to prevent unnecessary re-renders
+ (prevProps, nextProps) => {
+ // Only re-render if these props change
+ return (
+ prevProps.sourceX === nextProps.sourceX &&
+ prevProps.sourceY === nextProps.sourceY &&
+ prevProps.targetX === nextProps.targetX &&
+ prevProps.targetY === nextProps.targetY &&
+ prevProps.label === nextProps.label &&
+ prevProps.confidence_level === nextProps.confidence_level &&
+ prevProps.style?.opacity === nextProps.style?.opacity
+ )
+ },
+)
+
+// Add display name for debugging
+CustomEdge.displayName = "CustomEdge"
+
+export default CustomEdge
+
diff --git a/flowsint-web/src/components/investigations/floating-edge.tsx b/flowsint-web/src/components/investigations/floating-edge.tsx
index b42dbdda..25ade3c5 100644
--- a/flowsint-web/src/components/investigations/floating-edge.tsx
+++ b/flowsint-web/src/components/investigations/floating-edge.tsx
@@ -1,58 +1,111 @@
-import { getEdgeParams } from '@/lib/utils';
-import {
- EdgeLabelRenderer,
- getStraightPath,
- useInternalNode
-} from '@xyflow/react';
-import { useInvestigationStore } from '@/store/investigation-store';
-import { Badge } from '@/components/ui/badge';
-function FloatingEdge(props: any) {
- const { id, source, target, markerEnd, label, confidence_level, sourceX, sourceY, targetX, targetY, style } = props
- const sourceNode = useInternalNode(source);
- const targetNode = useInternalNode(target);
+"use client"
+
+import { memo, useMemo } from "react"
+import { getEdgeParams } from "@/lib/utils"
+import { EdgeLabelRenderer, getSmoothStepPath, getStraightPath, useInternalNode } from "@xyflow/react"
+import { useInvestigationStore } from "@/store/investigation-store"
+import { Badge } from "@/components/ui/badge"
+
+function FloatingEdge({
+ id,
+ source,
+ target,
+ markerEnd,
+ label,
+ confidence_level,
+ sourceX,
+ sourceY,
+ targetX,
+ targetY,
+ style,
+}: any) {
+ const sourceNode = useInternalNode(source)
+ const targetNode = useInternalNode(target)
const { settings } = useInvestigationStore()
+ // Si les nœuds source ou cible n'existent pas, on ne rend rien
if (!sourceNode || !targetNode) {
- return null;
+ return null
}
- const { sx, sy, tx, ty } = getEdgeParams(
- sourceNode,
- targetNode,
- );
+ // Mémorisation des paramètres de l'arête
+ const edgeParameters = useMemo(() => {
+ return getEdgeParams(sourceNode, targetNode)
+ }, [sourceNode, targetNode])
+
+ // Mémorisation du calcul du chemin et des coordonnées du label
+ const pathData = useMemo(() => {
+ const { sx, sy, tx, ty } = edgeParameters
+ return getStraightPath({
+ sourceX: sx,
+ sourceY: sy,
+ targetX: tx,
+ targetY: ty,
+ })
+ }, [edgeParameters])
+
+ // Mémorisation du style du badge
+ const badgeStyle = useMemo(
+ () => ({
+ position: "absolute" as const,
+ transform: `translate(-50%, -50%) translate(${pathData[1]}px,${pathData[2]}px)`,
+ pointerEvents: "all" as const,
+ opacity: style?.opacity || 1,
+ }),
+ [pathData, style?.opacity],
+ )
- const [edgePath, labelX, labelY] = getStraightPath({
- sourceX: sx,
- sourceY: sy,
- targetX: tx,
- targetY: ty,
- });
+ // Mémorisation du contenu du badge
+ const badgeContent = useMemo(
+ () => (
+ <>
+ {label} {confidence_level && <>{confidence_level}%</>}
+ </>
+ ),
+ [label, confidence_level],
+ )
+
+ // Mémorisation du badge complet
+ const edgeLabel = useMemo(() => {
+ let labelElement = null
+ if (settings.showEdgeLabel) {
+ labelElement = (
+ <Badge
+ color={label === "relation" ? "orange" : "blue"}
+ style={badgeStyle}
+ className="nodrag nopan bg-primary/80 backdrop-blur leading-3.5 border border-primary !text-[.6rem] !px-1 !py-0"
+ >
+ {badgeContent}
+ </Badge>
+ )
+ }
+ return labelElement
+ }, [settings.showEdgeLabel, label, badgeStyle, badgeContent])
return (
<>
- <path
- id={id}
- className="react-flow__edge-path"
- d={edgePath}
- markerEnd={markerEnd}
- style={style}
- />
- <EdgeLabelRenderer>
- {settings.showEdgeLabel &&
- <Badge color={label === "relation" ? 'orange' : "blue"} style={{
- position: 'absolute',
- transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
- pointerEvents: 'all',
- opacity: style?.opacity || 1
- }}
- className="nodrag nopan bg-primary/80 backdrop-blur leading-3.5 border border-primary !text-[.6rem] !px-1 !py-0">{label} {confidence_level &&
- <>{confidence_level}%</>}
- </Badge>}
- </EdgeLabelRenderer></>
-
- );
+ <path id={id} className="react-flow__edge-path" d={pathData[0]} markerEnd={markerEnd} style={style} />
+ <EdgeLabelRenderer>{edgeLabel}</EdgeLabelRenderer>
+ </>
+ )
}
-export default FloatingEdge;
+// Fonction de comparaison personnalisée pour memo
+function arePropsEqual(prevProps: any, nextProps: any) {
+ return (
+ prevProps.id === nextProps.id &&
+ prevProps.source === nextProps.source &&
+ prevProps.target === nextProps.target &&
+ prevProps.label === nextProps.label &&
+ prevProps.confidence_level === nextProps.confidence_level &&
+ prevProps.style?.opacity === nextProps.style?.opacity &&
+ prevProps.sourceX === nextProps.sourceX &&
+ prevProps.sourceY === nextProps.sourceY &&
+ prevProps.targetX === nextProps.targetX &&
+ prevProps.targetY === nextProps.targetY
+ )
+}
+// Export du composant mémorisé
+export default memo(FloatingEdge, arePropsEqual)
diff --git a/flowsint-web/src/components/investigations/graph.tsx b/flowsint-web/src/components/investigations/graph.tsx
index 1012c36f..b4ee7d25 100644
--- a/flowsint-web/src/components/investigations/graph.tsx
+++ b/flowsint-web/src/components/investigations/graph.tsx
@@ -45,10 +45,13 @@ import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger }
import AddNodeModal from "./add-node-modal"
import { Dialog, DialogTrigger } from "../ui/dialog"
import { memo } from "react"
+import { shallow } from "zustand/shallow"
+import CustomEdge from "./custom-edge"
+import floatingEdge from "./floating-edge"
// Define constants outside component to prevent recreation
const edgeTypes = {
- custom: FloatingEdge,
+ custom: floatingEdge
}
const nodeTypes = {
@@ -60,8 +63,6 @@ const nodeTypes = {
address: AddressNode,
}
-import { shallow } from "zustand/shallow"
-
// Split selectors to minimize re-renders
const nodeEdgeSelector = (store: { nodes: any; edges: any }) => ({
nodes: store.nodes,
@@ -252,6 +253,7 @@ const LayoutFlow = ({ refetch, theme }: LayoutFlowProps) => {
fitView
proOptions={{ hideAttribution: true }}
nodeTypes={nodeTypes}
+ // @ts-ignore
edgeTypes={edgeTypes}
className="!bg-background"
>
diff --git a/flowsint-web/src/components/investigations/large-data-graph.tsx b/flowsint-web/src/components/investigations/large-data-graph.tsx
index ff1a35dd..eacccab6 100644
--- a/flowsint-web/src/components/investigations/large-data-graph.tsx
+++ b/flowsint-web/src/components/investigations/large-data-graph.tsx
@@ -1,19 +1,29 @@
"use client"
-import React, { useEffect, useState, useCallback, useMemo } from "react"
+
+import { useEffect, useState, useCallback, useMemo, useRef } from "react"
import dynamic from "next/dynamic"
import { Button } from "@/components/ui/button"
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from "@/components/ui/tooltip"
-import { AlignCenterVertical, PencilRulerIcon, RotateCwIcon } from "lucide-react"
+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 { useQueryState } from "nuqs"
+// @ts-ignore
+import * as d3 from 'd3'
// Import ForceGraph2D with types
-const ForceGraph2D = dynamic(() => import('react-force-graph-2d'), { ssr: false })
+const ForceGraph2D = dynamic(() => import("react-force-graph-2d"), { ssr: false })
// Constants
const NODE_R = 8
+const GROUPS_COLORS = {
+ individual: "#ff6b6b",
+ email: "#4ecdc4",
+ phone: "#45b7d1",
+ address: "#96ceb4",
+ social: "#ffeead",
+}
// Types
interface NodeData {
@@ -21,12 +31,14 @@ interface NodeData {
color?: string
x?: number
y?: number
+ group?: string
[key: string]: any
}
interface EdgeData {
source: string
target: string
+ type?: string
[key: string]: any
}
@@ -64,18 +76,29 @@ function LayoutFlow({ refetch, theme }: LayoutFlowProps) {
const [highlightNodes, setHighlightNodes] = useState<Set<string>>(new Set())
const [highlightLinks, setHighlightLinks] = useState<Set<string>>(new Set())
const [hoverNode, setHoverNode] = useState<ForceGraphNode | null>(null)
- const graphRef = React.useRef<any>(null)
-
+ const graphRef = useRef<any>(null)
+ const [zoomLevel, setZoomLevel] = useState(1)
const { nodes, edges, reloading } = useFlowStore()
- // Convert data for ForceGraph
+ // Amélioration du groupement des nœuds
+ const getNodeGroup = useCallback((node: NodeData) => {
+ if (node.data?.type?.includes("individual")) return "individual"
+ if (node.data?.type?.includes("email")) return "email"
+ if (node.data?.type?.includes("phone")) return "phone"
+ if (node.data?.type?.includes("address")) return "address"
+ if (node.data?.type?.includes("social")) return "social"
+ return "other"
+ }, [])
+
+ // Convert data for ForceGraph with improved grouping
const graphData: GraphData = useMemo(() => {
return {
nodes: nodes.map((node) => ({
id: node.id,
...node.data,
- color: typeof node.data.color === "string" ? node.data.color : (theme === "dark" ? "#fff" : "#000"),
+ group: getNodeGroup(node),
+ color: GROUPS_COLORS[getNodeGroup(node) as keyof typeof GROUPS_COLORS] || "#666",
})),
links: edges.map((edge) => ({
source: edge.source,
@@ -83,79 +106,128 @@ function LayoutFlow({ refetch, theme }: LayoutFlowProps) {
...edge.data,
})),
}
- }, [nodes, edges, theme])
-
- const handleNodeHover = (node: { [key: string]: any; id?: string | number; x?: number; y?: number; color?: string } | null) => {
- setHoverNode(node && typeof node.id === 'string' ? node as ForceGraphNode : null)
- setHighlightNodes(new Set(node && typeof node.id === 'string' ? [node.id] : []))
- setHighlightLinks(
- new Set(
- node
- ? edges
- .filter((edge) => edge.source === node.id || edge.target === node.id)
- .map((edge) => `${edge.source}-${edge.target}`)
- : [],
- ),
- )
- }
+ }, [nodes, edges, getNodeGroup])
- const handleNodeClick = useCallback((node: { [key: string]: any; id?: string | number; x?: number; y?: number; color?: string }, event: MouseEvent) => {
- if (node && graphRef.current) {
- if (node.x !== undefined && node.y !== undefined) {
- graphRef.current.centerAt(node.x, node.y, 1000)
- graphRef.current.zoom(2, 1000)
+ // Amélioration du rendu des nœuds
+ const Node = useCallback(
+ (node: any, ctx: CanvasRenderingContext2D) => {
+ if (node.x === undefined || node.y === undefined) return
+
+ const label = node.data.label
+ const fontSize = 12
+ ctx.font = `${fontSize}px Inter, system-ui, sans-serif`
+ const textWidth = ctx.measureText(label).width
+ const padding = 12
+ const height = 24
+ const width = textWidth + padding * 2
+
+ // Dessiner l'ombre
+ ctx.shadowColor = "rgba(0, 0, 0, 0.1)"
+ ctx.shadowBlur = 5
+ ctx.shadowOffsetX = 0
+ ctx.shadowOffsetY = 2
+
+ // Dessiner le fond
+ ctx.fillStyle = node.color
+ const radius = height / 2
+
+ // Créer le chemin pour la forme de pilule
+ ctx.beginPath()
+ ctx.moveTo(node.x - width / 2 + radius, node.y - height / 2)
+ ctx.lineTo(node.x + width / 2 - radius, node.y - height / 2)
+ ctx.arcTo(node.x + width / 2, node.y - height / 2, node.x + width / 2, node.y, radius)
+ ctx.lineTo(node.x + width / 2, node.y + height / 2 - radius)
+ ctx.arcTo(node.x + width / 2, node.y + height / 2, node.x + width / 2 - radius, node.y + height / 2, radius)
+ ctx.lineTo(node.x - width / 2 + radius, node.y + height / 2)
+ ctx.arcTo(node.x - width / 2, node.y + height / 2, node.x - width / 2, node.y + height / 2 - radius, radius)
+ ctx.lineTo(node.x - width / 2, node.y - height / 2 + radius)
+ ctx.arcTo(node.x - width / 2, node.y - height / 2, node.x - width / 2 + radius, node.y - height / 2, radius)
+ ctx.fill()
+
+ // Réinitialiser l'ombre pour le texte
+ ctx.shadowColor = "transparent"
+
+ // Dessiner le texte
+ ctx.textAlign = "center"
+ ctx.textBaseline = "middle"
+ ctx.fillStyle = theme === "dark" ? "#fff" : "#000"
+ ctx.fillText(label, node.x, node.y)
+
+ // Ajouter un effet de surbrillance pour les nœuds en survol
+ if (highlightNodes.has(node.id)) {
+ ctx.strokeStyle = theme === "dark" ? "#fff" : "#000"
+ ctx.lineWidth = 2
+ ctx.stroke()
}
- }
- }, [])
+ },
+ [highlightNodes, theme],
+ )
- const Node = useCallback(
- (
- node: { [key: string]: any; id?: string | number; x?: number; y?: number; color?: string },
- ctx: CanvasRenderingContext2D,
- ) => {
- if (node.x !== undefined && node.y !== undefined) {
- const label = node.data.label
- const fontSize = 14 // Increased font size
- ctx.font = `${fontSize}px system-ui, -apple-system, sans-serif` // System font
- const textWidth = ctx.measureText(label).width
- const padding = fontSize * 0.8 // Increased padding
- const height = fontSize * 1.8 // Fixed height for pill shape
- const width = textWidth + padding * 2 // Add padding to both sides
-
- // Draw rounded rectangle background
- ctx.fillStyle = "#f1f1f1" // Light gray background
- const radius = height / 2 // Radius for pill shape
-
- ctx.beginPath()
- ctx.moveTo(node.x - width / 2 + radius, node.y - height / 2)
- ctx.lineTo(node.x + width / 2 - radius, node.y - height / 2)
- ctx.arcTo(node.x + width / 2, node.y - height / 2, node.x + width / 2, node.y, radius)
- ctx.lineTo(node.x + width / 2, node.y + height / 2 - radius)
- ctx.arcTo(node.x + width / 2, node.y + height / 2, node.x + width / 2 - radius, node.y + height / 2, radius)
- ctx.lineTo(node.x - width / 2 + radius, node.y + height / 2)
- ctx.arcTo(node.x - width / 2, node.y + height / 2, node.x - width / 2, node.y + height / 2 - radius, radius)
- ctx.lineTo(node.x - width / 2, node.y - height / 2 + radius)
- ctx.arcTo(node.x - width / 2, node.y - height / 2, node.x - width / 2 + radius, node.y - height / 2, radius)
- ctx.fill()
-
- // Draw text
- ctx.textAlign = "center"
- ctx.textBaseline = "middle"
- ctx.fillStyle = "#000000" // Dark text color
- ctx.fillText(label, node.x, node.y)
+ // Amélioration des interactions
+ const handleNodeHover = useCallback(
+ (node: ForceGraphNode | null) => {
+ setHoverNode(node)
+ setHighlightNodes(new Set(node ? [node.id] : []))
+
+ // Mettre en évidence les liens connectés
+ const connectedLinks = new Set<string>()
+ if (node) {
+ edges.forEach((edge) => {
+ if (edge.source === node.id || edge.target === node.id) {
+ connectedLinks.add(`${edge.source}-${edge.target}`)
+ // Ajouter les nœuds connectés à la surbrillance
+ // @ts-ignore
+ setHighlightNodes((prev) => new Set([...prev, edge.source, edge.target]))
+ }
+ })
}
+ setHighlightLinks(connectedLinks)
},
- [hoverNode],
+ [edges],
)
+ const handleNodeClick = useCallback((node: ForceGraphNode, event: MouseEvent) => {
+ if (node && graphRef.current) {
+ // Zoom plus fluide et naturel
+ const distance = 13000
+ graphRef.current.centerAt(node.x, node.y, distance)
+ graphRef.current.zoom(2.5, distance)
+ }
+ }, [])
+
useEffect(() => {
- if (graphRef && graphRef.current)
+ if (graphRef.current) {
+ // Significantly increase repulsion force
+ graphRef.current
+ .d3Force("link")
+ .distance(() => 2100) // Increase from 150 to 200
+ .strength(0.1) // Decrease from 0.2 to 0.1 for more flexibility
+
graphRef.current
- .d3Force("link", undefined)
- .iterations(1)
- .distance(220);
+ .d3Force("charge")
+ .strength(-400) // Double the repulsion from -200 to -400
+ .distanceMax(5100) // Increase from 250 to 500
+
+ // Add this to improve initial positioning
+ graphRef.current.d3Force("x", d3.forceX().strength(0.05))
+ graphRef.current.d3Force("y", d3.forceY().strength(0.05))
+ }
+ }, [])
+
+ const handleZoomIn = useCallback(() => {
+ if (graphRef.current) {
+ const currentZoom = graphRef.current.zoom()
+ graphRef.current.zoom(currentZoom * 1.2, 400)
+ }
+ }, [])
+
+ const handleZoomOut = useCallback(() => {
+ if (graphRef.current) {
+ const currentZoom = graphRef.current.zoom()
+ graphRef.current.zoom(currentZoom / 1.2, 400)
+ }
+ }, [])
- }, [graphRef, graphRef.current, nodes, edges])
return (
<div className="relative h-[calc(100vh_-_48px)]">
<div className="absolute top-3.5 left-3.5 z-10 flex items-center gap-1">
@@ -166,43 +238,70 @@ function LayoutFlow({ refetch, theme }: LayoutFlowProps) {
<AlignCenterVertical className="h-4 w-4" />
</Button>
</TooltipTrigger>
- <TooltipContent>Auto layout</TooltipContent>
+ <TooltipContent>Fit view</TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button size="icon" variant="outline" onClick={handleZoomIn}>
+ <ZoomInIcon className="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Zoom in</TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button size="icon" variant="outline" onClick={handleZoomOut}>
+ <ZoomOutIcon className="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Zoom out</TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button size="icon" variant="outline" onClick={() => setView("flow-graph")}>
+ <PencilRulerIcon className="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Switch to editor</TooltipContent>
</Tooltip>
</TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="icon"
- variant="outline"
- onClick={() => setView("flow-graph")}
- >
- <PencilRulerIcon className='h-4 w-4' />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- Editor
- </TooltipContent>
- </Tooltip>
</div>
+
<div className="absolute top-4 right-4 z-10 flex items-center gap-1">
<Button size="icon" disabled={reloading} variant="outline" onClick={refetch}>
<RotateCwIcon className={`h-4 w-4 ${reloading ? "animate-spin" : ""}`} />
</Button>
</div>
+
<ForceGraph2D
- nodeAutoColorBy="group"
ref={graphRef}
graphData={graphData}
nodeRelSize={NODE_R}
- nodeColor={(node: any) => ("transparent")}
- linkWidth={(link: any) => (highlightLinks.has(`${(link.source as ForceGraphNode).id}-${(link.target as ForceGraphNode).id}`) ? 2 : 1)}
- linkDirectionalParticles={4}
- linkDirectionalParticleWidth={(link: any) => (highlightLinks.has(`${(link.source as ForceGraphNode).id}-${(link.target as ForceGraphNode).id}`) ? 2 : 0)}
- nodeCanvasObjectMode={() => "after"}
nodeCanvasObject={Node}
+ nodeCanvasObjectMode={() => "after"}
+ linkColor={() => (theme === "dark" ? "#ffffff33" : "#00000033")}
+ linkWidth={(link: any) =>
+ highlightLinks.has(`${(link.source as ForceGraphNode).id}-${(link.target as ForceGraphNode).id}`) ? 2 : 1
+ }
+ linkDirectionalParticles={4}
+ linkDirectionalParticleWidth={(link: any) =>
+ highlightLinks.has(`${(link.source as ForceGraphNode).id}-${(link.target as ForceGraphNode).id}`) ? 2 : 0
+ }
+ linkDirectionalParticleColor={() => (theme === "dark" ? "#fff" : "#000")}
+ // @ts-ignore
onNodeHover={handleNodeHover}
+ // @ts-ignore
onNodeClick={handleNodeClick}
- backgroundColor={"transparent"}
+ backgroundColor="transparent"
+ d3AlphaDecay={0.01} // Ralentir la stabilisation pour un meilleur layout
+ d3VelocityDecay={0.4} // Amortissement du mouvement
+ cooldownTime={3000} // Temps de stabilisation plus long
+ onEngineStop={() => {
+ // Ajuster la position des nœuds après la stabilisation
+ if (graphRef.current) {
+ graphRef.current.zoomToFit(400)
+ }
+ }}
/>
</div>
)
@@ -220,19 +319,19 @@ export default function LargeInvestigationGraph({ graphQuery }: LargeInvestigati
useEffect(() => {
if (data) {
useFlowStore.setState({
- nodes: data?.nodes.map(node => ({
+ nodes: data?.nodes.map((node) => ({
...node,
position: { x: node.x ?? 0, y: node.y ?? 0 },
- data: node
+ data: node,
})),
- edges: data?.edges.map(edge => ({
+ edges: data?.edges.map((edge) => ({
...edge,
- id: `${edge.source}-${edge.target}`
- }))
+ id: `${edge.source}-${edge.target}`,
+ })),
})
setMounted(true)
}
- }, [data, data?.nodes, data?.edges])
+ }, [data])
if (!mounted || isLoading) {
return (
@@ -243,4 +342,5 @@ export default function LargeInvestigationGraph({ graphQuery }: LargeInvestigati
}
return <LayoutFlow refetch={refetch} isLoading={isLoading} theme={resolvedTheme as string} />
-}
\ No newline at end of file
+}
+
diff --git a/flowsint-web/src/components/investigations/layout.tsx b/flowsint-web/src/components/investigations/layout.tsx
index c2189f3e..aa7edc19 100644
--- a/flowsint-web/src/components/investigations/layout.tsx
+++ b/flowsint-web/src/components/investigations/layout.tsx
@@ -30,7 +30,7 @@ const InvestigationLayout = ({
const { panelOpen, setPanelOpen } = useInvestigationStore()
return (
<SidebarProvider defaultOpen={false}>
- <AppSidebar user={user} defaultChecked={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}>
<div className='flex flex-col w-full h-full rounded-none shadow-none border-r'>
diff --git a/flowsint-web/src/components/investigations/nodes/email.tsx b/flowsint-web/src/components/investigations/nodes/email.tsx
index 93f8f2a3..30e88750 100644
--- a/flowsint-web/src/components/investigations/nodes/email.tsx
+++ b/flowsint-web/src/components/investigations/nodes/email.tsx
@@ -101,7 +101,7 @@ function EmailNode({ data }: any) {
// Mémorisation de la poignée
const handle = useMemo(
- () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500 hidden")} />,
+ () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500")} />,
[],
)
diff --git a/flowsint-web/src/components/investigations/nodes/individual.tsx b/flowsint-web/src/components/investigations/nodes/individual.tsx
index 0f2302d5..7cde1d1c 100644
--- a/flowsint-web/src/components/investigations/nodes/individual.tsx
+++ b/flowsint-web/src/components/investigations/nodes/individual.tsx
@@ -9,19 +9,20 @@ 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 { SquarePenIcon } from "lucide-react"
+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,
+ 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"
@@ -30,200 +31,246 @@ 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
+ 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])
+ // 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
+ // 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])
+ 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>
- )
- }
+ // 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])
+ 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", showContent ? "group-hover:opacity-100 opacity-0" : "opacity-0")}
- />
- <Handle
- type="source"
- position={Position.Bottom}
- className={cn("w-16 bg-teal-500", showContent ? "group-hover:opacity-100 opacity-0" : "opacity-0")}
- />
- </>
- ),
- [showContent],
- )
+ // Mémorisation des handles pour éviter les recalculs
+ const handles = useMemo(
+ () => (
+ <>
+ <Handle
+ type="target"
+ position={Position.Top}
+ // className={cn("w-16 bg-teal-500", showContent ? "group-hover:opacity-100 opacity-0" : "opacity-0")}
+ />
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ // className={cn("w-16 bg-teal-500", showContent ? "group-hover:opacity-100 opacity-0" : "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>
- {/* Autres éléments de menu... */}
- </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,
- ],
- )
+ // 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>
- )
+ 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
- )
- },
+ (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/nodes/ip_address.tsx b/flowsint-web/src/components/investigations/nodes/ip_address.tsx
index 7495701c..04a703fb 100644
--- a/flowsint-web/src/components/investigations/nodes/ip_address.tsx
+++ b/flowsint-web/src/components/investigations/nodes/ip_address.tsx
@@ -77,7 +77,7 @@ function IpNode({ data }: any) {
// Mémorisation de la poignée
const handle = useMemo(
- () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500 hidden")} />,
+ () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500")} />,
[],
)
diff --git a/flowsint-web/src/components/investigations/nodes/minimal_individual.tsx b/flowsint-web/src/components/investigations/nodes/minimal_individual.tsx
new file mode 100644
index 00000000..f25d7a35
--- /dev/null
+++ b/flowsint-web/src/components/investigations/nodes/minimal_individual.tsx
@@ -0,0 +1,156 @@
+"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 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",
+ 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", showContent ? "group-hover:opacity-100 opacity-0" : "opacity-0")}
+ />
+ <Handle
+ type="source"
+ position={Position.Bottom}
+ // className={cn("w-16 bg-teal-500", showContent ? "group-hover:opacity-100 opacity-0" : "opacity-0")}
+ />
+ </>
+ ),
+ [showContent],
+ )
+
+ return (
+ <div style={{ ...props.style, borderRadius: "100000px!important" }}>
+ <div className={cn(loading ? "opacity-40" : "opacity-100", "overflow-hidden group")}>
+ {nodeContent}
+ {handles}
+ </div>
+ </div>
+ )
+}
+
+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/nodes/phone.tsx b/flowsint-web/src/components/investigations/nodes/phone.tsx
index 69e0c32b..85cc9384 100644
--- a/flowsint-web/src/components/investigations/nodes/phone.tsx
+++ b/flowsint-web/src/components/investigations/nodes/phone.tsx
@@ -71,7 +71,7 @@ function PhoneNode({ data }: any) {
}, [settings.showNodeLabel, showContent, currentNode, data.id, data.label, settings.showCopyIcon])
const handle = useMemo(
- () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500 hidden")} />,
+ () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500")} />,
[],
)
const contextMenu = useMemo(
diff --git a/flowsint-web/src/components/investigations/nodes/physical_address.tsx b/flowsint-web/src/components/investigations/nodes/physical_address.tsx
index 731b73b0..4f30641a 100644
--- a/flowsint-web/src/components/investigations/nodes/physical_address.tsx
+++ b/flowsint-web/src/components/investigations/nodes/physical_address.tsx
@@ -32,46 +32,28 @@ function AddressNode({ data }: any) {
const handleSearch = useCallback(() => handleOpenSearchModal(data.label), [data.label, handleOpenSearchModal])
const nodeContent = useMemo(() => {
- if (settings.showNodeLabel && showContent) {
- return (
- <Card
- className={cn(
- "border hover:border-primary rounded-full p-0 shadow-none backdrop-blur bg-background/40",
- currentNode === data.id && "border-primary",
- )}
- >
- <div className="flex items-center gap-2 p-1">
- <Badge variant="secondary" className="h-6 w-6 p-0 rounded-full">
- <LocateIcon className="h-4 w-4" />
- </Badge>
- <div className="flex items-center gap-1">
- <span className="text-sm">{data.label}</span>
- {settings.showCopyIcon && <CopyButton className="rounded-full h-7 w-7 text-xs" content={data.label} />}
- </div>
- </div>
- </Card>
- )
- }
return (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button variant="ghost" className="rounded-full p-0">
- <Avatar className="h-6 w-6">
- <AvatarFallback>
- <LocateIcon className="h-3 w-3" />
- </AvatarFallback>
- </Avatar>
- </Button>
- </TooltipTrigger>
- <TooltipContent>{data.label}</TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <Card
+ className={cn(
+ "border hover:border-primary rounded-full p-0 shadow-none backdrop-blur bg-background/40",
+ currentNode === data.id && "border-primary",
+ )}
+ >
+ <div className="flex items-center gap-2 p-1">
+ <Badge variant="secondary" className="h-6 w-6 p-0 rounded-full">
+ <LocateIcon className="h-4 w-4" />
+ </Badge>
+ <div className="flex items-center gap-1">
+ <span className="text-sm">{data.label}</span>
+ {settings.showCopyIcon && <CopyButton className="rounded-full h-7 w-7 text-xs" content={data.label} />}
+ </div>
+ </div>
+ </Card>
)
- }, [settings.showNodeLabel, showContent, currentNode, data.id, data.label, settings.showCopyIcon])
+ }, [currentNode, data.id, data.label, settings.showCopyIcon])
const handle = useMemo(
- () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500 hidden")} />,
+ () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500")} />,
[],
)
const contextMenu = useMemo(
diff --git a/flowsint-web/src/components/investigations/nodes/social.tsx b/flowsint-web/src/components/investigations/nodes/social.tsx
index 80a4b3d7..688ed203 100644
--- a/flowsint-web/src/components/investigations/nodes/social.tsx
+++ b/flowsint-web/src/components/investigations/nodes/social.tsx
@@ -97,7 +97,7 @@ function SocialNode({ data }: any) {
// Mémorisation de la poignée
const handle = useMemo(
- () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500 hidden")} />,
+ () => <Handle type="target" position={Position.Top} className={cn("w-16 bg-teal-500")} />,
[],
)
diff --git a/flowsint-web/src/components/nav-user.tsx b/flowsint-web/src/components/nav-user.tsx
index ed086700..b8323a69 100644
--- a/flowsint-web/src/components/nav-user.tsx
+++ b/flowsint-web/src/components/nav-user.tsx
@@ -98,10 +98,12 @@ export function NavUser({
<Bell />
Notifications
</DropdownMenuItem>
- <DropdownMenuItem>
- <ThemeSwitch />
+ <DropdownMenuSeparator />
+ <DropdownMenuLabel className="text-xs font-light opacity-60">Preferences</DropdownMenuLabel>
+ <div className="flex text-sm items-center justify-between px-3">
Theme
- </DropdownMenuItem>
+ <ThemeSwitch />
+ </div>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={logout}>
diff --git a/flowsint-web/src/store/flow-store.ts b/flowsint-web/src/store/flow-store.ts
index d2e1270d..f4a1de2e 100644
--- a/flowsint-web/src/store/flow-store.ts
+++ b/flowsint-web/src/store/flow-store.ts
@@ -72,6 +72,7 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>
set({ currentNode: nodeId });
},
onConnect: async (params: any, investigation_id?: string) => {
+ console.log(investigation_id)
if (!investigation_id) return;
try {
// Insertion dans Supabase